@@ -105,6 +105,7 @@ TEST_F(SoundBlocksTest, RegisterBlocks)
105
105
EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_seteffectto" , &SoundBlocks::compileSetEffectTo));
106
106
EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_changeeffectby" , &SoundBlocks::compileChangeEffectBy));
107
107
EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_changevolumeby" , &SoundBlocks::compileChangeVolumeBy));
108
+ EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_cleareffects" , &SoundBlocks::compileClearEffects));
108
109
EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_setvolumeto" , &SoundBlocks::compileSetVolumeTo));
109
110
EXPECT_CALL (m_engineMock, addCompileFunction (m_section.get (), " sound_volume" , &SoundBlocks::compileVolume));
110
111
@@ -715,6 +716,40 @@ TEST_F(SoundBlocksTest, ChangeEffectByImpl)
715
716
ASSERT_EQ (vm.registerCount (), 0 );
716
717
}
717
718
719
+ TEST_F (SoundBlocksTest, ClearEffects)
720
+ {
721
+ Compiler compiler (&m_engineMock);
722
+
723
+ auto block = std::make_shared<Block>(" a" , " sound_cleareffects" );
724
+
725
+ EXPECT_CALL (m_engineMock, functionIndex (&SoundBlocks::clearEffects)).WillOnce (Return (0 ));
726
+
727
+ compiler.init ();
728
+ compiler.setBlock (block);
729
+ SoundBlocks::compileClearEffects (&compiler);
730
+ compiler.end ();
731
+
732
+ ASSERT_EQ (compiler.bytecode (), std::vector<unsigned int >({ vm::OP_START, vm::OP_EXEC, 0 , vm::OP_HALT }));
733
+ ASSERT_TRUE (compiler.constValues ().empty ());
734
+ }
735
+
736
+ TEST_F (SoundBlocksTest, ClearEffectsImpl)
737
+ {
738
+ static unsigned int bytecode[] = { vm::OP_START, vm::OP_EXEC, 0 , vm::OP_HALT };
739
+ static BlockFunc functions[] = { &SoundBlocks::clearEffects };
740
+
741
+ TargetMock target;
742
+ VirtualMachine vm (&target, nullptr , nullptr );
743
+
744
+ vm.setBytecode (bytecode);
745
+ vm.setFunctions (functions);
746
+
747
+ EXPECT_CALL (target, clearSoundEffects ());
748
+ vm.run ();
749
+
750
+ ASSERT_EQ (vm.registerCount (), 0 );
751
+ }
752
+
718
753
TEST_F (SoundBlocksTest, ChangeVolumeBy)
719
754
{
720
755
Compiler compiler (&m_engineMock);
0 commit comments