Commit ee53364dbbaa8d5bb56e95604501f0f4418a766f
- Diff rendering mode:
- inline
- side by side
t/03-util.t
(17 / 1)
|   | |||
| 17 | 17 | } | |
| 18 | 18 | ||
| 19 | 19 | sub run_tests () { | |
| 20 | plan(42); | ||
| 20 | plan(46); | ||
| 21 | 21 | ||
| 22 | 22 | test_hash_exists(); | |
| 23 | 23 | test_hash_keys(); | |
| 24 | test_hash_values(); | ||
| 24 | 25 | test_hash_kv(); | |
| 25 | 26 | ||
| 26 | 27 | test_set_from_array(); | |
| … | … | ||
| 40 | 40 | ||
| 41 | 41 | ok( %opt.exists('foobar'), 'exists works for existing keys'); | |
| 42 | 42 | nok(%opt.exists('zanzibar'), 'exists works for non-existent keys'); | |
| 43 | } | ||
| 44 | |||
| 45 | sub 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'); | ||
| 43 | 58 | } | |
| 44 | 59 | ||
| 45 | 60 | sub test_hash_keys() { |

