Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[t/spec] clean up and fudge reduce-metaop.t for rakudo.

git-svn-id: http://svn.pugscode.org/pugs@24211 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit 21768a77438c992c5c5736452985fc8aa8f23e28 1 parent 3d9d4c4
moritz authored
Showing with 27 additions and 7 deletions.
  1. +27 −7 S03-operators/reduce-metaop.t
View
34 S03-operators/reduce-metaop.t
@@ -1,6 +1,7 @@
use v6;
use Test;
-plan 52;
+# XXX not sure if plan is right :(
+plan 50;
=begin pod
@@ -26,6 +27,7 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
is(([/] 12,4,3), (12/4/3), "[/] works");
is(([**] 2,2,3), (2**2**3), "[**] works");
+ #?rakudo 2 skip '[\...] meta ops'
is((~ [\+] @array), "5 2 9 9 10 1", "[\\+] works");
is((~ [\-] 1, 2, 3), "1 -1 -4", "[\\-] works");
}
@@ -33,9 +35,11 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
{
is ([~] <a b c d>), "abcd", "[~] works";
+ #?rakudo skip '[\...] meta ops'
is (~ [\~] <a b c d>), "a ab abc abcd", "[\\~] works";
}
+#?rakudo skip '[<comparisonop>]'
{
ok ( [<] 1, 2, 3, 4), "[<] works (1)";
ok (not [<] 1, 3, 2, 4), "[<] works (2)";
@@ -58,12 +62,14 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
is ([~] [\**] 3, 2, 0), "0 1 3", "[\\**] (right assoc) works (2)";
}
+#?rakudo skip '[//], [orelse]'
{
my @array = (undef, undef, 3, undef, 5);
is ([//] @array), 3, "[//] works";
is ([orelse] @array), 3, "[orelse] works";
}
+#?rakudo skip '[||]'
{
my @array = (undef, undef, 0, 3, undef, 5);
is ([||] @array), 3, "[||] works";
@@ -90,6 +96,7 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
# is ([.[]] $arr, 1, 0, 2), 9, '[.[]] works';
# }
+#?rakudo skip '[=>]'
{
# 18:45 < autrijus> hm, I found a way to easily do linked list consing in Perl6
# 18:45 < autrijus> [=>] 1..10;
@@ -99,18 +106,30 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
is (try {$list.value.value}), 3, "[=>] works (3)";
}
+
+#?rakudo todo '[,]'
{
- my @array = <5 -3 7 0 1 -9>;
- is ([,] @array), @array, "[,] works (a noop)";
+ my @array = <5 -3 7 0 1 -9>;
+ # according to http://irclog.perlgeek.de/perl6/2008-09-10#i_560910
+ # [,] returns a scalar (holding an Array)
+ my $count = 0;
+ $count++ for [,] @array;
+ is $count, 1, '[,] returns a single Array';
+ isa_ok ([,] @array), '[,] returns something of type Array';
}
# Following two tests taken verbatim from former t/operators/reduce.t
+#?rakudo 2 skip '>>+<<'
lives_ok({my @foo = [1..3] >>+<< [1..3] >>+<< [1..3]},'Sanity Check');
lives_ok({my @foo = [>>+<<] ([1..3],[1..3],[1..3])},'Parse [>>+<<]');
# Check that user defined infix ops work with [...], too.
-sub infix:<more_than_plus>(Int $a, Int $b) { $a + $b + 1 }
-is( (try { [more_than_plus] 1, 2, 3 }), 8, "[...] reduce metaop works on user defined ops", :todo<bug>);
+#?pugs todo 'bug'
+#?rakudo skip 'custom operators'
+{
+ sub infix:<more_than_plus>(Int $a, Int $b) { $a + $b + 1 }
+ is( (try { [more_than_plus] 1, 2, 3 }), 8, "[...] reduce metaop works on user defined ops";
+}
# {
# my $arr = [ 42, [ 23 ] ];
@@ -128,10 +147,11 @@ is( (try { [more_than_plus] 1, 2, 3 }), 8, "[...] reduce metaop works on user de
# L<S03/"Reduction operators"/"Among the builtin operators, [+]() returns 0 and [*]() returns 1">
-is( [*](), 1, "[*]() returns 1");
-is( [+](), 0, "[+]() returns 0");
+is( ([*]()), 1, "[*]() returns 1");
+is( ([+]()), 0, "[+]() returns 0");
#?pugs todo '[=] meta ops'
+#?rakudo skip '[=] meta ops'
{
my ($a, $b);
Please sign in to comment.
Something went wrong with that request. Please try again.