Skip to content

Commit 90af916

Browse files
first commit
1 parent 02f298b commit 90af916

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

nautilus-api/test/ExecutionTests/ControlFlowFunctions.hpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace nautilus::engine {
1111
return iw + 42;
1212
}
1313

14-
val<int32_t> ifThenElseCondition() {
15-
val<int32_t> value = val<int32_t>(1);
14+
val<int32_t> ifThenElseCondition(val<int32_t> value) {
1615
val<int32_t> iw = val<int32_t>(1);
1716
if (value == 42) {
1817
iw = iw + 1;
@@ -22,9 +21,7 @@ namespace nautilus::engine {
2221
return iw + 42;
2322
}
2423

25-
val<int32_t> nestedIfThenElseCondition() {
26-
val<int32_t> value = val<int32_t>(1);
27-
val<int32_t> iw = val<int32_t>(1);
24+
val<int32_t> nestedIfThenElseCondition(val<int32_t> value, val<int32_t> iw) {
2825
if (value == 42) {
2926
} else {
3027
if (iw == 8) {
@@ -36,9 +33,7 @@ namespace nautilus::engine {
3633
}
3734

3835

39-
val<int32_t> nestedIfNoElseCondition() {
40-
val<int32_t> value = val<int32_t>(1);
41-
val<int32_t> iw = val<int32_t>(1);
36+
val<int32_t> nestedIfNoElseCondition(val<int32_t> value, val<int32_t> iw) {
4237
if (value == 42) {
4338
iw = iw + 4;
4439
} else {

nautilus-api/test/ExecutionTests/Executions.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <catch2/catch_all.hpp>
2-
#include <engine/engine.hpp>
2+
#include "engine/engine.hpp"
33
#include "ExpressionFunctions.hpp"
44
#include "ControlFlowFunctions.hpp"
55
#include "LoopFunctions.hpp"
@@ -41,8 +41,7 @@ namespace nautilus::engine {
4141
REQUIRE(f((int8_t) 7) == 14);
4242
REQUIRE(f((int8_t) -7) == 0);
4343
REQUIRE(f((int8_t) -14) == -7);
44-
}
45-
SECTION("castInt8ToInt64Test2") {
44+
}SECTION("castInt8ToInt64Test2") {
4645
auto f = engine.registerFunction(castInt8ToInt64AddExpression2);
4746
REQUIRE(f((int8_t) 8) == 50);
4847
REQUIRE(f((int8_t) -2) == 40);
@@ -56,23 +55,29 @@ namespace nautilus::engine {
5655
REQUIRE(f(1) == 43);
5756
}SECTION("ifThenElseConditionTest") {
5857
auto f = engine.registerFunction(ifThenElseCondition);
59-
REQUIRE(f() == 85);
58+
REQUIRE(f(1) == 85);
59+
REQUIRE(f(42) == 44);
6060
}SECTION("nestedIfThenElseCondition") {
6161
auto f = engine.registerFunction(nestedIfThenElseCondition);
62-
REQUIRE(f() == 5);
62+
REQUIRE(f(1, 1) == 5);
63+
REQUIRE(f(42, 1) == 3);
64+
REQUIRE(f(1, 8) == 10);
6365
}SECTION("nestedIfNoElseCondition") {
6466
auto f = engine.registerFunction(nestedIfNoElseCondition);
65-
REQUIRE(f() == 12);
66-
}SECTION("andFunction") {
67-
auto f = engine.registerFunction(andFunction);
68-
REQUIRE(f(42) == true);
69-
REQUIRE(f(1) == false);
67+
REQUIRE(f(1, 1) == 12);
68+
REQUIRE(f(42, 1) == 7);
69+
REQUIRE(f(42, 10) == 16);
70+
REQUIRE(f(1, -1) == 10);
7071
} SECTION("deeplyNestedIfElseIfCondition") {
7172
auto f = engine.registerFunction(deeplyNestedIfElseIfCondition);
7273
REQUIRE(f() == 17);
7374
}SECTION("deeplyNestedIfElseCondition") {
7475
auto f = engine.registerFunction(deeplyNestedIfElseCondition);
7576
REQUIRE(f() == 12);
77+
}SECTION("andFunction") {
78+
auto f = engine.registerFunction(andFunction);
79+
REQUIRE(f(42) == true);
80+
REQUIRE(f(1) == false);
7681
}SECTION("andCondition") {
7782
auto f = engine.registerFunction(andCondition);
7883
REQUIRE(f(42, 42) == 1);

0 commit comments

Comments
 (0)