#include "include/test.hpp" #include "../src/include/execute.hpp" #include "../src/include/utils.hpp" EvalResult execute(string s, Memory& memory) { return execute(split_string(s, '\n'), memory); } int main() { _TEST_PRESENTATION("Repl"); Memory mem1; _TEST_ASSERT( _TEST_NO_EXCEPTION(get(execute("int x = 1;", mem1)) == 1), "Déclaration d'une variable globale", false ); _TEST_ASSERT( _TEST_NO_EXCEPTION(get(execute("x;", mem1)) == 1), "Persistance de variable", true ); Memory mem2; _TEST_ASSERT( _TEST_IS_EXCEPTION(execute("{ int x = 1; 1 / 0; }", mem2), ErrorType::DivisionByZero), "Déclaration d'une scope avec erreur au runtime", false ); _TEST_ASSERT( _TEST_IS_EXCEPTION(execute("x;", mem2), ErrorType::UnknownIdentifier), "Destruction des scopes en cas d'erreur", true ); return 0; }