diff options
author | Raymond Hettinger <python@rcn.com> | 2016-09-08 21:40:36 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-09-08 21:40:36 (GMT) |
commit | 262b6793e04993cb88847a3fb8dab22848cf6647 (patch) | |
tree | 7b985de4d19e233277cfbd767eb71b11034429e9 /Lib | |
parent | 5dc504c3c937a160c6d09bb124df5298712a1839 (diff) | |
download | cpython-262b6793e04993cb88847a3fb8dab22848cf6647.zip cpython-262b6793e04993cb88847a3fb8dab22848cf6647.tar.gz cpython-262b6793e04993cb88847a3fb8dab22848cf6647.tar.bz2 |
Issue #26020: Fix evaluation order for set literals
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_set.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index 1a49edf..7594303 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -388,6 +388,21 @@ class TestSet(TestJointOps, unittest.TestCase): t = {1,2,3} self.assertEqual(s, t) + def test_set_literal_insertion_order(self): + # SF Issue #26020 -- Expect left to right insertion + s = {1, 1.0, True} + self.assertEqual(len(s), 1) + stored_value = s.pop() + self.assertEqual(type(stored_value), int) + + def test_set_literal_evaluation_order(self): + # Expect left to right expression evaluation + events = [] + def record(obj): + events.append(obj) + s = {record(1), record(2), record(3)} + self.assertEqual(events, [1, 2, 3]) + def test_hash(self): self.assertRaises(TypeError, hash, self.s) |