1212#include < scratchcpp/script.h>
1313#include < scratchcpp/thread.h>
1414#include < scratchcpp/scratchconfiguration.h>
15+ #include < scratchcpp/compiler.h>
16+ #include < scratchcpp/compilerconstant.h>
1517#include < scratch/sound_p.h>
1618#include < timermock.h>
1719#include < clockmock.h>
@@ -189,7 +191,7 @@ TEST(EngineTest, StopSignal)
189191 }
190192}
191193
192- /* TEST(EngineTest, CompileAndExecuteMonitors)
194+ TEST (EngineTest, CompileAndExecuteMonitors)
193195{
194196 Engine engine;
195197 auto stage = std::make_shared<Stage>();
@@ -209,8 +211,8 @@ TEST(EngineTest, StopSignal)
209211 EXPECT_CALL (*extension, onInit);
210212 ScratchConfiguration::registerExtension (extension);
211213 engine.setExtensions ({ " MonitorTest" });
212- engine.addCompileFunction(extension.get(), m1->opcode(), [](Compiler *compiler) { compiler->addConstValue(5.4); });
213- engine.addCompileFunction(extension.get(), m2->opcode(), [](Compiler *compiler) { compiler->addConstValue("test"); });
214+ engine.addCompileFunction (extension.get (), m1->opcode (), [](Compiler *compiler) -> CompilerValue * { return compiler->addConstValue (5.4 ); });
215+ engine.addCompileFunction (extension.get (), m2->opcode (), [](Compiler *compiler) -> CompilerValue * { return compiler->addConstValue (" test" ); });
214216
215217 engine.addMonitorNameFunction (extension.get (), m1->opcode (), [](Block *block) -> const std::string & {
216218 static const std::string testStr = " test" ;
@@ -229,11 +231,9 @@ TEST(EngineTest, StopSignal)
229231 auto script3 = m3->script ();
230232 ASSERT_TRUE (script1 && script2 && !script3);
231233
232- ASSERT_EQ(script1->bytecodeVector(), std::vector<unsigned int>({ vm::OP_START, vm::OP_CONST, 0, vm::OP_EXEC, 0, vm::OP_HALT }));
233234 ASSERT_EQ (script1->target (), stage.get ());
234235 ASSERT_EQ (script1->topBlock (), m1->block ());
235236
236- ASSERT_EQ(script2->bytecodeVector(), std::vector<unsigned int>({ vm::OP_START, vm::OP_CONST, 0, vm::OP_EXEC, 0, vm::OP_HALT }));
237237 ASSERT_EQ (script2->target (), sprite.get ());
238238 ASSERT_EQ (script2->topBlock (), m2->block ());
239239
@@ -255,27 +255,23 @@ TEST(EngineTest, StopSignal)
255255 m3->setInterface (&iface3);
256256
257257 EXPECT_CALL (iface1, onValueChanged).Times (0 );
258- EXPECT_CALL(iface2, onValueChanged(_)).WillOnce(WithArgs<0>(Invoke([](const VirtualMachine *vm) {
259- ASSERT_EQ(vm->registerCount(), 1);
260- ASSERT_EQ(vm->getInput(0, 1)->toString(), "test");
261- ASSERT_FALSE(vm->atEnd()); // the script shouldn't end because that would spam the console with leak warnings
262- })));
258+ EXPECT_CALL (iface2, onValueChanged (_)).WillOnce (WithArgs<0 >(Invoke ([](const Value &value) { ASSERT_EQ (value.toString (), " test" ); })));
263259 EXPECT_CALL (iface3, onValueChanged).Times (0 );
264260 engine.updateMonitors ();
265261
266262 // Change the monitor values
267- testing::internal::CaptureStdout();
263+ /* testing::internal::CaptureStdout();
268264 EXPECT_CALL(iface1, onValueChanged);
269265 m1->changeValue(0);
270266 ASSERT_EQ(testing::internal::GetCapturedStdout(), "change 1!\n");
271267
272268 testing::internal::CaptureStdout();
273269 EXPECT_CALL(iface2, onValueChanged);
274270 m2->changeValue(0);
275- ASSERT_EQ(testing::internal::GetCapturedStdout(), "change 2!\n");
271+ ASSERT_EQ(testing::internal::GetCapturedStdout(), "change 2!\n");*/
276272
277273 ScratchConfiguration::removeExtension (extension);
278- }*/
274+ }
279275
280276TEST (EngineTest, IsRunning)
281277{
0 commit comments