Changeset 21798 for misc

Show
Ignore:
Timestamp:
08/06/08 05:32:39 (5 months ago)
Author:
rhr
Message:

[utable.t] syntax check with STD

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • misc/pX/Common/Unicode/t/utable.t

    r19345 r21798  
    1212$u = undef; 
    1313ok $u = Utable.new(@@( 1..2 ; 5..8 )), 'Utable.new with a list of ranges works'; 
    14 for 1..2, 5..8 -> my $n { 
     14for 1..2, 5..8 -> $n { 
    1515    is $u.contains($n), True, ".contains finds $n in @@( 1..2 ; 5..8 )"; 
    1616} 
    17 for -2..0, 3..4, 9..11 -> my $n { 
     17for -2..0, 3..4, 9..11 -> $n { 
    1818    is $u.contains($n), False, ".contains doesn't find $n in @@( 1..2 ; 5..8 )"; 
    1919} 
     
    2424$u = undef; 
    2525ok $u = Utable.new('1..2;5..8'), 'Utable.new with a string works'; 
    26 for 1..2, 5..8 -> my $n { 
     26for 1..2, 5..8 -> $n { 
    2727    is $u.contains($n), True, ".contains finds $n in '1..2;5..8'"; 
    2828} 
    29 for -2..0, 3..4, 9..11 -> my $n { 
     29for -2..0, 3..4, 9..11 -> $n { 
    3030    is $u.contains($n), False, ".contains doesn't find $n in '1..2;5..8'"; 
    3131} 
     
    3434ok $u eqv $u.perl.eval, "round-trip to .perl works for '1..2;5..8'"; 
    3535 
    36 is $u.inverse.tostr '0;3..4;9..1114111', '.inverse works'; 
     36is $u.inverse.tostr, '0;3..4;9..1114111', '.inverse works'; 
    3737 
    3838my $io = open "/tmp/utable.$*PID", :w orelse die; 
     
    6666$u = undef; 
    6767ok $u = Utable.new(@@( 1..2 ; 5..8 ), :val(1, 2)), 'Utable.new with a list of ranges and a list of values works'; 
    68 for 1..2 -> my $n { 
     68for 1..2 -> $n { 
    6969    is $u.get($n), 1, ".get finds 1 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    7070} 
    71 for 5..8 -> my $n { 
     71for 5..8 -> $n { 
    7272    is $u.get($n), 2, ".get finds 2 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    7373} 
    74 for -2..0, 3..4, 9..11 -> my $n { 
     74for -2..0, 3..4, 9..11 -> $n { 
    7575    is $u.get($n), undef, ".get returns undef for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    7676} 
     
    8181$u = undef; 
    8282ok $u = Utable.new('1..2:1;5..8:2'), 'Utable.new with a string with values works'; 
    83 for 1..2 -> my $n { 
     83for 1..2 -> $n { 
    8484    is $u.get($n), 1, ".get finds 1 for $n in '1..2:1;5..8:2'"; 
    8585} 
    86 for 5..8 -> my $n { 
     86for 5..8 -> $n { 
    8787    is $u.get($n), 2, ".get finds 2 for $n in '1..2:1;5..8:2'"; 
    8888} 
    89 for -2..0, 3..4, 9..11 -> my $n { 
     89for -2..0, 3..4, 9..11 -> $n { 
    9090    is $u.get($n), undef, ".get returns undef for $n in '1..2:1;5..8:2'"; 
    9191} 
     
    9595 
    9696$u = Utable.new; 
    97 for 1..2, 5..8 -> my $n { $u.add($n); } 
    98 # test redundant adds 
    99 for 1..2, 5..8 -> my $n { $u.add($n); } 
    100 for 1..2, 5..8 -> my $n { 
     97for 1..2, 5..8 -> $n { $u.add($n); } 
     98# test redundant adds 
     99for 1..2, 5..8 -> $n { $u.add($n); } 
     100for 1..2, 5..8 -> $n { 
    101101    is $u.contains($n), True, "(add) .contains finds $n in @@( 1..2 ; 5..8 )"; 
    102102} 
    103 for -2..0, 3..4, 9..11 -> my $n { 
     103for -2..0, 3..4, 9..11 -> $n { 
    104104    is $u.contains($n), False, "(add) .contains doesn't find $n in @@( 1..2 ; 5..8 )"; 
    105105} 
     
    109109 
    110110$u = Utable.new; 
    111 for 8, 7, 6, 5, 2, 1 -> my $n { $u.add($n); } 
    112 # test redundant adds 
    113 for 1..2, 5..8 -> my $n { $u.add($n); } 
    114 for 1..2, 5..8 -> my $n { 
     111for 8, 7, 6, 5, 2, 1 -> $n { $u.add($n); } 
     112# test redundant adds 
     113for 1..2, 5..8 -> $n { $u.add($n); } 
     114for 1..2, 5..8 -> $n { 
    115115    is $u.contains($n), True, "(backwards add) .contains finds $n in @@( 1..2 ; 5..8 )"; 
    116116} 
    117 for -2..0, 3..4, 9..11 -> my $n { 
     117for -2..0, 3..4, 9..11 -> $n { 
    118118    is $u.contains($n), False, "(backwards add) .contains doesn't find $n in @@( 1..2 ; 5..8 )"; 
    119119} 
     
    123123 
    124124$u = Utable.new; 
    125 for 2, 6, 7, 5, 1, 8 -> my $n { $u.add($n); } 
    126 # test redundant adds 
    127 for 1..2, 5..8 -> my $n { $u.add($n); } 
    128 for 1..2, 5..8 -> my $n { 
     125for 2, 6, 7, 5, 1, 8 -> $n { $u.add($n); } 
     126# test redundant adds 
     127for 1..2, 5..8 -> $n { $u.add($n); } 
     128for 1..2, 5..8 -> $n { 
    129129    is $u.contains($n), True, "(random add) .contains finds $n in @@( 1..2 ; 5..8 )"; 
    130130} 
    131 for -2..0, 3..4, 9..11 -> my $n { 
     131for -2..0, 3..4, 9..11 -> $n { 
    132132    is $u.contains($n), False, "(random add) .contains doesn't find $n in @@( 1..2 ; 5..8 )"; 
    133133} 
     
    137137 
    138138$u = Utable.new; 
    139 for 1..2 -> my $n { $u.add($n, :val(1)); } 
    140 for 5..8 -> my $n { $u.add($n, :val(2)); } 
    141 # test redundant adds 
    142 for 1..2 -> my $n { $u.add($n, :val(1)); } 
    143 for 5..8 -> my $n { $u.add($n, :val(2)); } 
    144 for 1..2 -> my $n { 
     139for 1..2 -> $n { $u.add($n, :val(1)); } 
     140for 5..8 -> $n { $u.add($n, :val(2)); } 
     141# test redundant adds 
     142for 1..2 -> $n { $u.add($n, :val(1)); } 
     143for 5..8 -> $n { $u.add($n, :val(2)); } 
     144for 1..2 -> $n { 
    145145    is $u.get($n), 1, "(add) .get finds 1 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    146146} 
    147 for 5..8 -> my $n { 
     147for 5..8 -> $n { 
    148148    is $u.get($n), 2, "(add) .get finds 2 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    149149} 
    150 for -2..0, 3..4, 9..11 -> my $n { 
     150for -2..0, 3..4, 9..11 -> $n { 
    151151    is $u.get($n), undef, "(add) .get returns undef for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    152152} 
     
    156156 
    157157$u = Utable.new; 
    158 for 8, 7, 6, 5 -> my $n { $u.add($n, :val(2)); } 
    159 for 2, 1 -> my $n { $u.add($n, :val(1)); } 
    160 # test redundant adds 
    161 for 1..2 -> my $n { $u.add($n, :val(1)); } 
    162 for 5..8 -> my $n { $u.add($n, :val(2)); } 
    163 for 1..2 -> my $n { 
     158for 8, 7, 6, 5 -> $n { $u.add($n, :val(2)); } 
     159for 2, 1 -> $n { $u.add($n, :val(1)); } 
     160# test redundant adds 
     161for 1..2 -> $n { $u.add($n, :val(1)); } 
     162for 5..8 -> $n { $u.add($n, :val(2)); } 
     163for 1..2 -> $n { 
    164164    is $u.get($n), 1, "(backwards add) .get finds 1 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    165165} 
    166 for 5..8 -> my $n { 
     166for 5..8 -> $n { 
    167167    is $u.get($n), 2, "(backwards add) .get finds 2 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    168168} 
    169 for -2..0, 3..4, 9..11 -> my $n { 
     169for -2..0, 3..4, 9..11 -> $n { 
    170170    is $u.get($n), undef, "(backwards add) .get returns undef for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    171171} 
     
    175175 
    176176$u = Utable.new; 
    177 for 2, 1 -> my $n { $u.add($n, :val(1)); } 
    178 for 5, 8, 6, 7 -> my $n { $u.add($n, :val(2)); } 
    179 # test redundant adds 
    180 for 1..2 -> my $n { $u.add($n, :val(1)); } 
    181 for 5..8 -> my $n { $u.add($n, :val(2)); } 
    182 for 1..2 -> my $n { 
     177for 2, 1 -> $n { $u.add($n, :val(1)); } 
     178for 5, 8, 6, 7 -> $n { $u.add($n, :val(2)); } 
     179# test redundant adds 
     180for 1..2 -> $n { $u.add($n, :val(1)); } 
     181for 5..8 -> $n { $u.add($n, :val(2)); } 
     182for 1..2 -> $n { 
    183183    is $u.get($n), 1, "(random add) .get finds 1 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    184184} 
    185 for 5..8 -> my $n { 
     185for 5..8 -> $n { 
    186186    is $u.get($n), 2, "(random add) .get finds 2 for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    187187} 
    188 for -2..0, 3..4, 9..11 -> my $n { 
     188for -2..0, 3..4, 9..11 -> $n { 
    189189    is $u.get($n), undef, "(random add) .get returns undef for $n in @@( 1..2 ; 5..8 ), (1, 2)"; 
    190190} 
     
    202202my %h; 
    203203for ^1000 { 
    204     my $n = rand 0..$unicode_max while %h{$n}; 
    205     my $val = rand 1..2; 
     204    my $n = (0..$unicode_max).pick while %h{$n}; 
     205    my $val = (1..2).pick; 
    206206    $u.add($n, :$val); 
    207207    %h{$n} = $val; 
    208208} 
    209 for %h.keys -> my $n { 
     209for %h.keys -> $n { 
    210210    is $u.get($n), %h{$n}, 'rand lookup succeeds'; 
    211211}