1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-29 09:32:45 +00:00

Be sure to verify the opcode got executed

This commit is contained in:
Evil Eye 2021-10-27 22:08:41 +02:00
parent 6ad8549163
commit be759e576a

View File

@ -346,23 +346,28 @@ End)mwscript";
TEST_F(MWScriptTest, mwscript_test_function) TEST_F(MWScriptTest, mwscript_test_function)
{ {
registerExtensions(); registerExtensions();
bool failed = true;
if(auto script = compile(sScript2)) if(auto script = compile(sScript2))
{ {
class AddTopic : public Interpreter::Opcode0 class AddTopic : public Interpreter::Opcode0
{ {
bool& mFailed;
public: public:
AddTopic(bool& failed) : mFailed(failed) {}
void execute(Interpreter::Runtime& runtime) void execute(Interpreter::Runtime& runtime)
{ {
const auto topic = runtime.getStringLiteral(runtime[0].mInteger); const auto topic = runtime.getStringLiteral(runtime[0].mInteger);
runtime.pop(); runtime.pop();
mFailed = false;
EXPECT_EQ(topic, "OpenMW Unit Test"); EXPECT_EQ(topic, "OpenMW Unit Test");
} }
}; };
installOpcode(Compiler::Dialogue::opcodeAddTopic, new AddTopic); installOpcode(Compiler::Dialogue::opcodeAddTopic, new AddTopic(failed));
TestInterpreterContext context; TestInterpreterContext context;
run(*script, context); run(*script, context);
} }
else if(failed)
{ {
FAIL(); FAIL();
} }