46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
/**
|
|
* @author Edouard DUPIN
|
|
* @copyright 2017, Edouard DUPIN, all right reserved
|
|
* @license MPL-2 (see license file)
|
|
*/
|
|
#include <test-debug/debug.hpp>
|
|
#include <etest/etest.hpp>
|
|
#include "testInterface.hpp"
|
|
|
|
|
|
TEST(testVariableScope, solo_block_local) {
|
|
testInterface system;
|
|
bool ret = system.execute("variable result = true; { variable result = false; };");
|
|
EXPECT_EQ(ret, true);
|
|
EXPECT_EQ(system.exist("result"), true);
|
|
EXPECT_EQ(system.isBoolean("result"), true);
|
|
EXPECT_EQ(system.getBoolean("result"), true);
|
|
}
|
|
|
|
TEST(testVariableScope, solo_block_global) {
|
|
testInterface system;
|
|
bool ret = system.execute("variable result = true; { result = false; };");
|
|
EXPECT_EQ(ret, true);
|
|
EXPECT_EQ(system.exist("result"), true);
|
|
EXPECT_EQ(system.isBoolean("result"), true);
|
|
EXPECT_EQ(system.getBoolean("result"), false);
|
|
}
|
|
|
|
TEST(testVariableScope, function_block_global) {
|
|
testInterface system;
|
|
bool ret = system.execute("variable result = true; variable call = function () { result = false; }; call();");
|
|
EXPECT_EQ(ret, true);
|
|
EXPECT_EQ(system.exist("result"), true);
|
|
EXPECT_EQ(system.isBoolean("result"), true);
|
|
EXPECT_EQ(system.getBoolean("result"), false);
|
|
}
|
|
|
|
TEST(testVariableScope, function_block_local) {
|
|
testInterface system;
|
|
bool ret = system.execute("variable result = true; variable call = function () { variable result = false; }; call();");
|
|
EXPECT_EQ(ret, true);
|
|
EXPECT_EQ(system.exist("result"), true);
|
|
EXPECT_EQ(system.isBoolean("result"), true);
|
|
EXPECT_EQ(system.getBoolean("result"), true);
|
|
}
|