summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/utimeq_stable.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/extmod/utimeq_stable.py')
-rw-r--r--tests/extmod/utimeq_stable.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/extmod/utimeq_stable.py b/tests/extmod/utimeq_stable.py
new file mode 100644
index 0000000000..9f6ba76d4a
--- /dev/null
+++ b/tests/extmod/utimeq_stable.py
@@ -0,0 +1,23 @@
+try:
+ from utimeq import utimeq
+except ImportError:
+ print("SKIP")
+ import sys
+ sys.exit()
+
+h = utimeq(10)
+
+# Check that for 2 same-key items, the queue is stable (pops items
+# in the same order they were pushed). Unfortunately, this no longer
+# holds for more same-key values, as the underlying heap structure
+# is not stable itself.
+h.push(100, 20, 0)
+h.push(100, 10, 0)
+
+res = [0, 0, 0]
+h.pop(res)
+assert res == [100, 20, 0]
+h.pop(res)
+assert res == [100, 10, 0]
+
+print("OK")