The tests Rakudo doesn't run

masak on 2010-05-09T15:03:59

Just a short note.

After an enlightening discussion with mberends a couple of days ago, I became curious about how many spectests Rakudo doesn't run.

So I wrote a short script which takes a list of all spectest .t files, a list of all the files mentioned in Rakudo's t/spectest.data (including the commented-out ones), and did hash subtraction on them.

By the way, a common Perl 5 idiom in this situation is difficult to do in Rakudo, because some blocks are still erroneously parsed as hashes:

$ perl6
> my @array; my %hash = map { $_ => 1 }, @array;
No candidates found to invoke
> say { $_ => 1 }.WHAT
Hash()

Working around this, I arrived at the number 185. That's out of a total of 722. Here's the whole list.

Not too surprisingly, upon showing this list to #perl6, I was quickly informed (by the ever-knowledgeable moritz++) that there's already a Rakudo tool script which processes exactly this list of tests, and prints the much more useful subset of files with at least one test passing, thus being eligible for inclusion into t/spectest.data.

I hope to be able to explore the spectest suite further, in my copious spare time. My long-term goal is to create alluring SVG graphs over the tests currently passing in Rakudo master, Rakudo alpha, and Pugs.


A common workaround

moritz on 2010-05-09T16:40:59

my %hash;
%hash{@array} = 1 xx @array;

Actually I like that better than the map, but I agree it sucks that the map version doesn't work right now.

Re:A common workaround

masak on 2010-05-09T21:17:47

I think I like it better too. Just gotta internalize it :)

Hm, once laziness is in place, one could even do '1 xx *'. That pleases me.

Re:A common workaround

Aristotle on 2010-05-09T21:42:01

Some variation on this ought to work:

my %hash = @array X 1;

That would seem like the most direct expression of what one wants.

But I can’t quite figure out the right incantation.

Re:A common workaround

moritz on 2010-05-10T09:14:15

This should work indeed, but currently suffers from a lack of list flattening in Rakudo. Specifically

my @a = <a b c>;
say (@a X 1).perl; # ("a", 1, "b", 1, "c", 1)
say (@a X 1).elems; # 3

And then the hash assignment complains about an odd number of elements.

One can explictly construct Pair objects though:

my %h = @a X=> 1;
say %h.perl; # {"a" => 1, "b" => 1, "c" => 1}

Which is maybe a bit prettier than colomon's solution, but we can argue about that :-)

Re:A common workaround

colomon on 2010-05-10T02:21:19

what's the matter with %hash = @array >>=>>> 1 ? (might not work with texas hyper, but does with the normal hyper.)