@@ -237,24 +237,85 @@ def test_visitGotofrontback(self):
237
237
converted_block = visitBlock (context )
238
238
assert converted_block [0 ] == "comeToFront"
239
239
240
- def test_visitCostumenumbername (self ):
241
- context = create_block_context ("looks_costumenumbername" )
240
+ # def test_visitCostumenumbername(self):
241
+ # context = create_block_context("looks_costumenumbername")
242
+ # testblock = context.block
243
+ # addInputOfType(testblock, "CHANGE", TYPE_INT)
244
+ # testblock.fields["NUMBER_NAME"] = ["name"]
245
+ # testblock.fields["EFFECT"] = ["testeffect"]
246
+ # converted_block = visitBlock(context)
247
+ # assert converted_block[0] == "costumeName"
248
+ #
249
+ # testblock.fields["NUMBER_NAME"] = ["number"]
250
+ # converted_block = visitBlock(context)
251
+ # assert converted_block[0] == "costumeIndex"
252
+
253
+ def test_visitSize (self ):
254
+ context = create_block_context ("looks_size" )
255
+ converted_block = visitBlock (context )
256
+ assert converted_block [0 ] == "scale"
257
+
258
+
259
+
260
+
261
+
262
+ ######### Sound Blocks #########################################
263
+ def add_menu_block (self , context , opcode , menu_name , value ):
264
+ menu_block = add_new_block_to_context (context , opcode )
265
+ menu_block .fields [menu_name ] = [value ]
266
+ context .block .inputs [menu_name ] = [1 , menu_block .name ]
267
+
268
+ def test_visitPlay (self ):
269
+ context = create_block_context ("sound_play" )
242
270
testblock = context .block
243
- addInputOfType (testblock , "CHANGE" , TYPE_INT )
244
- testblock .fields ["NUMBER_NAME" ] = ["name" ]
245
- testblock .fields ["EFFECT" ] = ["testeffect" ]
271
+
272
+ block2 = add_new_block_to_context (context , "sound_sounds_menu" )
273
+ block2 .fields ["SOUND_MENU" ] = ["test_sound" ]
274
+ # addInputToBlock(testblock, "SOUND_MENU", block2.name, INPUTTYPE_BLOCK_NO_SHADOW)
275
+ testblock .inputs ["SOUND_MENU" ] = [1 , block2 .name ]
276
+
246
277
converted_block = visitBlock (context )
247
- assert converted_block [0 ] == "costumeName"
278
+ assert converted_block [0 ] == "playSound:"
279
+ assert converted_block [1 ] == "test_sound"
248
280
249
- testblock .fields ["NUMBER_NAME" ] = ["number" ]
281
+ def test_visitPlayuntildone (self ):
282
+ context = create_block_context ("sound_playuntildone" )
283
+ testblock = context .block
284
+ self .add_menu_block (context , "sound_sounds_menu" , "SOUND_MENU" , "test_sound" )
250
285
converted_block = visitBlock (context )
251
- assert converted_block [0 ] == "costumeIndex"
286
+ assert converted_block [0 ] == "doPlaySoundAndWait"
287
+ assert converted_block [1 ] == "test_sound"
252
288
253
- def test_visitSize (self ):
254
- context = create_block_context ("looks_size " )
289
+ def test_visitStopallsounds (self ):
290
+ context = create_block_context ("sound_stopallsounds " )
255
291
converted_block = visitBlock (context )
256
- assert converted_block [0 ] == "scale "
292
+ assert converted_block [0 ] == "stopAllSounds "
257
293
294
+ def test_visitClearsoundeffects (self ):
295
+ context = create_block_context ("sound_cleareffects" )
296
+ converted_block = visitBlock (context )
297
+ assert converted_block [0 ] == "clearSoundEffects"
298
+
299
+ def test_visitChangevolumeby (self ):
300
+ context = create_block_context ("sound_changevolumeby" )
301
+ testblock = context .block
302
+ addInputOfType (testblock , "VOLUME" , TYPE_INT )
303
+ converted_block = visitBlock (context )
304
+ assert converted_block [0 ] == "changeVolumeBy:"
305
+ assert converted_block [1 ] == 1234.0
306
+
307
+ def test_visitSetvolumeto (self ):
308
+ context = create_block_context ("sound_setvolumeto" )
309
+ testblock = context .block
310
+ addInputOfType (testblock , "VOLUME" , TYPE_INT )
311
+ converted_block = visitBlock (context )
312
+ assert converted_block [0 ] == "setVolumeTo:"
313
+ assert converted_block [1 ] == 1234.0
314
+
315
+ def test_visitVolume (self ):
316
+ context = create_block_context ("sound_volume" )
317
+ converted_block = visitBlock (context )
318
+ assert converted_block [0 ] == "volume"
258
319
259
320
260
321
if __name__ == "__main__" :
0 commit comments