Skip to content

Commit bf3bded

Browse files
committed
Move conditionReturnValue variable to src file in block tests
1 parent 82ec9a6 commit bf3bded

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

test/blocks/control_blocks_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ TEST_F(ControlBlocksTest, WaitUntil)
462462
builder.addObscuredInput("CONDITION", block);
463463
builder.build();
464464

465-
conditionReturnValue = false;
465+
setConditionReturnValue(false);
466466
m_engine->start();
467467

468468
m_engine->step();
@@ -471,7 +471,7 @@ TEST_F(ControlBlocksTest, WaitUntil)
471471
m_engine->step();
472472
ASSERT_TRUE(m_engine->isRunning());
473473

474-
conditionReturnValue = true;
474+
setConditionReturnValue(true);
475475
m_engine->step();
476476
m_engine->step();
477477
ASSERT_FALSE(m_engine->isRunning());
@@ -533,15 +533,15 @@ TEST_F(ControlBlocksTest, RepeatUntil)
533533
builder.addObscuredInput("CONDITION", block);
534534
builder.build();
535535

536-
conditionReturnValue = false;
536+
setConditionReturnValue(false);
537537
m_engine->start();
538538

539539
testing::internal::CaptureStdout();
540540
m_engine->step();
541541
ASSERT_EQ(testing::internal::GetCapturedStdout().substr(0, 10), "test\ntest\n");
542542
ASSERT_TRUE(m_engine->isRunning());
543543

544-
conditionReturnValue = true;
544+
setConditionReturnValue(true);
545545
m_engine->step();
546546
m_engine->step();
547547
ASSERT_FALSE(m_engine->isRunning());
@@ -620,15 +620,15 @@ TEST_F(ControlBlocksTest, While)
620620
builder.addObscuredInput("CONDITION", block);
621621
builder.build();
622622

623-
conditionReturnValue = true;
623+
setConditionReturnValue(true);
624624
m_engine->start();
625625

626626
testing::internal::CaptureStdout();
627627
m_engine->step();
628628
ASSERT_EQ(testing::internal::GetCapturedStdout().substr(0, 10), "test\ntest\n");
629629
ASSERT_TRUE(m_engine->isRunning());
630630

631-
conditionReturnValue = false;
631+
setConditionReturnValue(false);
632632
m_engine->step();
633633
m_engine->step();
634634
ASSERT_FALSE(m_engine->isRunning());

test/blocks/util.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
namespace libscratchcpp
1616
{
1717

18+
static bool conditionReturnValue = false;
19+
1820
void registerBlocks(IEngine *engine, IExtension *extension)
1921
{
2022
engine->addCompileFunction(extension, "test_print", [](Compiler *compiler) -> CompilerValue * {
@@ -51,6 +53,11 @@ void registerBlocks(IEngine *engine, IExtension *extension)
5153
});
5254
}
5355

56+
void setConditionReturnValue(bool newValue)
57+
{
58+
conditionReturnValue = newValue;
59+
}
60+
5461
extern "C" void test_print(const StringPtr *str)
5562
{
5663
std::cout << utf8::utf16to8(std::u16string(str->data)) << std::endl;

test/blocks/util.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ namespace libscratchcpp
66
class IEngine;
77
class IExtension;
88

9-
bool conditionReturnValue = false;
10-
119
void registerBlocks(IEngine *engine, IExtension *extension);
10+
void setConditionReturnValue(bool newValue);
1211

1312
} // namespace libscratchcpp

0 commit comments

Comments
 (0)