mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Add more issues and a forum thread
This commit is contained in:
parent
8e0dfe3a8a
commit
b3208f4066
@ -108,6 +108,33 @@ set c to ( a - 1 )
|
||||
set d to ( b * c )
|
||||
set e to ( d / a )
|
||||
|
||||
End)mwscript";
|
||||
|
||||
// https://forum.openmw.org/viewtopic.php?f=6&t=2262
|
||||
const std::string sScript4 = R"mwscript(Begin scripting_once_again
|
||||
|
||||
player -> addSpell "fire_bite", 645
|
||||
|
||||
PositionCell "Rabenfels, Taverne" 4480.000 3968.000 15820.000 0
|
||||
|
||||
End)mwscript";
|
||||
|
||||
const std::string sIssue1430 = R"mwscript(Begin issue1430
|
||||
|
||||
short var
|
||||
If ( menumode == 1 )
|
||||
Player->AddItem "fur_boots", 1
|
||||
Player->Equip "iron battle axe", 1
|
||||
player->addspell "fire bite", 645
|
||||
player->additem "ring_keley", 1,
|
||||
endif
|
||||
|
||||
End)mwscript";
|
||||
|
||||
const std::string sIssue1767 = R"mwscript(Begin issue1767
|
||||
|
||||
player->GetPcRank "temple"
|
||||
|
||||
End)mwscript";
|
||||
|
||||
const std::string sIssue3006 = R"mwscript(Begin issue3006
|
||||
@ -225,6 +252,18 @@ End)mwscript";
|
||||
|
||||
const std::string sIssue6282 = R"mwscript(Begin 11AA_LauraScript7.5
|
||||
|
||||
End)mwscript";
|
||||
|
||||
const std::string sIssue6363 = R"mwscript(Begin issue6363
|
||||
|
||||
short 1
|
||||
|
||||
if ( "1" == 1 )
|
||||
PositionCell 0 1 2 3 4 5 "Morrowland"
|
||||
endif
|
||||
|
||||
set 1 to 42
|
||||
|
||||
End)mwscript";
|
||||
|
||||
TEST_F(MWScriptTest, mwscript_test_invalid)
|
||||
@ -317,6 +356,24 @@ End)mwscript";
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MWScriptTest, mwscript_test_forum_thread)
|
||||
{
|
||||
registerExtensions();
|
||||
EXPECT_FALSE(!compile(sScript4));
|
||||
}
|
||||
|
||||
TEST_F(MWScriptTest, mwscript_test_1430)
|
||||
{
|
||||
registerExtensions();
|
||||
EXPECT_FALSE(!compile(sIssue1430));
|
||||
}
|
||||
|
||||
TEST_F(MWScriptTest, mwscript_test_1767)
|
||||
{
|
||||
registerExtensions();
|
||||
EXPECT_FALSE(!compile(sIssue1767));
|
||||
}
|
||||
|
||||
TEST_F(MWScriptTest, mwscript_test_3006)
|
||||
{
|
||||
if(auto script = compile(sIssue3006))
|
||||
@ -430,4 +487,37 @@ End)mwscript";
|
||||
{
|
||||
EXPECT_FALSE(!compile(sIssue6282));
|
||||
}
|
||||
|
||||
TEST_F(MWScriptTest, mwscript_test_6363)
|
||||
{
|
||||
registerExtensions();
|
||||
if(const auto script = compile(sIssue6363))
|
||||
{
|
||||
class PositionCell : public Interpreter::Opcode0
|
||||
{
|
||||
bool& mRan;
|
||||
public:
|
||||
PositionCell(bool& ran) : mRan(ran) {}
|
||||
|
||||
void execute(Interpreter::Runtime& runtime)
|
||||
{
|
||||
mRan = true;
|
||||
}
|
||||
};
|
||||
bool ran = false;
|
||||
installOpcode(Compiler::Transformation::opcodePositionCell, new PositionCell(ran));
|
||||
TestInterpreterContext context;
|
||||
context.setLocalShort(0, 0);
|
||||
run(*script, context);
|
||||
EXPECT_FALSE(ran);
|
||||
ran = false;
|
||||
context.setLocalShort(0, 1);
|
||||
run(*script, context);
|
||||
EXPECT_TRUE(ran);
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@
|
||||
#include <components/interpreter/interpreter.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TestCompilerContext : public Compiler::Context
|
||||
@ -28,7 +30,7 @@ namespace
|
||||
bool canDeclareLocals() const override { return true; }
|
||||
char getGlobalType(const std::string& name) const override { return ' '; }
|
||||
std::pair<char, bool> getMemberType(const std::string& name, const std::string& id) const override { return {' ', false}; }
|
||||
bool isId(const std::string& name) const override { return name == "player"; }
|
||||
bool isId(const std::string& name) const override { return Misc::StringUtils::ciEqual(name, "player"); }
|
||||
bool isJournalId(const std::string& name) const override { return false; }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user