diff options
author | Damien George <damien.p.george@gmail.com> | 2016-12-20 14:25:06 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-12-20 14:25:06 +1100 |
commit | 7bbce4e213c273d95b30519148bf41182b489247 (patch) | |
tree | 13a711d815baab6cdfac212bfa30a4850e6c79ae /tests | |
parent | b470f59892873c3f2f64519fef31a7d94d526427 (diff) | |
download | micropython-7bbce4e213c273d95b30519148bf41182b489247.tar.gz micropython-7bbce4e213c273d95b30519148bf41182b489247.zip |
tests/basics/set_pop: Improve coverage of set functions.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basics/set_pop.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/basics/set_pop.py b/tests/basics/set_pop.py index 0cd478ce25..5e1196c9f0 100644 --- a/tests/basics/set_pop.py +++ b/tests/basics/set_pop.py @@ -7,3 +7,12 @@ except KeyError: else: print("Failed to raise KeyError") +# this tests an optimisation in mp_set_remove_first +# N must not be equal to one of the values in hash_allocation_sizes +N = 11 +s = set(range(N)) +while s: + print(s.pop()) # last pop() should trigger the optimisation +for i in range(N): + s.add(i) # check that we can add the numbers back to the set +print(list(s)) |