Permalink
Browse files

Some updates to S29-list.

git-svn-id: http://svn.pugscode.org/pugs@21162 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
pmichaud
pmichaud committed Jul 2, 2008
1 parent 368ec90 commit 0960758f0674f773dd611453d2e8b8ad44533bc8
Showing with 30 additions and 21 deletions.
  1. +11 −9 S29-list/grep.t
  2. +10 −6 S29-list/map.t
  3. +4 −2 S29-list/reduce.t
  4. +5 −4 S29-list/sort.t
View
@@ -23,7 +23,7 @@ my @list = (1 .. 10);
is(@result[4], 9, 'got the value we expected');
}
-#?rakudo skip "adverbial closure"
+#?rakudo skip "adverbial block"
{
my @result = @list.grep():{ ($_ % 2) };
is(+@result, 5, 'we got a list back');
@@ -34,7 +34,7 @@ my @list = (1 .. 10);
is(@result[4], 9, 'got the value we expected');
}
-#?rakudo skip "adverbial closure"
+#?rakudo skip "adverbial block"
{
my @result = @list.grep :{ ($_ % 2) };
is(+@result, 5, 'we got a list back');
@@ -45,18 +45,20 @@ my @list = (1 .. 10);
is(@result[4], 9, 'got the value we expected');
}
-#?rakudo skip "adverbial closure"
+#?rakudo skip "closure as non-final argument"
{
my @result = grep { ($_ % 2) }: @list;
- is(+@result, 5, 'we got a list back');
- is(@result[0], 1, 'got the value we expected');
- is(@result[1], 3, 'got the value we expected');
- is(@result[2], 5, 'got the value we expected');
- is(@result[3], 7, 'got the value we expected');
- is(@result[4], 9, 'got the value we expected');
+ is(+@result, 5, 'we got a list back');
+ is(@result[0], 1, 'got the value we expected');
+ is(@result[1], 3, 'got the value we expected');
+ is(@result[2], 5, 'got the value we expected');
+ is(@result[3], 7, 'got the value we expected');
+ is(@result[4], 9, 'got the value we expected');
}
# .grep shouldn't work on non-arrays
+## XXX pmichaud, 2008-07-01:
+## p6l says that .grep should work on non-list values.
{
#?pugs 2 todo 'bug'
dies_ok { 42.grep: { $_ } }, "method form of grep should not work on numbers";
View
@@ -23,7 +23,7 @@ my @list = (1 .. 5);
is(@result[4], 10, 'got the value we expected');
}
-#?rakudo skip "adverbial closure"
+#?rakudo skip "adverbial block"
{
my @result = @list.map():{ $_ * 2 };
is(+@result, 5, 'we got a list back');
@@ -44,7 +44,7 @@ my @list = (1 .. 5);
is(@result[4], 10, 'got the value we expected');
}
-#?rakudo skip "colon invocant syntax"
+#?rakudo skip "closure as non-final argument"
{
my @result = map { $_ * 2 }: @list;
is(+@result, 5, 'we got a list back');
@@ -100,7 +100,7 @@ my @list = (1 .. 5);
}
# map with n-ary functions
-#?rakudo skip "colon invocant syntax"
+#?rakudo skip "adverbial block"
{
is ~(1,2,3,4).map:{ $^a + $^b }, "3 7", "map() works with 2-ary functions";
is ~(1,2,3,4).map:{ $^a + $^b + $^c }, "6 4", "map() works with 3-ary functions";
@@ -109,11 +109,12 @@ my @list = (1 .. 5);
}
# .map shouldn't work on non-arrays
+## XXX pmichaud, 2008-07-01: .map should work on non-list values
{
#?pugs 2 todo 'bug'
dies_ok { 42.map: { $_ } }, "method form of map should not work on numbers";
dies_ok { "str".map: { $_ } }, "method form of map should not work on strings";
- #?rakudo skip "colon invocant syntax"
+ #?rakudo skip "adverbial block"
is ~(42,).map:{ $_ }, "42", "method form of map should work on arrays";
};
@@ -130,7 +131,10 @@ should be equivalent to
=end pod
-#?rakudo skip "colon invocant syntax"
+## XXX pmichaud, 2008-07-01: As the test is written below, the
+## @expected and "map of ..." arguments are arguments of .map(...)
+## and not of is(...). See S12:406.
+#?rakudo skip "syntax error in test"
{
my @expected = ("foo","bar");
@expected = map { substr($_,1,1) }: @expected;
@@ -139,7 +143,7 @@ should be equivalent to
}
-#?rakudo skip "no hashes at the moment"
+#?rakudo skip '{} hash composer not implemented'
{
my @a = (1, 2, 3);
# XXX is hash { ... } legal?
View
@@ -20,8 +20,9 @@ plan 11;
my $sum = 5 + -3 + 7 + 0 + 1 + -9; # laziness :)
is((reduce { $^a + $^b }, 0, @array), $sum, "basic reduce works (1)");
-#?rakudo 2 skip 'adverbial closure'
+#?rakudo skip 'closure as non-final argument'
is((reduce { $^a + $^b }: 100, @array), 100 + $sum, "basic reduce works (2)");
+#?rakudo skip 'method fallback to sub unimpl'
is(({ $^a * $^b }.reduce: 1,2,3,4,5), 120, "basic reduce works (3)");
}
@@ -34,14 +35,15 @@ plan 11;
}
# .reduce shouldn't work on non-arrays
+## XXX pmichaud, 2008-07-01: .reduce should work on non-list values
{
#?pugs 2 todo 'bug'
dies_ok { 42.reduce: { $^a + $^b } }, "method form of reduce should not work on numbers";
dies_ok { "str".reduce: { $^a + $^b } }, "method form of reduce should not work on strings";
is ((42,).reduce: { $^a + $^b }), 42, "method form of reduce should work on arrays";
}
-#?rakudo 4 skip 'parsefail'
+#?rakudo 4 skip '{} hash composer not implemented'
{
my $hash = {a => {b => {c => 42}}};
my @reftypes;
View
@@ -36,16 +36,16 @@ plan 21;
is(@s, @e, '... with explicit spaceship');
}
-#?rakudo skip "adverbial closure"
+#?rakudo skip "closure as non-final argument"
{
my @a = (2, 45, 6, 1, 3);
my @e = (1, 2, 3, 6, 45);
my @s = sort { $^a <=> $^b }: @a;
- is(@s, @e, '... with closure as indirect invocant');
+ is(@s, @e, '... with closure as indirect invocant');
}
-#?rakudo skip "adverbial closure"
+#?rakudo skip "method fallback to sub unimpl"
{
my @a = (2, 45, 6, 1, 3);
my @e = (1, 2, 3, 6, 45);
@@ -152,7 +152,8 @@ plan 21;
}
# .sort shouldn't work on non-arrays
-#?rakudo skip 'adverbial closure'
+## XXX pmichaud, 2008-07-01: .sort should work on non-list values
+#?rakudo skip 'test errors, adverbial block'
{
#?pugs 2 todo 'bug'
dies_ok { 42.sort: { 0 } }, "method form of sort should not work on numbers";

0 comments on commit 0960758

Please sign in to comment.