- Timestamp:
- 10/10/08 22:42:59 (6 weeks ago)
- Location:
- t
- Files:
-
- 7 modified
-
regex/from_perl6_rules/exhaustive.t (modified) (2 diffs)
-
regex/from_perl6_rules/hash_cap.t (modified) (8 diffs)
-
regex/from_perl6_rules/overlapping.t (modified) (2 diffs)
-
spec/S02-builtin_data_types/autovivification.t (modified) (1 diff)
-
spec/S02-names_and_variables/signature.t (modified) (1 diff)
-
spec/S06-traits/is-readonly.t (modified) (2 diffs)
-
spec/S29-hash/delete.t (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
t/regex/from_perl6_rules/exhaustive.t
r21749 r22571 41 41 ok( %expected{$_}, "Matched '$_' ($rep)" ); 42 42 ok( %position{$_} == $_.pos, "At correct position of '$_' ($rep)" ); 43 delete %expected{$_};43 %expected{$_} :delete; 44 44 } 45 45 ok(%expected.keys == 0, "No matches missed ($rep)" ); … … 56 56 ok( %expected{$_}, "Capture matched '$_'" ); 57 57 ok( $_[1] = substr($_[0],1,-1), "Captured within '$_'" ); 58 delete %expected{$_};58 %expected{$_} :delete; 59 59 } 60 60 -
t/regex/from_perl6_rules/hash_cap.t
r21789 r22571 20 20 21 21 ok(" a b\tc" ~~ m/%<chars>=( \s+ \S+ )/, 'Named unrepeated hash capture'); 22 ok( exists($/<chars>,' a'), 'One key captured');22 ok($/<chars>{' a'}:exists, 'One key captured'); 23 23 ok(eval(q{!defined($/<chars>{' a'})}), 'One value undefined'); 24 24 ok($/<chars>.keys == 1, 'No extra unrepeated captures'); 25 25 26 26 ok(" a b\tc" ~~ m/%<chars>=( \s+ \S+ )+/, 'Named simple hash capture'); 27 ok( exists($/<chars>,' a'), 'First simple key captured');27 ok($/<chars>{' a'}:exists, 'First simple key captured'); 28 28 ok(eval(q{!defined($/<chars>{' a'})}), 'First simple value undefined'); 29 ok( exists($/<chars>,' b'), 'Second simple key captured');29 ok($/<chars>{' b'}:exists, 'Second simple key captured'); 30 30 ok(eval(q{!defined($/<chars>{' b'})}), 'Second simple value undefined'); 31 ok( exists($/<chars>,"\tc"), 'Third simple key captured');31 ok($/<chars>{"\tc"}:exists, 'Third simple key captured'); 32 32 ok(eval(q{!defined($/<chars>{"\tc"})}), 'Third simple value undefined'); 33 33 ok($/<chars>.keys == 3, 'No extra simple captures'); 34 34 35 35 ok(" a b\tc" ~~ m/%<first>=( \s+ \S+ )+ %<last>=( \s+ \S+)+/, 'Sequential simple hash capture'); 36 ok( exists($/<first>,' a'), 'First sequential key captured');36 ok($/<first>{' a'}:exists, 'First sequential key captured'); 37 37 ok(eval(q{!defined($/<first>{' a'})}), 'First sequential value undefined'); 38 ok( exists($/<first>,' b'), 'Second sequential key captured');38 ok($/<first>{' b'}:exists, 'Second sequential key captured'); 39 39 ok(eval(q{!defined($/<first>{' b'})}), 'Second sequential value undefined'); 40 ok( exists($/<last>,"\tc"), 'Third sequential key captured');40 ok($/<last>{"\tc"}:exists, 'Third sequential key captured'); 41 41 ok(eval(q{!defined($/<last>{"\tc"})}), 'Third sequential value undefined'); 42 42 ok($/<first>.keys == 2, 'No extra first sequential captures'); … … 44 44 45 45 ok("abcxyd" ~~ m/a %<foo>=(.(.))+ d/, 'Repeated nested hash capture'); 46 ok( exists($/<foo>,'c'), 'Nested key 1 captured');46 ok($/<foo>{'c'}:exists, 'Nested key 1 captured'); 47 47 ok(eval(q{!defined($/<foo><c>)}), 'No nested value 1 captured'); 48 ok( exists($/<foo>,'y'), 'Nested key 2 captured');48 ok($/<foo>{'y'}:exists, 'Nested key 2 captured'); 49 49 ok(eval(q{!defined($/<foo><y>)}), 'No nested value 2 captured'); 50 50 ok($/<foo>.keys == 2, 'No extra nested captures'); 51 51 52 52 ok("abcd" ~~ m/a %<foo>=(.(.)) d/, 'Unrepeated nested hash capture'); 53 ok( exists($/<foo>,'c'), 'Unrepeated key captured');53 ok($/<foo>{'c'}:exists, 'Unrepeated key captured'); 54 54 ok(eval(q{!defined($/<foo><c>)}), 'Unrepeated value not captured'); 55 55 ok($/<foo>.keys == 1, 'No extra unrepeated nested captures'); 56 56 57 57 ok("abcd" ~~ m/a %<foo>=((.)(.)) d/, 'Unrepeated nested hash multicapture'); 58 ok( exists($/<foo>,'b'), 'Unrepeated key multicaptured');58 ok($/<foo>{'b'}:exists, 'Unrepeated key multicaptured'); 59 59 ok(eval(q{$/<foo><b>}), 'c', 'Unrepeated value not multicaptured'); 60 60 ok($/<foo>.keys == 1, 'No extra unrepeated nested multicaptures'); 61 61 62 62 ok("abcxyd" ~~ m/a %<foo>=((.)(.))+ d/, 'Repeated nested hash multicapture'); 63 ok( exists($/<foo>,'b'), 'Nested key 1 multicaptured');63 ok($/<foo>{'b'}:exists, 'Nested key 1 multicaptured'); 64 64 ok(eval(q{$/<foo><b>}), 'c', 'Nested value 1 multicaptured'); 65 ok( exists($/<foo>,'x'), 'Nested key 2 multicaptured');65 ok($/<foo>{'x'}:exists, 'Nested key 2 multicaptured'); 66 66 ok(eval(q{$/<foo><x>}), 'y', 'Nested value 2 multicaptured'); 67 67 ok($/<foo>.keys == 2, 'No extra nested multicaptures'); … … 69 69 our %foo; 70 70 ok("abcxyd" ~~ m/a %foo=(.(.))+ d/, 'Package hash capture'); 71 ok( exists(%foo,'c'), 'Package hash key 1 captured');71 ok(%foo{'c'}:exists, 'Package hash key 1 captured'); 72 72 ok(eval(q{!defined(%foo{c})}), 'Package hash value 1 not captured'); 73 ok( exists(%foo,'y'), 'Package hash key 2 captured');73 ok(%foo{'y'}:exists, 'Package hash key 2 captured'); 74 74 ok(eval(q{!defined(%foo{y})}), 'Package hash value 2 not captured'); 75 75 ok(%foo.keys == 2, 'No extra package hash captures'); … … 82 82 83 83 ok(" a b\tc" ~~ m/%<chars>=( %<spaces>=[\s+] (\S+))+/, 'Nested multihash capture'); 84 ok( exists($/<chars>,'a'), 'Outer hash capture key 1');84 ok($/<chars>{'a'}:exists, 'Outer hash capture key 1'); 85 85 ok(eval(q{!defined($/<chars><a>)}), 'Outer hash no capture value 1'); 86 ok( exists($/<chars>,'b'), 'Outer hash capture key 2');86 ok($/<chars>{'b'}:exists, 'Outer hash capture key 2'); 87 87 ok(eval(q{!defined($/<chars><b>)}), 'Outer hash no capture value 2'); 88 ok( exists($/<chars>,'c'), 'Outer hash capture key 3');88 ok($/<chars>{'c'}:exists, 'Outer hash capture key 3'); 89 89 ok(eval(q{!defined($/<chars><c>)}), 'Outer hash no capture value 3'); 90 90 ok($/<chars>.keys == 3, 'Outer hash no extra captures'); 91 91 92 ok( exists($/<spaces>,' '), 'Inner hash capture key 1');92 ok($/<spaces>{' '}:exists, 'Inner hash capture key 1'); 93 93 ok(eval(q{!defined($/<spaces>{' '})}), 'Inner hash no capture value 1'); 94 ok( exists($/<spaces>,' '), 'Inner hash capture key 2');94 ok($/<spaces>{' '}:exists, 'Inner hash capture key 2'); 95 95 ok(eval(q{!defined($/<spaces>{' '})}), 'Inner hash no capture value 2'); 96 ok( exists($/<spaces>,"\t"), 'Inner hash capture key 3');96 ok($/<spaces>{"\t"}:exists, 'Inner hash capture key 3'); 97 97 ok(eval(q{!defined($/<spaces>{"\t"})}), 'Inner hash no capture value 3'); 98 98 ok($/<spaces>.keys == 3, 'Inner hash no extra captures'); … … 102 102 ok(" a b\tc" ~~ m/%<chars>=( <spaces> (\S+))+/, 'Subrule hash capture'); 103 103 104 ok( exists($/<chars>,'a'), 'Outer subrule hash capture key 1');104 ok($/<chars>{'a'}:exists, 'Outer subrule hash capture key 1'); 105 105 ok(eval(q{!defined($/<chars><a>)}), 'Outer subrule hash no capture value 1'); 106 ok( exists($/<chars>,'b'), 'Outer subrule hash capture key 2');106 ok($/<chars>{'b'}:exists, 'Outer subrule hash capture key 2'); 107 107 ok(eval(q{!defined($/<chars><b>)}), 'Outer subrule hash no capture value 2'); 108 ok( exists($/<chars>,'c'), 'Outer subrule hash capture key 3');108 ok($/<chars>{'c'}:exists, 'Outer subrule hash capture key 3'); 109 109 ok(eval(q{!defined($/<chars><c>)}), 'Outer subrule hash no capture value 3'); 110 110 ok($/<chars>.keys == 3, 'Outer subrule hash no extra captures'); … … 113 113 114 114 ok(" a b\tc" ~~ m/%<chars>=( %<spaces>=[<?spaces>] (\S+))+/, 'Nested subrule hash multicapture'); 115 ok( exists($/<chars>,'a'), 'Outer rule nested hash key multicapture');115 ok($/<chars>{'a'}:exists, 'Outer rule nested hash key multicapture'); 116 116 ok(eval(q{!defined($/<chars><a>)}), 'Outer rule nested hash value multicapture'); 117 ok( exists($/<chars>,'b'), 'Outer rule nested hash key multicapture');117 ok($/<chars>{'b'}:exists, 'Outer rule nested hash key multicapture'); 118 118 ok(eval(q{!defined($/<chars><b>)}), 'Outer rule nested hash value multicapture'); 119 ok( exists($/<chars>,'c'), 'Outer rule nested hash key multicapture');119 ok($/<chars>{'c'}:exists, 'Outer rule nested hash key multicapture'); 120 120 ok(eval(q{!defined($/<chars><c>)}), 'Outer rule nested hash value multicapture'); 121 121 ok($/<chars>.keys == 3, 'Outer subrule hash no extra multicaptures'); 122 122 123 ok( exists($/<spaces>,' '), 'Inner rule nested hash key multicapture');123 ok($/<spaces>{' '}:exists, 'Inner rule nested hash key multicapture'); 124 124 ok(eval(q{!defined($/<spaces>{' '})}), 'Inner rule nested hash value multicapture'); 125 ok( exists($/<spaces>,' '), 'Inner rule nested hash key multicapture');125 ok($/<spaces>{' '}:exists, 'Inner rule nested hash key multicapture'); 126 126 ok(eval(q{!defined($/<spaces>{' '})}), 'Inner rule nested hash value multicapture'); 127 ok( exists($/<spaces>,"\t"), 'Inner rule nested hash key multicapture');127 ok($/<spaces>{"\t"}:exists, 'Inner rule nested hash key multicapture'); 128 128 ok(eval(q{!defined($/<spaces>{"\t"})}), 'Inner rule nested hash value multicapture'); 129 129 ok($/<spaces>.keys == 3, 'Inner subrule hash no extra multicaptures'); … … 137 137 my %bases = (); 138 138 ok("Gattaca" ~~ m:i/ %bases=(A|C|G|T)+ /, 'All your bases...'); 139 ok( exists(%bases,'a'), 'a key');139 ok(%bases{'a'}:exists, 'a key'); 140 140 ok(eval(q{!defined(%bases{a})}), 'No a value'); 141 ok( exists(%bases,'c'), 'c key');141 ok(%bases{'c'}:exists, 'c key'); 142 142 ok(eval(q{!defined(%bases{c})}), 'No c value'); 143 ok(! exists(%bases,'g'), 'No g key');144 ok( exists(%bases,'G'), 'G key');143 ok(!%bases{'g'}:exists, 'No g key'); 144 ok(%bases{'G'}:exists, 'G key'); 145 145 ok(eval(q{!defined(%bases{G})}), 'No G value'); 146 ok( exists(%bases,'t'), 't key');146 ok(%bases{'t'}:exists, 't key'); 147 147 ok(eval(q{!defined(%bases{t})}), 'No t value'); 148 148 ok(%bases.keys == 4, 'No other bases'); … … 151 151 my %aca = ('aca' => 1);; 152 152 ok("Gattaca" ~~ m:i/ %bases=(A|C|G|T)**{4} (%aca) /, 'Hash interpolation'); 153 ok( exists(%bases,'a'), 'a key');153 ok(%bases{'a'}:exists, 'a key'); 154 154 ok(eval(q{!defined(%bases{a})}), 'No a value'); 155 ok(! exists(%bases,'c'), 'No c key');156 ok(! exists(%bases,'g'), 'No g key');157 ok( exists(%bases,'G'), 'G key');155 ok(!%bases{'c'}:exists, 'No c key'); 156 ok(!%bases{'g'}:exists, 'No g key'); 157 ok(%bases{'G'}:exists, 'G key'); 158 158 ok(eval(q{!defined(%bases{G})}), 'No G value'); 159 ok( exists(%bases,'t'), 't key');159 ok(%bases{'t'}:exists, 't key'); 160 160 ok(eval(q{!defined(%bases{t})}), 'No t value'); 161 161 ok(%bases.keys == 3, 'No other bases'); -
t/regex/from_perl6_rules/overlapping.t
r21719 r22571 37 37 ok( %expected{$_}, "Matched '$_' ($rep)" ); 38 38 ok( %position{$_} == $_.pos, "At correct position of '$_' ($rep)" ); 39 delete %expected{$_};39 %expected{$_} :delete; 40 40 } 41 41 ok(%expected.keys == 0, "No matches missed ($rep)" ); … … 52 52 my %expected; %expected{map {$_[1]}, @expected} = (1) x @expected; 53 53 ok( $_[1] = substr($_[0],1,-1), "Captured within '$_'" ); 54 delete %expected{$_};54 %expected{$_} :delete; 55 55 } 56 56 -
t/spec/S02-builtin_data_types/autovivification.t
r22385 r22571 16 16 { 17 17 my %a; 18 my $b = exists %a<b><c>;18 my $b = true %a<b><c>:exists; 19 19 is %a.keys.elems, 0, "exists doesn't autovivify."; 20 20 } -
t/spec/S02-names_and_variables/signature.t
r21940 r22571 58 58 my $siglist = eval ':($x?)'; 59 59 try { $siglist.infix:<:=>() }; 60 ok(! exists $x, "complex siglist bindings works (2)", :todo<feature>);60 ok(!VAR($x).defined, "complex siglist bindings works (2)", :todo<feature>); 61 61 } 62 62 -
t/spec/S06-traits/is-readonly.t
r22125 r22571 26 26 { 27 27 my $a is readonly; 28 ok !(try { exists $a }), "exists() returns falseon an uninitialized var declared with 'is readonly'";28 ok !(try { VAR($a).defined }), ".VAR returns undefined on an uninitialized var declared with 'is readonly'"; 29 29 30 30 $a := 42; 31 ok (try { exists $a }), "exists() returns truenow", :todo<feature>;31 ok (try { VAR($a).defined }), ".VAR returns defined now", :todo<feature>; 32 32 } 33 33 … … 35 35 my $a = 3; 36 36 37 ok (try { exists $a }), "exists()on a plain normal initialized variable returns true", :todo<feature>;37 ok (try { VAR($a).defined }), ".VAR on a plain normal initialized variable returns true", :todo<feature>; 38 38 } -
t/spec/S29-hash/delete.t
r22215 r22571 4 4 plan 9; 5 5 6 # L<S29/Hash/=item delete> 7 8 =begin pod 9 10 Test delete method of Spec Functions. 11 12 our List multi method Hash::delete ( *@keys ) 13 our Scalar multi method Hash::delete ( $key ) is default 14 15 Deletes the elements specified by C<$key> or C<$keys> from the invocant. 16 returns the value(s) that were associated to those keys. 17 18 =end pod 6 # L<S02/Names and Variables/:delete> 19 7 20 8 sub gen_hash { … … 29 17 30 18 my $b = %h1<b>; 31 is %h1 .delete(<b>), $b, "Test for delete single key. (Method call)";19 is %h1<b>:delete, $b, "Test for delete single key."; 32 20 } 33 21 … … 36 24 my %h1 = gen_hash; 37 25 my @cde = %h1<c d e>; 38 is %h1 .delete(<c d e>), @cde, "test for delete multiple keys. (method call)";26 is %h1<c d e>:delete, @cde, "test for delete multiple keys."; 39 27 } 40 28 … … 43 31 44 32 is +%hash, 4, "basic sanity (2)"; 45 is ~ %hash.delete("a"), "1",33 is ~(%hash<a>:delete), "1", 46 34 "deletion of a hash element returned the right value"; 47 35 is +%hash, 3, "deletion of a hash element"; 48 36 { 49 is ~ %hash.delete("c", "d"), "3 4",37 is ~(%hash{"c", "d"}:delete), "3 4", 50 38 "deletion of hash elements returned the right values"; 51 39 is +%hash, 1, "deletion of hash elements"; … … 55 43 { 56 44 my $a = 1; 57 try { delete $a; };45 try { $a :delete; }; 58 46 # XXX do we really want to test against a specific error message? 59 47 #?rakudo 1 skip "no rx:P5"
