Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ScriptingTests.cpp
Go to the documentation of this file.
2
4
5namespace Divide
6{
7
8TEST_CASE("Simple Inline Script Test", "[scripting]")
9{
11
12 Script input("5.3 + 2.1");
13 constexpr D64 result = 7.4;
14
15 CHECK_COMPARE(input.eval<double>(), result);
16}
17
18TEST_CASE( "External Function Script Test", "[scripting]" )
19{
21
22 Script input
23 (R"(
24 use("utility.chai");
25 var my_fun = fun(x)
26 {
27 return x + 2;
28 };
29
30 something(my_fun)
31 )");
32
33 I32 variable = 0;
34 const auto testFunc = [&variable](const DELEGATE_STD<I32, I32>& t_func) {
35 variable = t_func(variable);
36 };
37
38 input.registerFunction(testFunc, "something");
39 input.eval<void>();
40 CHECK_EQUAL(variable, 2);
41}
42
43} //namespace Divide
void registerFunction(const Func &function, const char *functionName)
Definition: Script.inl:59
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::function< Ret(Args...) > DELEGATE_STD
int32_t I32
double D64
TEST_CASE("ByteBuffer RW Bool", "[byte_buffer]")
#define CHECK_COMPARE(LHS, RHS)
#define CHECK_EQUAL(LHS, RHS)