Skip to content

Commit

Permalink
nom fudging
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Jul 28, 2011
1 parent f6e35cb commit c7c1e2f
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 4 deletions.
2 changes: 2 additions & 0 deletions S02-names/our.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ plan 10;
# RT #63882
{
enum A <a b c>;
#?rakudo todo 'nom regression'
is c, 2, 'c is 2 from enum';
eval 'sub c { "sub c" }';
ok $! !~~ Exception, 'can define sub c in eval after c defined in enum';
#?rakudo todo 'nom regression'
is c, 2, 'c is still 2 from enum';
#?rakudo skip 'OUR::subname() does not work'
is OUR::c(), 'sub c', 'sub c called with OUR:: works';
Expand Down
24 changes: 23 additions & 1 deletion S03-operators/autoincrement-range.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,63 +49,85 @@ my $x;
{
diag( "Tests for '\x[391]' .. '\x[3a9]' (Greek uppercase)" );
$x = "\x[3a9]\x[3a9]";
#?rakudo todo 'nom regression'
is( ++$x, "\x[391]\x[391]\x[391]",
"'\x[3a9]\x[3a9]'++ is '\x[391]\x[391]\x[391]'" );
$x = "\x[391]\x[391]\x[391]";
ok( --$x ~~ Failure, "'\x[391]\x[391]\x[391]'-- fails" );
$x = "A\x[391]";
#?rakudo todo 'nom regression'
is( ++$x, "A\x[392]", "'A\x[391]'++ is 'A\x[392]'" );
$x = "A\x[392]";
#?rakudo todo 'nom regression'
is( --$x, "A\x[391]", "'A\x[392]'-- is 'A\x[391]'" );
$x = "A\x[3a9]";
#?rakudo todo 'nom regression'
is( ++$x, "B\x[391]", "'A\x[3a9]'++ is 'B\x[391]'" );
$x = "B\x[391]";
#?rakudo todo 'nom regression'
is( --$x, "A\x[3a9]", "'B\x[391]'-- is 'A\x[3a9]'" );
$x = "\x[391]ZZ";
#?rakudo todo 'nom regression'
is( ++$x, "\x[392]AA", "'\x[391]ZZ'++ is '\x[392]AA'" );
$x = "\x[392]AA";
#?rakudo todo 'nom regression'
is( --$x, "\x[391]ZZ", "'\x[392]AA'-- is '\x[391]ZZ'" );
}
{
diag( "Tests for '\x[3b1]' .. '\x[3c9]' (Greek lowercase)" );
$x = "\x[3c9]\x[3c9]";
#?rakudo todo 'nom regression'
is( ++$x, "\x[3b1]\x[3b1]\x[3b1]",
"'\x[3c9]\x[3c9]'++ is '\x[3b1]\x[3b1]\x[3b1]'" );
$x = "\x[3b1]\x[3b1]\x[3b1]";
ok( --$x ~~ Failure, "'\x[3b1]\x[3b1]\x[3b1]'-- fails" );
$x = "A\x[3b1]";
#?rakudo todo 'nom regression'
is( ++$x, "A\x[3b2]", "'A\x[3b1]'++ is 'A\x[3b2]'" );
$x = "A\x[3b2]";
#?rakudo todo 'nom regression'
is( --$x, "A\x[3b1]", "'A\x[3b2]'-- is 'A\x[3b1]'" );
$x = "A\x[3c9]";
#?rakudo todo 'nom regression'
is( ++$x, "B\x[3b1]", "'A\x[3c9]'++ is 'B\x[3b1]'" );
$x = "B\x[3b1]";
#?rakudo todo 'nom regression'
is( --$x, "A\x[3c9]", "'B\x[3b1]'-- is 'A\x[3c9]'" );
$x = "\x[3b1]ZZ";
#?rakudo todo 'nom regression'
is( ++$x, "\x[3b2]AA", "'\x[3b1]ZZ'++ is '\x[3b2]AA'" );
$x = "\x[3b2]AA";
#?rakudo todo 'nom regression'
is( --$x, "\x[3b1]ZZ", "'\x[3b2]AA'-- is '\x[3b1]ZZ'" );
}
#?rakudo todo 'Hebrew'
{
diag( "Tests for '\x[5d0]' .. '\x[5ea]' (Hebrew)" );
$x = "\x[5ea]\x[5ea]";
#?rakudo todo 'Hebrew'
is( ++$x, "\x[5d0]\x[5d0]\x[5d0]", "'\x[5ea]\x[5ea]'++ is '\x[5d0]\x[5d0]\x[5d0]'" );
$x = "\x[5d0]\x[5d0]\x[5d0]";
#?rakudo skip 'Hebrew - false positive'
ok( --$x ~~ Failure, "'\x[5d0]\x[5d0]\x[5d0]'-- fails" );
$x = "A\x[5d0]";
#?rakudo todo 'Hebrew'
is( ++$x, "A\x[5d1]", "'A\x[5d0]'++ is 'A\x[5d1]'" );
$x = "A\x[5d1]";
#?rakudo todo 'Hebrew'
is( --$x, "A\x[5d0]", "'A\x[5d1]'-- is 'A\x[5d0]'" );
$x = "A\x[5ea]";
#?rakudo todo 'Hebrew'
is( ++$x, "B\x[5d0]", "'A\x[5ea]'++ is 'B\x[5d0]'" );
$x = "B\x[5d0]";
#?rakudo todo 'Hebrew'
is( --$x, "A\x[5ea]", "'B\x[5d0]'-- is 'A\x[5ea]'" );
$x = "\x[5d0]ZZ";
#?rakudo todo 'Hebrew'
is( ++$x, "\x[5d1]AA", "'\x[5d0]ZZ'++ is '\x[5d1]AA'" );
$x = "\x[5d1]AA";
#?rakudo todo 'Hebrew'
is( --$x, "\x[5d0]ZZ", "'\x[5d1]AA'-- is '\x[5d0]ZZ'" );
}

{
diag( "Tests for '0' .. '9'" );
$x = "99";
Expand Down
1 change: 1 addition & 0 deletions S03-operators/basic-types.t
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ my $int = 0;
isa_ok($int, Int, 'it is an Int type');

my $num = '';
#?rakudo todo 'nom regression'
ok(+$num ~~ Num, 'it is an Num type');

my $float = 0.5e0;
Expand Down
5 changes: 4 additions & 1 deletion S03-operators/boolean-bitwise.t
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ plan 43;
ok( ?(False?^False == False), '?^ works with Bools');
ok( ?(False?^True == True), '?^ works with Bools');
ok( ?(True ?^False == True), '?^ works with Bools');
#?rakudo skip 'segmentation fault'
ok( ?(True ?^True == False), '?^ works with Bools');

#?rakudo skip 'segmentation fault'
ok( ?('' ?^'' == False), '?^ works');
ok( ?(Any ?^ 1 == True), '?^ works');
ok( ?(-1 ?^ Any == True), '?^ works');
#?rakudo skip 'segmentation fault'
ok( ?(42 ?^ 42 == False), '?^ works');
#?rakudo skip 'segmentation fault'
ok( ?(42 ?^ 41 == False), '?^ works');

ok( ?(infix:<?^>(True) == True), '?^ works with one argument');
ok( ?(infix:<?^>() == False), '?^ works with no arguments');

#?rakudo skip 'segmentation fault'
isa_ok (42 ?^ 41), Bool, '?^ yields a Bool';
isa_ok infix:<?^>(True), Bool, '?^ with one argument yields a Bool';
isa_ok infix:<?^>(), Bool, '?^ with no arguments yields a Bool';
Expand Down
17 changes: 15 additions & 2 deletions S03-operators/short-circuit.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ it is closely related to || and && and //.

# test cases by Andrew Savige

plan 75;
plan 79;

my $accum = '';
sub f1($s) { $accum ~= $s; 1 }
Expand Down Expand Up @@ -158,12 +158,14 @@ sub accumtest($expect, $op) {

is(0 ^^ 42, 42, "^^ operator working (one true)");
is(42 ^^ 0, 42, "^^ operator working (one true)");
#?rakudo skip 'segmentation fault'
is(1 ^^ 42, False, "^^ operator working (both true)");
is(0 ^^ 0, 0, "^^ operator working (both false)");
is((0 xor 42), 42, "xor operator working (one true)");
is((42 xor 0), 42, "xor operator working (one true)");
is((0 xor 42), 42, "xor operator working (one true)");
is((42 xor 0), 42, "xor operator working (one true)");
#?rakudo skip 'segmentation fault'
ok(!(1 xor 42), "xor operator working (both true)");
ok(!(0 xor 0), "xor operator working (both false)");
}
Expand All @@ -174,17 +176,23 @@ sub accumtest($expect, $op) {
is 0 ^^ False ^^ '', '', '^^ given all false values returns last (1)';
is False ^^ '' ^^ 0, 0, '^^ given all false values returns last (2)';
is False ^^ 42 ^^ '', 42, '^^ given one true value returns it (1)';
#?rakudo skip 'segmentation fault'
is 0 ^^ Int ^^ 'plugh', 'plugh', '^^ given one true value returns it (2)';
#?rakudo skip 'segmentation fault'
is 15 ^^ 0 ^^ 'quux', False, '^^ given two true values returns False (1)';
#?rakudo skip 'segmentation fault'
is 'a' ^^ 'b' ^^ 0, False, '^^ given two true values returns False (2)';

is (0 xor False xor ''), '', 'xor given all false values returns last (1)';
is (False xor '' xor 0), 0, 'xor given all false values returns last (2)';
is (False xor 42 xor ''), 42, 'xor given one true value returns it (1)';
is (0 xor Int xor 'plugh'), 'plugh', 'xor given one true value returns it (2)';
#?rakudo skip 'segmentation fault'
is (15 xor 0 xor 'quux'), False, 'xor given two true values returns False (1)';
#?rakudo skip 'segmentation fault'
is ('a' xor 'b' xor 0), False, 'xor given two true values returns False (2)';

#?rakudo skip 'segmentation fault'
isa_ok 7 ^^ 7, Bool, '^^ can return a Bool';
isa_ok 7 ^^ Mu, Int, '^^ can return an Int';
isa_ok 0 ^^ ^7, Range, '^^ can return a Range';
Expand All @@ -199,9 +207,13 @@ sub accumtest($expect, $op) {

is (@a ^^ @c), '1 2 3', 'Array ^^ true returns true array';
is (@c ^^ @a), '1 2 3', 'Array ^^ true returns true array';
#?rakudo skip 'segmentation fault'
ok (@a ^^ @b) == (), 'Array ^^ true returns empty list';
#?rakudo skip 'segmentation fault'
ok (@c ^^ @d) == (), 'Array ^^ true returns empty list';
#?rakudo skip 'segmentation fault'
is (@a ^^ ()), '1 2 3', 'True array ^^ empty list returns array';
#?rakudo skip 'segmentation fault'
is (() ^^ @a), '1 2 3', 'Empty list ^^ true array returns array';
ok (() ^^ @c) == (), 'Empty list ^^ empty array returns ()';
}
Expand All @@ -224,7 +236,6 @@ sub accumtest($expect, $op) {
{
my $x = 0;
my $y = 0;
#?rakudo todo 'chained comparison order of evaluations'
ok(($x++ < ++$y < ++$y), "chained comparison (truth - 1)");
# expect x=1, y=2
is($y, 2, "chained comparison short-circuit: not re-evaluating middle");
Expand Down Expand Up @@ -271,12 +282,14 @@ ok (0 || 0 || 1), '0 || 0 || 1 is true';
my $b = 0;
$a //= ($b = 1);
is $a, 0, 'basic //=';
#?rakudo todo 'nom regression'
is $b, 0, '//= short-circuits';

$a = 1;
$b = 0;
$a ||= ($b = 2);
is $a, 1, 'basic ||=';
#?rakudo todo 'nom regression'
is $b, 0, '||= short-circuits';

}
Expand Down
3 changes: 3 additions & 0 deletions S03-smartmatch/any-array-slice.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ use Test;

#L<S03/Smart matching/array value slice truth>
{
#?rakudo todo 'nom regression'
ok ((Mu, 1, Mu) ~~ .[1]),
"element 1 of (Mu, 1, Mu) is true";
#?rakudo todo 'nom regression'
ok !((Mu, Mu) ~~ .[0]),
"element 0 of (Mu, Mu) is false";
#?rakudo todo 'nom regression'
ok ((0, 1, 2, 3) ~~ .[1, 2, 3]),
"array slice .[1,2,3] of (0,1,2,3) is true";
ok !((0, 1, 2, 3) ~~ .[0]),
Expand Down
5 changes: 5 additions & 0 deletions S03-smartmatch/any-hash-slice.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ use Test;
sub notautoquoted_a { 'a' };
sub notautoquoted_c { 'c' };

#?rakudo todo 'nom regression'
ok (%h ~~ .{'c'}), '%hash ~~ .{true"}';
ok !(%h ~~ .{'b'}), '%hash ~~ .{false"}';
#?rakudo todo 'nom regression'
ok (%h ~~ .{<c d>}), '%hash ~~ .{<true values>}';
ok !(%h ~~ .{<c d a>}), '%hash ~~ .{<not all true>}';
ok !(%h ~~ .{notautoquoted_a}), '~~. {notautoquoted_a}';
#?rakudo todo 'nom regression'
ok (%h ~~ .{notautoquoted_c}), '~~. {notautoquoted_c}';
#?rakudo todo 'nom regression'
ok (%h ~~ .<c>), '%hash ~~ .<true"}';
ok !(%h ~~ .<b>), '%hash ~~ .<false"}';
#?rakudo todo 'nom regression'
ok (%h ~~ .<c d>), '%hash ~~ .<true values>';
ok !(%h ~~ .<c d a>), '%hash ~~ .<not all true>';
ok !(%h ~~ .<c d f>), '%hash ~~ .<not all exist>';
Expand Down
18 changes: 18 additions & 0 deletions S03-smartmatch/array-array.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,37 @@ plan 36;
ok(!([1] ~~ []), "array smartmatch boundary conditions");
ok(([] ~~ []), "array smartmatch boundary conditions");
ok(([1] ~~ [1]), "array smartmatch boundary conditions");
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,*), 'array smartmatch dwims * at end');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,*,*), 'array smartmatch dwims * at end (many *s)');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (*,4), 'array smartmatch dwims * at start');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (*,*,4), 'array smartmatch dwims * at start (many *s)');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,*,3,4), 'array smartmatch dwims * 1 elem');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,*,*,3,4), 'array smartmatch dwims * 1 elem (many *s)');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,*,4), 'array smartmatch dwims * many elems');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,*,*,4), 'array smartmatch dwims * many elems (many *s)');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (*,3,*), 'array smartmatch dwims * at start and end');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (*,*,3,*,*), 'array smartmatch dwims * at start and end (many *s)');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (*,1,2,3,4), 'array smartmatch dwims * can match nothing at start');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (*,*,1,2,3,4), 'array smartmatch dwims * can match nothing at start (many *s)');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,2,*,3,4), 'array smartmatch dwims * can match nothing in middle');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,2,*,*,3,4), 'array smartmatch dwims * can match nothing in middle (many *s)');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,2,3,4,*), 'array smartmatch dwims * can match nothing at end');
#?rakudo todo 'nom regression'
ok((1,2,3,4) ~~ (1,2,3,4,*,*), 'array smartmatch dwims * can match nothing at end (many *s)');
ok(!((1,2,3,4) ~~ (1,*,3)), '* dwimming does not cause craziness');
ok(!((1,2,3,4) ~~ (*,5)), '* dwimming does not cause craziness');
Expand All @@ -40,9 +56,11 @@ plan 36;
ok (@a ~~ @a), 'Basic smartmatching on arrays (positive)';
ok (@a !~~ @b), 'Basic smartmatching on arrays (negative)';
ok (@b !~~ @a), 'Basic smartmatching on arrays (negative)';
#?rakudo todo 'nom regression'
ok (@a ~~ @m), 'Whatever dwimminess in arrays';
ok (@a ~~ (1, 2, 3)), 'smartmatch Array ~~ List';
ok ((1, 2, 3) ~~ @a), 'smartmatch List ~~ Array';
#?rakudo todo 'nom regression'
ok ((1, 2, 3) ~~ @m), 'smartmatch List ~~ Array with dwim';

ok (1 ~~ *,1,*), 'smartmatch with Array RHS co-erces LHS to list';
Expand Down

0 comments on commit c7c1e2f

Please sign in to comment.