Changeset 21157

Show
Ignore:
Timestamp:
07/02/08 03:02:00 (3 months ago)
Author:
Auzon
Message:

[gsoc_spectest] Added tests for the little-mentioned reverse method on Hashes. (added 4 tests)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • t/spec/S29-list/reverse.t

    r20702 r21157  
    1010=end pod 
    1111 
    12 plan 45; 
     12plan 49; 
    1313 
    1414# As a function : 
     
    3232is( '䀻«'.reverse,   '«»€ä', "some unicode characters" ); 
    3333 
    34  
    35 # L<S29/"List"/"=item reverse"> 
    3634 
    3735=begin pod 
     
    151149    is(@b[0], (@b.reverse)[0], 'one item list is left alone'); 
    152150} 
     151 
     152=begin pod 
     153 
     154Tests for %hash.reverse, which inverts the keys and values of a hash. 
     155 
     156=end pod 
     157 
     158{ 
     159    my %hash = <a b c d>; 
     160    is(%hash.reverse, {'b' => 'a', 'd' => 'c'}, 'simple hash reversal'); 
     161    is(%hash, {'a' => 'b', 'c' => 'd'}, 'original hash is intact'); 
     162} 
     163 
     164{ 
     165    my %hash = reverse {0 => 'a', 1 => 'a'}; 
     166 
     167    is(%hash.keys, <a>, 'hash reversal with collision (unspecced, keys)'); 
     168    is(%hash.values.sort, <0 1>, 'hash reversal with collision (unspecced, values)'); 
     169}