- Timestamp:
- 10/05/08 19:58:12 (7 weeks ago)
- Location:
- t/spec
- Files:
-
- 8 modified
-
S02-literals/pairs.t (modified) (5 diffs)
-
S02-magicals/dollar_bang.t (modified) (5 diffs)
-
S02-names_and_variables/varnames.t (modified) (1 diff)
-
S02-whitespace_and_comments/unspace.t (modified) (6 diffs)
-
S12-enums/basic.t (modified) (1 diff)
-
S12-methods/what.t (modified) (3 diffs)
-
S29-context/eval.t (modified) (2 diffs)
-
S29-str/split-simple.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
t/spec/S02-literals/pairs.t
r22290 r22515 18 18 # foo($pair); # pair passed positionally 19 19 # 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 20 23 21 24 plan 40; … … 26 29 is f1(a => 42, 23), "IntInt", "'a => 42' is a named"; 27 30 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"; 30 33 31 34 is f1("a" => 42, 23), "PairInt", "'\"a\" => 42' is a named"; … … 44 47 is f2(a => 42), "Int", "'a => 42' is a named"; 45 48 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"; 48 50 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"; 55 54 56 #?rakudo 6 todo 'unknown'55 #?rakudo 7 todo 'not every pair acts as named parameters' 57 56 dies_ok { f2("a" => 42) }, "'\"a\" => 42' is a pair"; 58 57 dies_ok { f2(("a") => 42) }, "'(\"a\") => 42' is a pair"; … … 61 60 dies_ok { f2((:a(42))) }, "'(:a(42))' is a pair"; 62 61 dies_ok { f2((:a)) }, "'(:a)' is a pair"; 63 #?rakudo todo '.() sub calls'64 62 dies_ok { f2.((:a)) }, "in 'f2.((:a))', '(:a)' is a pair"; 65 63 66 #?rakudo todo 'unknown'64 #?rakudo 4 todo 'not every pair acts as named parameters' 67 65 dies_ok { $f2((:a)) }, "in '\$f2((:a))', '(:a)' is a pair"; 68 #?rakudo skip '.() sub calls'69 66 dies_ok { $f2.((:a)) }, "in '\$f2.((:a))', '(:a)' is a pair"; 70 #?rakudo todo 'unknown'71 67 dies_ok { $f2(((:a))) }, "in '\$f2(((:a)))', '(:a)' is a pair"; 72 #?rakudo skip '.() sub calls'73 68 dies_ok { $f2.(((:a))) }, "in '\$f2.(((:a)))', '(:a)' is a pair"; 74 69 } … … 79 74 80 75 is f3($pair), "Pair", 'a $pair is not treated magically...'; 76 # XXX investigate what [,] actually does, it has changed recently 81 77 #?pugs todo '[,]' 82 78 #?rakudo skip 'reduce meta op' -
t/spec/S02-magicals/dollar_bang.t
r22426 r22515 3 3 use Test; 4 4 5 plan 8;5 plan 10; 6 6 7 7 =begin desc … … 13 13 # L<S04/"Exceptions"/"A bare die/fail takes $! as the default argument."> 14 14 15 # ?rakudo 3 skip 'unimpl $!'15 ##?rakudo 3 skip 'unimpl $!' 16 16 17 eval '&nonexisting_subroutine()'; 17 eval 'nonexisting_subroutine()'; 18 ok defined($!), 'nonexisting sub in eval makes $! defined'; 19 eval 'nonexisting_subroutine()'; 20 #?rakudo skip 'Test $! for truthness' 18 21 ok $!, 'Calling a nonexisting subroutine sets $!'; 19 22 20 23 undefine $!; 24 # XXX nonexisting_subroutine is detectable at compile time, 25 # this test should be fixed somehow 21 26 try { nonexisting_subroutine; }; 27 ok $! !~~ undef, 'Calling a nonexisting subroutine defines $!'; 28 try { nonexisting_subroutine; }; 29 #?rakudo skip 'Test $! for truthness' 22 30 ok $!, 'Calling a nonexisting subroutine sets $!'; 23 31 … … 27 35 my @a; 28 36 try { foo(@a,@a) }; 37 #?rakudo skip 'Test $! for truthness' 29 38 ok $!, 'Calling a subroutine with a nonmatching signature sets $!'; 30 39 ok !$called, 'The subroutine also was not called'; … … 38 47 undefine $!; 39 48 try { incr(19) }; 49 #?rakudo todo 'containers/values' 40 50 ok $!, 'Modifying a constant sets $!'; 41 51 … … 47 57 die; # use the default argument 48 58 } 59 #?rakudo todo 'stringification of $!' 49 60 ok ~($!) ~~ /qwerty/, 'die without argument uses $! properly'; 61 62 # vim: ft=perl6 -
t/spec/S02-names_and_variables/varnames.t
r22393 r22515 13 13 14 14 # things that should be invalid 15 #?rakudo skip 'Null PMC access in type()'16 15 eval_dies_ok 'my $f!ao = "beh";', "but normal varnames can't have ! in their name"; 17 #?rakudo skip 'Null PMC access in type()'18 16 eval_dies_ok 'my $fo:o::b:ar = "bla"', "var names can't have colons in their names either"; 19 17 -
t/spec/S02-whitespace_and_comments/unspace.t
r22161 r22515 7 7 # L<S02/"Whitespace and Comments"/This is known as the "unspace"> 8 8 9 is(4\ .sqrt, 2, 'unspace with numbers'); 9 10 #?rakudo skip "get_string() not implemented in class 'ResizableStringArray'" 11 ok(4\ .sqrt == 2, 'unspace with numbers'); 12 #?rakudo skip 'unspace with comments' 10 13 is(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 14 is("x"\ .codes, 1, 'unspace with strings'); 15 is("x"\ .codes(), 1, 'unspace with strings + parens'); 16 17 #?rakudo skip 'lexicals in eval' 18 { 14 19 my $foo = 4; 15 20 is(eval('$foo.++'), 4, '(short) unspace with postfix inc'); … … 19 24 is(eval('$foo\ .--'), 6, 'unspace with postfix dec'); 20 25 is($foo, 5, 'unspace with postfix dec really postfix'); 26 } 21 27 22 28 is("xxxxxx"\.bytes, 6, 'unspace without spaces'); … … 58 64 59 65 #XXX why is eval required here? 66 { 60 67 is(eval('foo.id'), 'a', 'sanity - foo.id'); 61 68 is(eval('foo .id'), 'b', 'sanity - foo .id'); … … 166 173 .id'), 'a', 'hideous nested pod torture test'); 167 174 175 } 168 176 # L<S04/"Statement-ending blocks"/"Because subroutine declarations are expressions"> 169 177 #XXX probably shouldn't be in this file... 170 178 179 { 171 180 eval('sub f { 3 } sub g { 3 }'); 172 181 eval_dies_ok('f', 'semicolon or newline required between blocks'); 173 182 eval_dies_ok('g', 'semicolon or newline required between blocks'); 183 } 174 184 175 185 # L<S06/"Blocks"/"unless followed immediately by a comma"> 176 186 # 187 { 177 188 sub baz(Code $x, *@y) { $x.(@y) } 178 189 … … 188 199 is(eval('xyzzy { @^x } : 1, 2, 3'), (1, 2, 3), 'colon not immediately following arg block'); 189 200 is(eval('xyzzy { @^x }\ : 1, 2, 3'), (1, 2, 3), 'unspace then colon following arg block'); 201 } 190 202 191 203 # L<S02/"Whitespace and Comments"/"natural conflict between postfix operators and infix operators"> … … 195 207 # ($n) (++$m) 196 208 # ($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 13 13 } 14 14 15 #?rakudo skip 'infix:<but>' 15 16 { 16 17 my $x = 'Today' but Day::Mon; -
t/spec/S12-methods/what.t
r21472 r22515 25 25 { 26 26 my $a = 3; 27 #?rakudo todo 'Int type should somehow conform to Num' 27 28 ok($a.WHAT ~~ Num, "an Int isa Num"); 28 29 ok($a.WHAT ~~ Object, "an Int isa Object"); … … 32 33 { 33 34 my $a = sub ($x) { 100 + $x }; 35 #?rakudo 2 todo 'correct types for subs and blocks' 34 36 ok($a.WHAT === Sub, "a sub's type is Sub"); 35 37 ok($a.WHAT ~~ Routine, "a sub isa Routine"); … … 45 47 my $o = Foo.new; 46 48 is($o."WHAT", 'Bar', '."WHAT" calls the method instead of the macro'); 49 #?rakudo todo '.WHAT not (easily overridable)' 47 50 is($o.WHAT, 'Foo', '.WHAT still works as intended'); 48 51 my $meth = "WHAT"; 52 #?rakudo skip 'indirect method calls' 49 53 is($o.$meth, 'Bar', '.$meth calls the method instead of the macro'); 50 54 } -
t/spec/S29-context/eval.t
r22471 r22515 11 11 =end pod 12 12 13 #?rakudo skip "Null PMC access in find_method()"14 15 #?rakudo emit =begin unimpl16 17 13 # 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 } 22 24 23 25 is(eval('5'), 5, 'simple eval works and returns the value'); 24 26 my $foo = 1234; 25 #?rakudo skip "unimpl Null PMC access in find_method"27 #?rakudo skip 'eval needs access to outer scope' 26 28 is(eval('$foo'), $foo, 'simple eval using variable defined outside'); 27 29 28 30 # traps die? 29 #?rakudo skip "unimpl Null PMC access in type()"31 #?rakudo skip 'Null PMC access in type()' 30 32 ok(!eval('die; 1'), "eval can trap die"); 31 33 32 ok( !eval('my @a = (1); @a<0>'), "eval returns undef on syntax error");34 ok(eval('my @a = (1); @a!<0>') ~~ undef, "eval returns undef on syntax error"); 33 35 34 #?rakudo skip "unimpl Null PMC access in type()"36 #?rakudo skip 'eval should trap fatal use statement' 35 37 ok(!eval('use Poison; 1'), "eval can trap a fatal use statement"); 36 38 … … 38 40 ok(v() == 123, "a plain subroutine"); 39 41 eval 'sub v { 456 }'; 42 #?rakudo todo 'eval can override subroutines (specced?)' 40 43 ok(v() == 456, "eval can overwrite a subroutine"); 41 44 42 45 # 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 ' 44 47 dies_ok({eval {42}}, 'block eval is gone'); -
t/spec/S29-str/split-simple.t
r22315 r22515 2 2 use Test; 3 3 4 plan 3 0;4 plan 32; 5 5 6 6 =begin description … … 51 51 ); 52 52 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 { 63 split_test 'ab34d5z'.split(/<before \d>/), <ab 3 4d 5z>, 'split with zero-width assertions'; 64 } 65 53 66 # As per Larry, ''.split('') is the empty list 54 67 # http://www.nntp.perl.org/group/perl.perl6.language/2008/09/msg29730.html
