Commit ee53364dbbaa8d5bb56e95604501f0f4418a766f

  • avatar
  • Duke Leto <jonathan @le…o.net>
  • Sun Jan 24 22:55:37 CET 2010
Add tests for %hash.values
t/03-util.t
(17 / 1)
  
1717}
1818
1919sub run_tests () {
20 plan(42);
20 plan(46);
2121
2222 test_hash_exists();
2323 test_hash_keys();
24 test_hash_values();
2425 test_hash_kv();
2526
2627 test_set_from_array();
4040
4141 ok( %opt.exists('foobar'), 'exists works for existing keys');
4242 nok(%opt.exists('zanzibar'), 'exists works for non-existent keys');
43}
44
45sub test_hash_values() {
46 my %hash;
47 my @values := %hash.values;
48
49 is(@values, 0, 'values on empty hash is empty');
50 %hash<GreatJob> := 42;
51
52 @values := %hash.values;
53 is(@values, 1, 'values on hash with one entry has one element');
54 is(@values[0], 42, '... and that element is correct');
55
56 %hash<pigdog> := 99;
57 is( %hash.values, 2, 'values on hash with two entries has two elements');
4358}
4459
4560sub test_hash_keys() {