Skip to content

Commit

Permalink
Add closure test
Browse files Browse the repository at this point in the history
  • Loading branch information
asynchroza committed Nov 15, 2023
1 parent 6e2c16f commit c775a91
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions nulascript/tests/eval_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <string>
#include <type_traits>

// #define MULTILINE_STRING(s) #s
#define MULTILINE_STRING(s) #s

Storage* getEvaluatedStorage(std::string input) {
Lexer l(input);
Expand Down Expand Up @@ -107,8 +107,18 @@ TEST(EvalSuite, TestFunction) {
std::string expected;
};

std::vector<Test> tests = {
{"let something = fn(x) {x;}; something(69);", "69"}};
std::vector<Test> tests = {{
// clang-format off
MULTILINE_STRING(
let something = fn(a) {
fn(b) { a == b };
};

let result = something(10);
result(10);
), "true"
// clang-format on
}};

for (auto test : tests) {
auto result = getEvaluatedStorage(test.input);
Expand Down

0 comments on commit c775a91

Please sign in to comment.