@@ -243,8 +243,9 @@ def test_build_list_unpack_seq(self):
243243 Instr ('STORE_NAME' , 'x' ),
244244 Instr ('STORE_NAME' , 'y' )])
245245 self .check (code ,
246- Instr ('LOAD_NAME' , 'b' ),
247246 Instr ('LOAD_NAME' , 'a' ),
247+ Instr ('LOAD_NAME' , 'b' ),
248+ Instr ('ROT_TWO' ),
248249 Instr ('STORE_NAME' , 'x' ),
249250 Instr ('STORE_NAME' , 'y' ))
250251
@@ -258,13 +259,47 @@ def test_build_list_unpack_seq(self):
258259 Instr ('STORE_NAME' , 'y' ),
259260 Instr ('STORE_NAME' , 'z' )])
260261 self .check (code ,
261- Instr ('LOAD_NAME' , 'c' ),
262- Instr ('LOAD_NAME' , 'b' ),
263262 Instr ('LOAD_NAME' , 'a' ),
263+ Instr ('LOAD_NAME' , 'b' ),
264+ Instr ('LOAD_NAME' , 'c' ),
265+ Instr ('ROT_THREE' ),
266+ Instr ('ROT_TWO' ),
264267 Instr ('STORE_NAME' , 'x' ),
265268 Instr ('STORE_NAME' , 'y' ),
266269 Instr ('STORE_NAME' , 'z' ))
267270
271+ def test_build_tuple_unpack_seq_const (self ):
272+ # x, y = (3, 4)
273+ code = Bytecode ([Instr ('LOAD_CONST' , 3 ),
274+ Instr ('LOAD_CONST' , 4 ),
275+ Instr ('BUILD_TUPLE' , 2 ),
276+ Instr ('UNPACK_SEQUENCE' , 2 ),
277+ Instr ('STORE_NAME' , 'x' ),
278+ Instr ('STORE_NAME' , 'y' )])
279+ self .check (code ,
280+ Instr ('LOAD_CONST' , (3 , 4 )),
281+ Instr ('UNPACK_SEQUENCE' , 2 ),
282+ Instr ('STORE_NAME' , 'x' ),
283+ Instr ('STORE_NAME' , 'y' ))
284+
285+ def test_build_list_unpack_seq_const (self ):
286+ # x, y, z = [3, 4, 5]
287+ code = Bytecode ([Instr ('LOAD_CONST' , 3 ),
288+ Instr ('LOAD_CONST' , 4 ),
289+ Instr ('LOAD_CONST' , 5 ),
290+ Instr ('BUILD_LIST' , 3 ),
291+ Instr ('UNPACK_SEQUENCE' , 3 ),
292+ Instr ('STORE_NAME' , 'x' ),
293+ Instr ('STORE_NAME' , 'y' ),
294+ Instr ('STORE_NAME' , 'z' )])
295+ self .check (code ,
296+ Instr ('LOAD_CONST' , 5 ),
297+ Instr ('LOAD_CONST' , 4 ),
298+ Instr ('LOAD_CONST' , 3 ),
299+ Instr ('STORE_NAME' , 'x' ),
300+ Instr ('STORE_NAME' , 'y' ),
301+ Instr ('STORE_NAME' , 'z' ))
302+
268303 def test_build_set (self ):
269304 # test = x in {1, 2, 3}
270305 code = Bytecode ([Instr ('LOAD_NAME' , 'x' ),
0 commit comments