MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / TEST

Function TEST

Engine/source/console/test/ScriptTest.cpp:38–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38TEST(Script, Basic_Arithmetic)
39{
40 ConsoleValue add = RunScript(R"(
41 return 1.0 + 1;
42 )");
43
44 ASSERT_EQ(add.getInt(), 2);
45
46 ConsoleValue sub = RunScript(R"(
47 return 10 - 1.0;
48 )");
49
50 ASSERT_EQ(sub.getInt(), 9);
51
52 ConsoleValue mult = RunScript(R"(
53 return 10 * 2.5;
54 )");
55
56 ASSERT_EQ(mult.getInt(), 25);
57
58 ConsoleValue div = RunScript(R"(
59 return 10.0 / 2;
60 )");
61
62 ASSERT_EQ(div.getInt(), 5);
63
64 ConsoleValue mod = RunScript(R"(
65 return 4 % 5;
66 )");
67
68 ASSERT_EQ(mod.getInt(), 4);
69
70 ConsoleValue add2 = RunScript(R"(
71 $a = 0;
72 $a += 2;
73 return $a;
74 )");
75
76 ASSERT_EQ(add2.getInt(), 2);
77
78 ConsoleValue sub2 = RunScript(R"(
79 $a = 0;
80 $a -= 2;
81 return $a;
82 )");
83
84 ASSERT_EQ(sub2.getInt(), -2);
85
86 ConsoleValue mult2 = RunScript(R"(
87 $a = 2;
88 $a *= 3;
89 return $a;
90 )");
91
92 ASSERT_EQ(mult2.getInt(), 6);
93
94 ConsoleValue div2 = RunScript(R"(
95 $a = 10;

Callers

nothing calls this directly

Calls 9

RunScriptFunction · 0.85
getIdMethod · 0.65
findObjectFunction · 0.50
getIntMethod · 0.45
getStringMethod · 0.45
sizeMethod · 0.45
deleteObjectMethod · 0.45
getFloatMethod · 0.45
getBoolMethod · 0.45

Tested by

no test coverage detected