Changeset 22571 for t

Show
Ignore:
Timestamp:
10/10/08 22:42:59 (6 weeks ago)
Author:
lwall
Message:

[t] excise exists and delete functions

Location:
t
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • t/regex/from_perl6_rules/exhaustive.t

    r21749 r22571  
    4141        ok( %expected{$_}, "Matched '$_' ($rep)" ); 
    4242        ok( %position{$_} == $_.pos, "At correct position of '$_' ($rep)" ); 
    43         delete %expected{$_}; 
     43        %expected{$_} :delete; 
    4444    } 
    4545    ok(%expected.keys == 0, "No matches missed ($rep)" ); 
     
    5656    ok( %expected{$_}, "Capture matched '$_'" ); 
    5757    ok( $_[1] = substr($_[0],1,-1), "Captured within '$_'" ); 
    58     delete %expected{$_}; 
     58    %expected{$_} :delete; 
    5959} 
    6060 
  • t/regex/from_perl6_rules/hash_cap.t

    r21789 r22571  
    2020 
    2121ok("  a b\tc" ~~ m/%<chars>=( \s+ \S+ )/, 'Named unrepeated hash capture'); 
    22 ok(exists($/<chars>,'  a'), 'One key captured'); 
     22ok($/<chars>{'  a'}:exists, 'One key captured'); 
    2323ok(eval(q{!defined($/<chars>{'  a'})}), 'One value undefined'); 
    2424ok($/<chars>.keys == 1, 'No extra unrepeated captures'); 
    2525 
    2626ok("  a b\tc" ~~ m/%<chars>=( \s+ \S+ )+/, 'Named simple hash capture'); 
    27 ok(exists($/<chars>,'  a'), 'First simple key captured'); 
     27ok($/<chars>{'  a'}:exists, 'First simple key captured'); 
    2828ok(eval(q{!defined($/<chars>{'  a'})}), 'First simple value undefined'); 
    29 ok(exists($/<chars>,' b'), 'Second simple key captured'); 
     29ok($/<chars>{' b'}:exists, 'Second simple key captured'); 
    3030ok(eval(q{!defined($/<chars>{' b'})}), 'Second simple value undefined'); 
    31 ok(exists($/<chars>,"\tc"), 'Third simple key captured'); 
     31ok($/<chars>{"\tc"}:exists, 'Third simple key captured'); 
    3232ok(eval(q{!defined($/<chars>{"\tc"})}), 'Third simple value undefined'); 
    3333ok($/<chars>.keys == 3, 'No extra simple captures'); 
    3434 
    3535ok("  a b\tc" ~~ m/%<first>=( \s+ \S+ )+ %<last>=( \s+ \S+)+/, 'Sequential simple hash capture'); 
    36 ok(exists($/<first>,'  a'), 'First sequential key captured'); 
     36ok($/<first>{'  a'}:exists, 'First sequential key captured'); 
    3737ok(eval(q{!defined($/<first>{'  a'})}), 'First sequential value undefined'); 
    38 ok(exists($/<first>,' b'), 'Second sequential key captured'); 
     38ok($/<first>{' b'}:exists, 'Second sequential key captured'); 
    3939ok(eval(q{!defined($/<first>{' b'})}), 'Second sequential value undefined'); 
    40 ok(exists($/<last>,"\tc"), 'Third sequential key captured'); 
     40ok($/<last>{"\tc"}:exists, 'Third sequential key captured'); 
    4141ok(eval(q{!defined($/<last>{"\tc"})}), 'Third sequential value undefined'); 
    4242ok($/<first>.keys == 2, 'No extra first sequential captures'); 
     
    4444 
    4545ok("abcxyd" ~~ m/a  %<foo>=(.(.))+ d/, 'Repeated nested hash capture'); 
    46 ok(exists($/<foo>,'c'), 'Nested key 1 captured'); 
     46ok($/<foo>{'c'}:exists, 'Nested key 1 captured'); 
    4747ok(eval(q{!defined($/<foo><c>)}), 'No nested value 1 captured'); 
    48 ok(exists($/<foo>,'y'), 'Nested key 2 captured'); 
     48ok($/<foo>{'y'}:exists, 'Nested key 2 captured'); 
    4949ok(eval(q{!defined($/<foo><y>)}), 'No nested value 2 captured'); 
    5050ok($/<foo>.keys == 2, 'No extra nested captures'); 
    5151 
    5252ok("abcd" ~~ m/a  %<foo>=(.(.))  d/, 'Unrepeated nested hash capture'); 
    53 ok(exists($/<foo>,'c'), 'Unrepeated key captured'); 
     53ok($/<foo>{'c'}:exists, 'Unrepeated key captured'); 
    5454ok(eval(q{!defined($/<foo><c>)}), 'Unrepeated value not captured'); 
    5555ok($/<foo>.keys == 1, 'No extra unrepeated nested captures'); 
    5656 
    5757ok("abcd" ~~ m/a  %<foo>=((.)(.))  d/, 'Unrepeated nested hash multicapture'); 
    58 ok(exists($/<foo>,'b'), 'Unrepeated key multicaptured'); 
     58ok($/<foo>{'b'}:exists, 'Unrepeated key multicaptured'); 
    5959ok(eval(q{$/<foo><b>}), 'c', 'Unrepeated value not multicaptured'); 
    6060ok($/<foo>.keys == 1, 'No extra unrepeated nested multicaptures'); 
    6161 
    6262ok("abcxyd" ~~ m/a  %<foo>=((.)(.))+ d/, 'Repeated nested hash multicapture'); 
    63 ok(exists($/<foo>,'b'), 'Nested key 1 multicaptured'); 
     63ok($/<foo>{'b'}:exists, 'Nested key 1 multicaptured'); 
    6464ok(eval(q{$/<foo><b>}), 'c', 'Nested value 1 multicaptured'); 
    65 ok(exists($/<foo>,'x'), 'Nested key 2 multicaptured'); 
     65ok($/<foo>{'x'}:exists, 'Nested key 2 multicaptured'); 
    6666ok(eval(q{$/<foo><x>}), 'y', 'Nested value 2 multicaptured'); 
    6767ok($/<foo>.keys == 2, 'No extra nested multicaptures'); 
     
    6969our %foo; 
    7070ok("abcxyd" ~~ m/a  %foo=(.(.))+  d/, 'Package hash capture'); 
    71 ok(exists(%foo,'c'), 'Package hash key 1 captured'); 
     71ok(%foo{'c'}:exists, 'Package hash key 1 captured'); 
    7272ok(eval(q{!defined(%foo{c})}), 'Package hash value 1 not captured'); 
    73 ok(exists(%foo,'y'), 'Package hash key 2 captured'); 
     73ok(%foo{'y'}:exists, 'Package hash key 2 captured'); 
    7474ok(eval(q{!defined(%foo{y})}), 'Package hash value 2 not captured'); 
    7575ok(%foo.keys == 2, 'No extra package hash captures'); 
     
    8282 
    8383ok("  a b\tc" ~~ m/%<chars>=( %<spaces>=[\s+] (\S+))+/, 'Nested multihash capture'); 
    84 ok(exists($/<chars>,'a'), 'Outer hash capture key 1'); 
     84ok($/<chars>{'a'}:exists, 'Outer hash capture key 1'); 
    8585ok(eval(q{!defined($/<chars><a>)}), 'Outer hash no capture value 1'); 
    86 ok(exists($/<chars>,'b'), 'Outer hash capture key 2'); 
     86ok($/<chars>{'b'}:exists, 'Outer hash capture key 2'); 
    8787ok(eval(q{!defined($/<chars><b>)}), 'Outer hash no capture value 2'); 
    88 ok(exists($/<chars>,'c'), 'Outer hash capture key 3'); 
     88ok($/<chars>{'c'}:exists, 'Outer hash capture key 3'); 
    8989ok(eval(q{!defined($/<chars><c>)}), 'Outer hash no capture value 3'); 
    9090ok($/<chars>.keys == 3, 'Outer hash no extra captures'); 
    9191 
    92 ok(exists($/<spaces>,'  '), 'Inner hash capture key 1'); 
     92ok($/<spaces>{'  '}:exists, 'Inner hash capture key 1'); 
    9393ok(eval(q{!defined($/<spaces>{'  '})}), 'Inner hash no capture value 1'); 
    94 ok(exists($/<spaces>,' '), 'Inner hash capture key 2'); 
     94ok($/<spaces>{' '}:exists, 'Inner hash capture key 2'); 
    9595ok(eval(q{!defined($/<spaces>{' '})}), 'Inner hash no capture value 2'); 
    96 ok(exists($/<spaces>,"\t"), 'Inner hash capture key 3'); 
     96ok($/<spaces>{"\t"}:exists, 'Inner hash capture key 3'); 
    9797ok(eval(q{!defined($/<spaces>{"\t"})}), 'Inner hash no capture value 3'); 
    9898ok($/<spaces>.keys == 3, 'Inner hash no extra captures'); 
     
    102102ok("  a b\tc" ~~ m/%<chars>=( <spaces> (\S+))+/, 'Subrule hash capture'); 
    103103 
    104 ok(exists($/<chars>,'a'), 'Outer subrule hash capture key 1'); 
     104ok($/<chars>{'a'}:exists, 'Outer subrule hash capture key 1'); 
    105105ok(eval(q{!defined($/<chars><a>)}), 'Outer subrule hash no capture value 1'); 
    106 ok(exists($/<chars>,'b'), 'Outer subrule hash capture key 2'); 
     106ok($/<chars>{'b'}:exists, 'Outer subrule hash capture key 2'); 
    107107ok(eval(q{!defined($/<chars><b>)}), 'Outer subrule hash no capture value 2'); 
    108 ok(exists($/<chars>,'c'), 'Outer subrule hash capture key 3'); 
     108ok($/<chars>{'c'}:exists, 'Outer subrule hash capture key 3'); 
    109109ok(eval(q{!defined($/<chars><c>)}), 'Outer subrule hash no capture value 3'); 
    110110ok($/<chars>.keys == 3, 'Outer subrule hash no extra captures'); 
     
    113113 
    114114ok("  a b\tc" ~~ m/%<chars>=( %<spaces>=[<?spaces>] (\S+))+/, 'Nested subrule hash multicapture'); 
    115 ok(exists($/<chars>,'a'), 'Outer rule nested hash key multicapture'); 
     115ok($/<chars>{'a'}:exists, 'Outer rule nested hash key multicapture'); 
    116116ok(eval(q{!defined($/<chars><a>)}), 'Outer rule nested hash value multicapture'); 
    117 ok(exists($/<chars>,'b'), 'Outer rule nested hash key multicapture'); 
     117ok($/<chars>{'b'}:exists, 'Outer rule nested hash key multicapture'); 
    118118ok(eval(q{!defined($/<chars><b>)}), 'Outer rule nested hash value multicapture'); 
    119 ok(exists($/<chars>,'c'), 'Outer rule nested hash key multicapture'); 
     119ok($/<chars>{'c'}:exists, 'Outer rule nested hash key multicapture'); 
    120120ok(eval(q{!defined($/<chars><c>)}), 'Outer rule nested hash value multicapture'); 
    121121ok($/<chars>.keys == 3, 'Outer subrule hash no extra multicaptures'); 
    122122 
    123 ok(exists($/<spaces>,'  '), 'Inner rule nested hash key multicapture'); 
     123ok($/<spaces>{'  '}:exists, 'Inner rule nested hash key multicapture'); 
    124124ok(eval(q{!defined($/<spaces>{'  '})}), 'Inner rule nested hash value multicapture'); 
    125 ok(exists($/<spaces>,' '), 'Inner rule nested hash key multicapture'); 
     125ok($/<spaces>{' '}:exists, 'Inner rule nested hash key multicapture'); 
    126126ok(eval(q{!defined($/<spaces>{' '})}), 'Inner rule nested hash value multicapture'); 
    127 ok(exists($/<spaces>,"\t"), 'Inner rule nested hash key multicapture'); 
     127ok($/<spaces>{"\t"}:exists, 'Inner rule nested hash key multicapture'); 
    128128ok(eval(q{!defined($/<spaces>{"\t"})}), 'Inner rule nested hash value multicapture'); 
    129129ok($/<spaces>.keys == 3, 'Inner subrule hash no extra multicaptures'); 
     
    137137my %bases = (); 
    138138ok("Gattaca" ~~ m:i/ %bases=(A|C|G|T)+ /, 'All your bases...'); 
    139 ok(exists(%bases,'a'), 'a key'); 
     139ok(%bases{'a'}:exists, 'a key'); 
    140140ok(eval(q{!defined(%bases{a})}), 'No a value'); 
    141 ok(exists(%bases,'c'), 'c key'); 
     141ok(%bases{'c'}:exists, 'c key'); 
    142142ok(eval(q{!defined(%bases{c})}), 'No c value'); 
    143 ok(!exists(%bases,'g'), 'No g key'); 
    144 ok(exists(%bases,'G'), 'G key'); 
     143ok(!%bases{'g'}:exists, 'No g key'); 
     144ok(%bases{'G'}:exists, 'G key'); 
    145145ok(eval(q{!defined(%bases{G})}), 'No G value'); 
    146 ok(exists(%bases,'t'), 't key'); 
     146ok(%bases{'t'}:exists, 't key'); 
    147147ok(eval(q{!defined(%bases{t})}), 'No t value'); 
    148148ok(%bases.keys == 4, 'No other bases'); 
     
    151151my %aca = ('aca' => 1);; 
    152152ok("Gattaca" ~~ m:i/ %bases=(A|C|G|T)**{4} (%aca) /, 'Hash interpolation'); 
    153 ok(exists(%bases,'a'), 'a key'); 
     153ok(%bases{'a'}:exists, 'a key'); 
    154154ok(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'); 
     155ok(!%bases{'c'}:exists, 'No c key'); 
     156ok(!%bases{'g'}:exists, 'No g key'); 
     157ok(%bases{'G'}:exists, 'G key'); 
    158158ok(eval(q{!defined(%bases{G})}), 'No G value'); 
    159 ok(exists(%bases,'t'), 't key'); 
     159ok(%bases{'t'}:exists, 't key'); 
    160160ok(eval(q{!defined(%bases{t})}), 'No t value'); 
    161161ok(%bases.keys == 3, 'No other bases'); 
  • t/regex/from_perl6_rules/overlapping.t

    r21719 r22571  
    3737        ok( %expected{$_}, "Matched '$_' ($rep)" ); 
    3838        ok( %position{$_} == $_.pos, "At correct position of '$_' ($rep)" ); 
    39         delete %expected{$_}; 
     39        %expected{$_} :delete; 
    4040    } 
    4141    ok(%expected.keys == 0, "No matches missed ($rep)" ); 
     
    5252    my %expected; %expected{map {$_[1]}, @expected} = (1) x @expected; 
    5353    ok( $_[1] = substr($_[0],1,-1), "Captured within '$_'" ); 
    54     delete %expected{$_}; 
     54    %expected{$_} :delete; 
    5555} 
    5656 
  • t/spec/S02-builtin_data_types/autovivification.t

    r22385 r22571  
    1616{ 
    1717    my %a; 
    18     my $b = exists %a<b><c>; 
     18    my $b = true %a<b><c>:exists; 
    1919    is %a.keys.elems, 0, "exists doesn't autovivify."; 
    2020} 
  • t/spec/S02-names_and_variables/signature.t

    r21940 r22571  
    5858    my $siglist = eval ':($x?)'; 
    5959    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>); 
    6161} 
    6262 
  • t/spec/S06-traits/is-readonly.t

    r22125 r22571  
    2626{ 
    2727    my $a is readonly; 
    28     ok !(try { exists $a }), "exists() returns false on an uninitialized var declared with 'is readonly'"; 
     28    ok !(try { VAR($a).defined }), ".VAR returns undefined on an uninitialized var declared with 'is readonly'"; 
    2929 
    3030    $a := 42; 
    31     ok (try { exists $a }), "exists() returns true now", :todo<feature>; 
     31    ok (try { VAR($a).defined }), ".VAR returns defined now", :todo<feature>; 
    3232} 
    3333 
     
    3535    my $a = 3; 
    3636 
    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>; 
    3838} 
  • t/spec/S29-hash/delete.t

    r22215 r22571  
    44plan 9; 
    55 
    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> 
    197 
    208sub gen_hash { 
     
    2917 
    3018    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."; 
    3220} 
    3321 
     
    3624    my %h1 = gen_hash; 
    3725    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."; 
    3927} 
    4028 
     
    4331 
    4432is +%hash, 4, "basic sanity (2)"; 
    45 is ~%hash.delete("a"), "1", 
     33is ~(%hash<a>:delete), "1", 
    4634  "deletion of a hash element returned the right value"; 
    4735is +%hash, 3, "deletion of a hash element"; 
    4836{ 
    49     is ~%hash.delete("c", "d"), "3 4", 
     37    is ~(%hash{"c", "d"}:delete), "3 4", 
    5038    "deletion of hash elements returned the right values"; 
    5139    is +%hash, 1, "deletion of hash elements"; 
     
    5543{ 
    5644    my $a = 1; 
    57     try { delete $a; }; 
     45    try { $a :delete; }; 
    5846    # XXX do we really want to test against a specific error message? 
    5947    #?rakudo 1 skip "no rx:P5"