More tests
This commit is contained in:
parent
a57b759af9
commit
5bed6a303c
@ -29,4 +29,6 @@ public:
|
||||
*/
|
||||
EvalResult eval(Node &ast);
|
||||
|
||||
void _debug_flush_memory(void);
|
||||
|
||||
#endif
|
@ -8,6 +8,10 @@ using namespace std;
|
||||
|
||||
unordered_map<string, MemoryEntry> memory;
|
||||
|
||||
void _debug_flush_memory(void) {
|
||||
memory.clear();
|
||||
}
|
||||
|
||||
EvalResult eval(Node &ast) {
|
||||
if (ast.index() == 0) {
|
||||
InnerNode node = get<InnerNode>(ast);
|
||||
|
@ -33,5 +33,17 @@ int main() {
|
||||
true
|
||||
);
|
||||
|
||||
_TEST_ASSERT(
|
||||
_TEST_IS_EXCEPTION(execute("1 / (5 - 5);"), RuntimeError),
|
||||
"Division par 0",
|
||||
true
|
||||
);
|
||||
|
||||
_TEST_ASSERT(
|
||||
_TEST_IS_EXCEPTION(execute("1 % (5 - 5);"), RuntimeError),
|
||||
"Modulo par 0",
|
||||
true
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,10 +1,6 @@
|
||||
#ifndef DEF_TEST_H
|
||||
#define DEF_TEST_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../src/include/colors.h"
|
||||
|
||||
#define _TEST_PRESENTATION(description) { printf("\n" BLUE "#### %s:" BOLD "%s" RESET BLUE " #####" RESET "\n", __FILE__, description); }
|
||||
|
@ -9,6 +9,8 @@ int execute(string s) {
|
||||
Node ast = parse(tokens);
|
||||
EvalResult res = eval(ast);
|
||||
|
||||
_debug_flush_memory();
|
||||
|
||||
return get<int>(res);
|
||||
}
|
||||
|
||||
@ -45,5 +47,11 @@ int main() {
|
||||
true
|
||||
);
|
||||
|
||||
_TEST_ASSERT(
|
||||
_TEST_IS_EXCEPTION(execute("1 + x;"), RuntimeError),
|
||||
"Identifieur indéfini",
|
||||
true
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user