feat: add basic math and random_int funcs
This commit is contained in:
parent
a62dd411aa
commit
cb2a1df61f
5 changed files with 149 additions and 18 deletions
|
|
@ -57,4 +57,16 @@ void test_evaluation()
|
|||
evaluate("(abs((0-1)*2)) + abs(2)", &resVal, &resType);
|
||||
assert(resType == TYPE_INT);
|
||||
assert(4 == resVal);
|
||||
}
|
||||
|
||||
evaluate("exp(2)-1", &resVal, &resType);
|
||||
assert(resType == TYPE_FLOAT);
|
||||
assert(float_almost_equal(6.389, get_float_from_int_rep(resVal)));
|
||||
|
||||
evaluate("(cos(2)^2)+(sin(2)^2)", &resVal, &resType);
|
||||
assert(resType == TYPE_FLOAT);
|
||||
assert(float_almost_equal(1, get_float_from_int_rep(resVal)));
|
||||
|
||||
evaluate("random_int(1, 100)", &resVal, &resType);
|
||||
assert(resType == TYPE_INT);
|
||||
printf(" - random int: %d \n", resVal);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue