Changeset 22515 for t

Show
Ignore:
Timestamp:
10/05/08 19:58:12 (7 weeks ago)
Author:
moritz
Message:

[t/spec] some test enhancements, corrections and fudging for rakudo.

Location:
t/spec
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • t/spec/S02-literals/pairs.t

    r22290 r22515  
    1818#   foo($pair);      # pair passed positionally 
    1919#   foo([,] $pair);     # named 
     20# 
     21#   S02 lists ':a' as being equivlaent to a => 1, so 
     22#   the type of the value of that pair is Int, not Bool 
    2023 
    2124plan 40; 
     
    2629    is f1(a     => 42, 23), "IntInt", "'a => 42' is a named"; 
    2730    is f1(:a(42),  23),     "IntInt", "':a(42)' is a named"; 
    28     is f1(:a,      23),     "BoolInt",  "':a' is a named"; 
    29     is f1(:!a,     23),     "BoolInt",  "':!a' is also named"; 
     31    is f1(:a,      23),     "IntInt",  "':a' is a named"; 
     32    is f1(:!a,     23),     "IntInt",  "':!a' is also named"; 
    3033 
    3134    is f1("a"   => 42, 23), "PairInt", "'\"a\" => 42' is a named"; 
     
    4447    is f2(a     => 42), "Int", "'a => 42' is a named"; 
    4548    is f2(:a(42)),      "Int", "':a(42)' is a named"; 
    46     #?rakudo todo 'Adverbial pairs without should produce a Bool (not Int)' 
    47     is f2(:a),          "Bool", "':a' is a named"; 
     49    is f2(:a),          "Int", "':a' is a named"; 
    4850     
    49     #?rakudo todo '.() sub calls' 
    50     is(f2.(:a),         "Bool",  "in 'f2.(:a)', ':a' is a named"); 
    51     #?rakudo todo 'Adverbial pairs without should produce a Bool (not Int)' 
    52     is $f2(:a),         "Bool",  "in '\$f2(:a)', ':a' is a named"; 
    53     #?rakudo skip '.() sub calls' 
    54     is $f2.(:a),        "Bool",  "in '\$f2.(:a)', ':a' is a named"; 
     51    is(f2.(:a),         "Int",  "in 'f2.(:a)', ':a' is a named"); 
     52    is $f2(:a),         "Int",  "in '\$f2(:a)', ':a' is a named"; 
     53    is $f2.(:a),        "Int",  "in '\$f2.(:a)', ':a' is a named"; 
    5554 
    56     #?rakudo 6 todo 'unknown' 
     55    #?rakudo 7 todo 'not every pair acts as named parameters' 
    5756    dies_ok { f2("a"   => 42) }, "'\"a\" => 42' is a pair"; 
    5857    dies_ok { f2(("a") => 42) }, "'(\"a\") => 42' is a pair"; 
     
    6160    dies_ok { f2((:a(42)))    }, "'(:a(42))' is a pair"; 
    6261    dies_ok { f2((:a))        }, "'(:a)' is a pair"; 
    63     #?rakudo todo '.() sub calls' 
    6462    dies_ok { f2.((:a))       }, "in 'f2.((:a))', '(:a)' is a pair"; 
    6563     
    66     #?rakudo todo 'unknown' 
     64    #?rakudo 4 todo 'not every pair acts as named parameters' 
    6765    dies_ok { $f2((:a))       }, "in '\$f2((:a))', '(:a)' is a pair"; 
    68     #?rakudo skip '.() sub calls' 
    6966    dies_ok { $f2.((:a))      }, "in '\$f2.((:a))', '(:a)' is a pair"; 
    70     #?rakudo todo 'unknown' 
    7167    dies_ok { $f2(((:a)))     }, "in '\$f2(((:a)))', '(:a)' is a pair"; 
    72     #?rakudo skip '.() sub calls' 
    7368    dies_ok { $f2.(((:a)))    }, "in '\$f2.(((:a)))', '(:a)' is a pair"; 
    7469} 
     
    7974 
    8075    is f3($pair),  "Pair", 'a $pair is not treated magically...'; 
     76    # XXX investigate what [,] actually does, it has changed recently 
    8177    #?pugs todo '[,]' 
    8278    #?rakudo skip 'reduce meta op' 
  • t/spec/S02-magicals/dollar_bang.t

    r22426 r22515  
    33use Test; 
    44 
    5 plan 8; 
     5plan 10; 
    66 
    77=begin desc 
     
    1313# L<S04/"Exceptions"/"A bare die/fail takes $! as the default argument."> 
    1414 
    15 #?rakudo 3 skip 'unimpl $!' 
     15##?rakudo 3 skip 'unimpl $!' 
    1616 
    17 eval '&nonexisting_subroutine()';  
     17eval 'nonexisting_subroutine()';  
     18ok defined($!), 'nonexisting sub in eval makes $! defined'; 
     19eval 'nonexisting_subroutine()';  
     20#?rakudo skip 'Test $! for truthness' 
    1821ok $!, 'Calling a nonexisting subroutine sets $!'; 
    1922 
    2023undefine $!; 
     24# XXX nonexisting_subroutine is detectable at compile time, 
     25# this test should be fixed somehow 
    2126try { nonexisting_subroutine; }; 
     27ok $! !~~ undef, 'Calling a nonexisting subroutine defines $!'; 
     28try { nonexisting_subroutine; }; 
     29#?rakudo skip 'Test $! for truthness' 
    2230ok $!, 'Calling a nonexisting subroutine sets $!'; 
    2331 
     
    2735my @a; 
    2836try { foo(@a,@a) }; 
     37#?rakudo skip 'Test $! for truthness' 
    2938ok $!, 'Calling a subroutine with a nonmatching signature sets $!'; 
    3039ok !$called, 'The subroutine also was not called'; 
     
    3847undefine $!; 
    3948try { incr(19) }; 
     49#?rakudo todo 'containers/values' 
    4050ok $!, 'Modifying a constant sets $!'; 
    4151 
     
    4757    die; # use the default argument 
    4858} 
     59#?rakudo todo 'stringification of $!' 
    4960ok ~($!) ~~ /qwerty/, 'die without argument uses $! properly'; 
     61 
     62# vim: ft=perl6 
  • t/spec/S02-names_and_variables/varnames.t

    r22393 r22515  
    1313 
    1414# things that should be invalid 
    15 #?rakudo skip 'Null PMC access in type()' 
    1615eval_dies_ok 'my $f!ao = "beh";', "but normal varnames can't have ! in their name"; 
    17 #?rakudo skip 'Null PMC access in type()' 
    1816eval_dies_ok 'my $fo:o::b:ar = "bla"', "var names can't have colons in their names either"; 
    1917 
  • t/spec/S02-whitespace_and_comments/unspace.t

    r22161 r22515  
    77# L<S02/"Whitespace and Comments"/This is known as the "unspace"> 
    88 
    9 is(4\       .sqrt, 2, 'unspace with numbers'); 
     9 
     10#?rakudo skip "get_string() not implemented in class 'ResizableStringArray'" 
     11ok(4\       .sqrt == 2, 'unspace with numbers'); 
     12#?rakudo skip 'unspace with comments' 
    1013is(4\#(quux).sqrt, 2, 'unspace with comments'); 
    11 is("x"\     .bytes, 1, 'unspace with strings'); 
    12 is("x"\     .bytes(), 1, 'unspace with strings + parens'); 
    13  
     14is("x"\     .codes, 1, 'unspace with strings'); 
     15is("x"\     .codes(), 1, 'unspace with strings + parens'); 
     16 
     17#?rakudo skip 'lexicals in eval' 
     18{ 
    1419my $foo = 4; 
    1520is(eval('$foo.++'), 4, '(short) unspace with postfix inc'); 
     
    1924is(eval('$foo\       .--'), 6, 'unspace with postfix dec'); 
    2025is($foo, 5, 'unspace with postfix dec really postfix'); 
     26} 
    2127 
    2228is("xxxxxx"\.bytes, 6, 'unspace without spaces'); 
     
    5864 
    5965#XXX why is eval required here? 
     66{ 
    6067is(eval('foo.id'), 'a', 'sanity - foo.id'); 
    6168is(eval('foo .id'), 'b', 'sanity - foo .id'); 
     
    166173    .id'), 'a', 'hideous nested pod torture test'); 
    167174 
     175} 
    168176# L<S04/"Statement-ending blocks"/"Because subroutine declarations are expressions"> 
    169177#XXX probably shouldn't be in this file... 
    170178 
     179{ 
    171180eval('sub f { 3 } sub g { 3 }'); 
    172181eval_dies_ok('f', 'semicolon or newline required between blocks'); 
    173182eval_dies_ok('g', 'semicolon or newline required between blocks'); 
     183} 
    174184 
    175185# L<S06/"Blocks"/"unless followed immediately by a comma"> 
    176  
     186# 
     187{ 
    177188sub baz(Code $x, *@y) { $x.(@y) } 
    178189 
     
    188199is(eval('xyzzy { @^x } : 1, 2, 3'), (1, 2, 3), 'colon not immediately following arg block'); 
    189200is(eval('xyzzy { @^x }\ : 1, 2, 3'), (1, 2, 3), 'unspace then colon following arg block'); 
     201} 
    190202 
    191203# L<S02/"Whitespace and Comments"/"natural conflict between postfix operators and infix operators"> 
     
    195207# ($n) (++$m) 
    196208# ($n) + (+$m) 
    197  
    198 my $n = 1; 
    199 my $m = 2; 
    200 sub infix:<++>($x, $y) { 42 } 
    201  
    202 #'$n++$m' should be a syntax error 
    203 eval_dies_ok('$n++$m', 'infix requires space when ambiguous with postfix'); 
    204 is($n, 1, 'check $n'); 
    205 is($m, 2, 'check $m'); 
    206  
    207 #'$n ++$m' should be infix:<++> 
    208 #no, really: http://moritz.faui2k3.org/irclog/out.pl?channel=perl6;date=2007-05-09#id_l328 
    209 $n = 1; $m = 2; 
    210 is(eval('$n ++$m'), 42, '$n ++$m with infix:<++> is $n ++ $m'); 
    211 is($n, 1, 'check $n'); 
    212 is($m, 2, 'check $m'); 
    213  
    214 #'$n ++ $m' should be infix:<++> 
    215 $n = 1; $m = 2; 
    216 is(eval('$n ++ $m'), 42, 'postfix requires no space w/ infix ambiguity'); 
    217 is($n, 1, 'check $n'); 
    218 is($m, 2, 'check $m'); 
    219  
    220 #These should all be postfix syntax errors 
    221 $n = 1; $m = 2; 
    222 eval_dies_ok('$n.++ $m',   'postfix dot w/ infix ambiguity'); 
    223 eval_dies_ok('$n\ ++ $m',  'postfix unspace w/ infix ambiguity'); 
    224 eval_dies_ok('$n\ .++ $m', 'postfix unspace w/ infix ambiguity'); 
    225 is($n, 1, 'check $n'); 
    226 is($m, 2, 'check $m'); 
    227  
    228 #Unspace inside operator splits it 
    229 $n = 1; $m = 2; 
    230 is(eval('$n+\ +$m'), 3, 'unspace inside operator splits it'); 
    231 is($n, 1, 'check $n'); 
    232 is($m, 2, 'check $m'); 
    233  
    234 $n = 1; 
    235 eval_dies_ok('$n ++', 'postfix requires no space'); 
    236 is($n, 1, 'check $n'); 
    237  
    238 $n = 1; 
    239 is(eval('$n.++'), 1, 'postfix dot'); 
    240 is($n, 2, 'check $n'); 
    241  
    242 $n = 1; 
    243 is(eval('$n\ ++'), 1, 'postfix unspace'); 
    244 is($n, 2, 'check $n'); 
    245  
    246 $n = 1; 
    247 is(eval('$n\ .++'), 1, 'postfix unspace'); 
    248 is($n, 2, 'check $n'); 
    249  
    250 # L<S02/"Lexical Conventions"/"U+301D codepoint has two closing alternatives"> 
    251 is(eval('foo\#〝 comment 〞.id'), 'a', 'unspace with U+301D/U+301E comment'); 
    252 eval_dies_ok('foo\#〝 comment 〟.id', 'unspace with U+301D/U+301F is invalid'); 
    253  
    254 # L<S02/"Whitespace and Comments"/".123"> 
    255 # .123 is equal to 0.123 
    256  
    257 is eval(' .123'), 0.123, ' .123 is equal to 0.123'; 
    258 is eval('.123'), 0.123, '.123 is equal to 0.123'; 
    259  
     209#?rakudo skip 'defining new operators' 
     210{ 
     211    my $n = 1; 
     212    my $m = 2; 
     213    sub infix:<++>($x, $y) { 42 } 
     214 
     215    #'$n++$m' should be a syntax error 
     216    #?rakudo 3 skip 'test dependency' 
     217    eval_dies_ok('$n++$m', 'infix requires space when ambiguous with postfix'); 
     218    is($n, 1, 'check $n'); 
     219    is($m, 2, 'check $m'); 
     220 
     221    #'$n ++$m' should be infix:<++> 
     222    #no, really: http://irclog.perlgeek.de/perl6/2007-05-09#id_l328 
     223    $n = 1; $m = 2; 
     224    is(eval('$n ++$m'), 42, '$n ++$m with infix:<++> is $n ++ $m'); 
     225    is($n, 1, 'check $n'); 
     226    is($m, 2, 'check $m'); 
     227 
     228    #'$n ++ $m' should be infix:<++> 
     229    $n = 1; $m = 2; 
     230    is(eval('$n ++ $m'), 42, 'postfix requires no space w/ infix ambiguity'); 
     231    is($n, 1, 'check $n'); 
     232    is($m, 2, 'check $m'); 
     233 
     234    #These should all be postfix syntax errors 
     235    $n = 1; $m = 2; 
     236    eval_dies_ok('$n.++ $m',   'postfix dot w/ infix ambiguity'); 
     237    eval_dies_ok('$n\ ++ $m',  'postfix unspace w/ infix ambiguity'); 
     238    eval_dies_ok('$n\ .++ $m', 'postfix unspace w/ infix ambiguity'); 
     239    is($n, 1, 'check $n'); 
     240    is($m, 2, 'check $m'); 
     241 
     242    #Unspace inside operator splits it 
     243    $n = 1; $m = 2; 
     244    is(eval('$n+\ +$m'), 3, 'unspace inside operator splits it'); 
     245    is($n, 1, 'check $n'); 
     246    is($m, 2, 'check $m'); 
     247 
     248    $n = 1; 
     249    eval_dies_ok('$n ++', 'postfix requires no space'); 
     250    is($n, 1, 'check $n'); 
     251 
     252    $n = 1; 
     253    is(eval('$n.++'), 1, 'postfix dot'); 
     254    is($n, 2, 'check $n'); 
     255 
     256    $n = 1; 
     257    is(eval('$n\ ++'), 1, 'postfix unspace'); 
     258    is($n, 2, 'check $n'); 
     259 
     260    $n = 1; 
     261    is(eval('$n\ .++'), 1, 'postfix unspace'); 
     262    is($n, 2, 'check $n'); 
     263 
     264    # L<S02/"Lexical Conventions"/"U+301D codepoint has two closing alternatives"> 
     265    is(eval('foo\#〝 comment 〞.id'), 'a', 'unspace with U+301D/U+301E comment'); 
     266    eval_dies_ok('foo\#〝 comment 〟.id', 'unspace with U+301D/U+301F is invalid'); 
     267 
     268    # L<S02/"Whitespace and Comments"/".123"> 
     269    # .123 is equal to 0.123 
     270 
     271    is eval(' .123'), 0.123, ' .123 is equal to 0.123'; 
     272    is eval('.123'), 0.123, '.123 is equal to 0.123'; 
     273} 
     274 
  • t/spec/S12-enums/basic.t

    r21144 r22515  
    1313} 
    1414 
     15#?rakudo skip 'infix:<but>' 
    1516{ 
    1617    my $x = 'Today' but Day::Mon; 
  • t/spec/S12-methods/what.t

    r21472 r22515  
    2525{ 
    2626  my $a = 3; 
     27  #?rakudo todo 'Int type should somehow conform to Num' 
    2728  ok($a.WHAT ~~ Num,    "an Int isa Num"); 
    2829  ok($a.WHAT ~~ Object, "an Int isa Object"); 
     
    3233{ 
    3334  my $a = sub ($x) { 100 + $x }; 
     35  #?rakudo 2 todo 'correct types for subs and blocks' 
    3436  ok($a.WHAT === Sub,    "a sub's type is Sub"); 
    3537  ok($a.WHAT ~~ Routine, "a sub isa Routine"); 
     
    4547    my $o = Foo.new; 
    4648    is($o."WHAT", 'Bar', '."WHAT" calls the method instead of the macro'); 
     49    #?rakudo todo '.WHAT not (easily overridable)' 
    4750    is($o.WHAT,   'Foo', '.WHAT still works as intended'); 
    4851    my $meth = "WHAT"; 
     52    #?rakudo skip 'indirect method calls' 
    4953    is($o.$meth,  'Bar', '.$meth calls the method instead of the macro'); 
    5054} 
  • t/spec/S29-context/eval.t

    r22471 r22515  
    1111=end pod 
    1212 
    13 #?rakudo skip "Null PMC access in find_method()" 
    14  
    15 #?rakudo emit =begin unimpl 
    16  
    1713# eval should evaluate the code in the lexical scope of eval's caller 
    18 sub make_eval_closure { my $a = 5; sub ($s) { eval $s } }; 
    19 is(make_eval_closure()('$a'), 5, 'eval runs code in the proper lexical scope'); 
    20  
    21 #?rakudo emit =end unimpl 
     14#?rakudo skip 'eval as closure' 
     15{ 
     16    sub make_eval_closure { 
     17        my $a = 5; 
     18        return sub ($s) { 
     19            eval $s  
     20        }; 
     21    }; 
     22    is(make_eval_closure().('$a'), 5, 'eval runs code in the proper lexical scope'); 
     23} 
    2224 
    2325is(eval('5'), 5, 'simple eval works and returns the value'); 
    2426my $foo = 1234; 
    25 #?rakudo skip "unimpl Null PMC access in find_method" 
     27#?rakudo skip 'eval needs access to outer scope' 
    2628is(eval('$foo'), $foo, 'simple eval using variable defined outside'); 
    2729 
    2830# traps die? 
    29 #?rakudo skip "unimpl Null PMC access in type()" 
     31#?rakudo skip 'Null PMC access in type()' 
    3032ok(!eval('die; 1'), "eval can trap die"); 
    3133 
    32 ok(!eval('my @a = (1); @a<0>'), "eval returns undef on syntax error"); 
     34ok(eval('my @a = (1); @a!<0>') ~~ undef, "eval returns undef on syntax error"); 
    3335 
    34 #?rakudo skip "unimpl Null PMC access in type()" 
     36#?rakudo skip 'eval should trap fatal use statement' 
    3537ok(!eval('use Poison; 1'), "eval can trap a fatal use statement"); 
    3638 
     
    3840ok(v() == 123, "a plain subroutine"); 
    3941eval 'sub v { 456 }'; 
     42#?rakudo todo 'eval can override subroutines (specced?)' 
    4043ok(v() == 456, "eval can overwrite a subroutine"); 
    4144 
    4245# L<S04/Exception handlers/Perl 6's eval function only evaluates strings, not blocks.> 
    43 #?rakudo skip "unimpl Null PMC access in find_method" 
     46#?rakudo skip 'eval { block } is gone ' 
    4447dies_ok({eval {42}}, 'block eval is gone'); 
  • t/spec/S29-str/split-simple.t

    r22315 r22515  
    22use Test; 
    33 
    4 plan 30; 
     4plan 32; 
    55 
    66=begin description 
     
    5151); 
    5252 
     53# zero-width assertions shouldn't loop 
     54# with additional spaces 
     55# a b 3 4 d 5 z    split on <before \d> 
     56#    ^ ^   ^    
     57#  => result: 'ab', '3', '4d', '5z' 
     58#  (confirmed by perl 5) 
     59 
     60#?rakudo skip 'split with zero-width assertions' 
     61#?DOES 2 
     62{ 
     63split_test 'ab34d5z'.split(/<before \d>/), <ab 3 4d 5z>, 'split with zero-width assertions'; 
     64} 
     65 
    5366# As per Larry, ''.split('') is the empty list 
    5467# http://www.nntp.perl.org/group/perl.perl6.language/2008/09/msg29730.html