feat: add ascii and newline prints

fix(Evaluator): issue over variable reducing priority
This commit is contained in:
Matthieu Bessat 2022-05-15 22:40:20 +02:00
parent 738d16f2fc
commit c3af6bd5ca
10 changed files with 114 additions and 21 deletions

View file

@ -141,4 +141,26 @@ void test_evaluation()
evaluate(state, "5.3 % 10", &resVal, &resType);
assert(resType == TYPE_FLOAT);
assert(float_almost_equal(5.3, get_float_from_int_rep(resVal)));
int ex = 43;
var_store_set(state->varStore, "var", TYPE_INT, (void*) &ex);
evaluate(state, "var", &resVal, &resType);
assert(resType == TYPE_INT);
assert(43 == resVal);
evaluate(state, "var < 52", &resVal, &resType);
assert(resType == TYPE_INT);
assert(1 == resVal);
evaluate(state, "var < (52-2)", &resVal, &resType);
assert(resType == TYPE_INT);
assert(1 == resVal);
int ex2 = 3;
var_store_set(state->varStore, "var2", TYPE_INT, (void*) &ex2);
evaluate(state, "abs((var2^2)-((var-41)^2))+2", &resVal, &resType);
assert(resType == TYPE_INT);
printf("actually got: %d \n", resVal);
assert(7 == resVal);
}