Skip to content

Commit

Permalink
pugs fudge
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Feb 25, 2012
1 parent 117ffc1 commit 7f7b55a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
35 changes: 34 additions & 1 deletion S03-operators/range.t
Expand Up @@ -18,6 +18,7 @@ is ~("a".."a"), "a", "(..) works on chars (2)";
is ~("b".."a"), "", "(..) works on chars (3)";
is ~("a".."z"), "a b c d e f g h i j k l m n o p q r s t u v w x y z", "(..) works on char range ending in z";
is ~("A".."Z"), "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", "(..) works on char range ending in Z";
#?pugs todo
is ~("Y".."AB"), "", "(..) works on carried chars (3)";

#?rakudo 4 skip 'Spec under design here'
Expand All @@ -37,11 +38,13 @@ is ~(2+5..6), "", "(..) has correct precedence (4)";
# L<S03/Range and RangeIter semantics/range operator has variants>
is [1^..9], [2..9], "bottom-exclusive range (^..) works (1)";
is [2^..2], [], "bottom-exclusive range (^..) works (2)";
#?pugs skip 'empty list'
is [3^..2], [], "bottom-exclusive auto-rev range (^..) works (3)";
is [1 ..^9], [1..8], "top-exclusive range (..^) works (1)";
is [2 ..^2], [], "top-exclusive range (..^) works (2)";
is [3 ..^2], [], "top-exclusive auto-rev range (..^) works (3)";
is [1^..^9], [2..8], "double-exclusive range (^..^) works (1)";
#?pugs skip 'empty list'
is [9^..^1], [], "double-exclusive auto-rev range (^..^) works (2)";
is [1^..^2], [], "double-exclusive range (^..^) can produce null range (1)";

Expand All @@ -51,12 +54,15 @@ is [1^..^2], [], "double-exclusive range (^..^) can produce null range (1)";
is [1^..^1], [], "double-exclusive range (x ^..^ x) where x is an int";

is ["a"^.."z"], ["b".."z"], "bottom-exclusive string range (^..) works";
#?pugs skip 'empty list'
is ["z"^.."a"], [], "bottom-exclusive string auto-rev range (^..) works";
is ["a"..^"z"], ["a".."y"], "top-exclusive string range (..^) works";
is ["z"..^"a"], [], "top-exclusive string auto-rev range (..^) works";
is ["a"^..^"z"], ["b".."y"], "double-exclusive string range (^..^) works";
#?pugs skip 'empty list'
is ["z"^..^"a"], [], "double-exclusive string auto-rev range (^..^) works";
is ['a'^..^'b'], [], "double-exclusive string range (^..^) can produce null range";
#?pugs skip 'empty list'
is ['b'^..^'a'], [], "double-exclusive string auto-rev range (^..^) can produce null range";
is ['a' ^..^ 'a'], [], "double-exclusive range (x ^..^ x) where x is a char";
is ('a'..'z').list.join(' '), 'a b c d e f g h i j k l m n o p q r s t u v w x y z', '"a".."z"';
Expand All @@ -76,6 +82,7 @@ is ~(^"5"), "0 1 2 3 4", 'unary ^"num" produces the range 0..^num';

{
my @a = 3, 5, 3;
#?pugs todo
is (^@a).perl, (0..^3).perl, 'unary ^@a produces 0..^+@a';
}

Expand All @@ -84,6 +91,7 @@ is (1..*).[^5].join('|'), '1|2|3|4|5', '1..*';
is ('a'..*).[^5].join('|'), 'a|b|c|d|e', '"a"..*';

# test that the zip operator works with ranges
#?pugs 4 todo
is (1..5 Z <a b c>).join('|'), '1|a|2|b|3|c', 'Ranges and infix:<Z>';
is (1..2 Z <a b c>).join('|'), '1|a|2|b', 'Ranges and infix:<Z>';
is (<c b a> Z 1..5).join('|'), 'c|1|b|2|a|3', 'Ranges and infix:<Z>';
Expand Down Expand Up @@ -136,6 +144,7 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';
#?rakudo 2 skip "nom regression: Method 'succ' not found for invocant of class 'Array'"
is ~(@one .. 3) , "1 2 3", "lower inclusive limit is in scalar context";
is ~(@one ^.. 3) , "2 3" , "lower exclusive limit is in scalar context";
#?pugs skip 'empty list'
is ~(3 ^.. @one) , "" , "lower exclusive limit is in scalar context";
is ~(1 .. @three) , "1 2 3", "upper inclusive limit is in scalar context";
is ~(4 .. @three) , "" , "upper inclusive limit is in scalar context";
Expand All @@ -158,11 +167,16 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';
my $end = "102.B";
lives_ok { $range = $start..$end },
'can make range from numeric string vars';
#?pugs todo
is $range.min, $start, 'range starts at start';
#?pugs skip ".gist"
is $range.min.WHAT.gist, "Str()", 'range start is a string';
#?pugs todo
is $range.max, $end, 'range ends at end';
#?pugs skip ".gist"
is $range.max.WHAT.gist, "Str()", 'range end is a string';
lives_ok { "$range" }, 'can stringify range';
#?pugs todo
is ~$range, "100.B 101.B 102.B", 'range is correct';
}

Expand All @@ -171,40 +185,54 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';
my $range;
lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = $0..$1 },
'can make range from match vars';
#?pugs todo
is $range.min, 1, 'range starts at one';
#?pugs todo
is $range.max, 3, 'range ends at three';
#?rakudo 2 skip "range stringification: Method 'succ' not found for invocant of class 'Match'"
#?niecza 2 skip 'cannot increment a value of type Match'
lives_ok { "$range" }, 'can stringify range';
#?pugs todo
is ~$range, "1 2 3", 'range is correct';
}
# and another set, just for the lulz
# RT #67882
#?pugs skip 'Range'
{
ok '1 3' ~~ /(\d) . (\d)/, 'regex sanity';
isa_ok $0..$1, Range, '$0..$1 constructs a Range';
#?rakudo skip "range with match object endpoints: Method 'succ' not found for invocant of class 'Match'"
#?niecza skip 'cannot increment a value of type Match'
is ($0..$1).join('|'), '1|2|3', 'range from $0..$1';
}

{
my $range;
lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = +$0..+$1 },
'can make range from match vars with numeric context forced';
#?pugs todo
is $range.min, 1, 'range starts at one';
#?pugs todo
is $range.max, 3, 'range ends at three';
lives_ok { "$range" }, 'can stringify range';
#?pugs todo
is ~$range, "1 2 3", 'range is correct';
}

{
my $range;
lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = ~$0..~$1 },
'can make range from match vars with string context forced';
#?pugs todo
is $range.min, 1, 'range starts at one';
#?pugs skip 'gist'
is $range.min.WHAT.gist, "Str()", 'range start is a string';
#?pugs todo
is $range.max, 3, 'range ends at three';
#?pugs skip 'gist'
is $range.max.WHAT.gist, "Str()", 'range end is a string';
lives_ok { "$range" }, 'can stringify range';
#?pugs todo
is ~$range, "1 2 3", 'range is correct';
}

Expand All @@ -213,24 +241,29 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';

#?rakudo todo 'forbid Ranges and Lists as Range endpoints'
#?niecza todo
#?pugs todo
{
ok !defined(try { 0 .. ^10 }), '0 .. ^10 is illegal';
ok !defined(try { 0 .. (0, 1, 2) }), '0 .. List is illegal';
}

# RT #68788
#?pugs skip 'Missing required parameters: $_'
#?DOES 2
{
$_ = Any; # unsetting $_ to reproduce bug literally
lives_ok {(1..$_)}, '(1..$_) lives';
isa_ok (1..$_), Range, '(..) works on Int .. Any';
}

#?pugs skip 'Numeric'
{
my $range = 1 .. '10';
is +$range, 10, "1 .. '10' has ten elements in it";
is +$range.grep(Numeric), 10, "and they are all numbers";
}

#?pugs skip 'Numeric'
{
my @array = 1 .. 10;
my $range = 1 .. @array;
Expand Down Expand Up @@ -258,4 +291,4 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';
}
}

# # vim: ft=perl6
# vim: ft=perl6
3 changes: 2 additions & 1 deletion S12-methods/submethods.t
Expand Up @@ -83,6 +83,8 @@ Basic submethod tests. See L<S12/"Submethods">
}

#?rakudo skip 'roles and submethods'
#?pugs skip 'does'
#?DOES 4
{
my $was_in_b1_build = 0;
my $was_in_b2_build = 0;
Expand All @@ -95,7 +97,6 @@ Basic submethod tests. See L<S12/"Submethods">
is $was_in_b2_build, 0, "roles' BUILD submethods were not yet called (2)";

$B does (RoleB1, RoleB2);
#?pugs 2 todo 'feature'
#?niecza 2 todo
is $was_in_b1_build, 1, "roles' BUILD submethods were called now (1)";
is $was_in_b2_build, 1, "roles' BUILD submethods were called now (2)";
Expand Down

0 comments on commit 7f7b55a

Please sign in to comment.