c-repl/test/variables.cpp
2023-11-10 22:24:14 +01:00

23 lines
551 B
C++

#include "include/test.h"
#include "../src/include/tokenize.h"
#include "../src/include/parser.h"
#include "../src/include/interpreter.h"
int execute(string s) {
vector<Token> tokens = tokenize(s);
Node ast = parse(tokens);
EvalResult res = eval(ast);
return get<int>(res);
}
int main() {
_TEST_PRESENTATION("Variables");
_TEST_ASSERT(execute("int uneVariableFarfelue__ = 12;") == 12, "Déclaration avec assignement");
_TEST_ASSERT(execute("int x = 5; x + 3;") == 8, "Déclaration puis assignement");
return 0;
}