| 1 | const t = [30, 38, 36, 31, 39, 37, 24, 32, 25, 33, 18, 26, 11, 18, 12, 4, 10, 17, 16, 11, 3, 9, |
| 2 | 2, 23, 30, 24, 16, 22, 23, 17, 9, 15, 10, 2, 8, 3, 1, 0, 7, 14, 29, 21] |
| 3 | |
| 4 | fn test_multiple_iterations_of_calling_clear_should_be_always_equivalent_to_assigning_a_new_map() { |
| 5 | println('array t len: ${t.len}, t: ${t}') |
| 6 | mut clr := map[int]int{} |
| 7 | for i in 0 .. 0xFFFF { |
| 8 | mut new := map[int]int{} |
| 9 | clr.clear() |
| 10 | for e in t { |
| 11 | new[e] = e |
| 12 | clr[e] = e |
| 13 | assert new.len == clr.len // , 'mismatch found after setting element: ${e}, on iteration ${i}' |
| 14 | } |
| 15 | if i & 0x3FFF == 0 { |
| 16 | println('index ${i}') |
| 17 | println('>> map new: ${new.len} | ${new.keys().sorted()}') |
| 18 | println('>> map cleared: ${clr.len} | ${clr.keys().sorted()}') |
| 19 | } |
| 20 | assert new == clr // , 'mismatch found for iteration: ${i}' |
| 21 | } |
| 22 | } |
| 23 | |