-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner.cpp
More file actions
37 lines (32 loc) · 997 Bytes
/
test_runner.cpp
File metadata and controls
37 lines (32 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <jaiscript/jaiscript.hpp>
#include <jaiscript/stdlib/stdlib.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <script.jai>" << std::endl;
return 1;
}
// Read script file
std::ifstream file(argv[1]);
if (!file) {
std::cerr << "Failed to open file: " << argv[1] << std::endl;
return 1;
}
std::stringstream buffer;
buffer << file.rdbuf();
std::string script = buffer.str();
// Create engine
auto eng = jai::engine::make();
jai::stdlib::register_all(*eng);
try {
auto result = eng->execute(script);
std::cout << "Result: " << result.to_string() << std::endl;
std::cout << "Result type: " << static_cast<int>(result.type()) << std::endl;
return 0;
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
}