mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
Issue #26020: Fix evaluation order for set literals
This commit is contained in:
parent
5dc504c3c9
commit
262b6793e0
3 changed files with 21 additions and 2 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue