utimeq_stable.py 482 B

12345678910111213141516171819202122
  1. try:
  2. from utimeq import utimeq
  3. except ImportError:
  4. print("SKIP")
  5. raise SystemExit
  6. h = utimeq(10)
  7. # Check that for 2 same-key items, the queue is stable (pops items
  8. # in the same order they were pushed). Unfortunately, this no longer
  9. # holds for more same-key values, as the underlying heap structure
  10. # is not stable itself.
  11. h.push(100, 20, 0)
  12. h.push(100, 10, 0)
  13. res = [0, 0, 0]
  14. h.pop(res)
  15. assert res == [100, 20, 0]
  16. h.pop(res)
  17. assert res == [100, 10, 0]
  18. print("OK")