feat(Evaluator): add modulus operator
This commit is contained in:
parent
7700e61019
commit
738d16f2fc
9 changed files with 39 additions and 3 deletions
|
|
@ -8,9 +8,9 @@
|
|||
int main()
|
||||
{
|
||||
printf("== UNIT TESTS == \n");
|
||||
test_utils();
|
||||
test_var_store();
|
||||
test_stack();
|
||||
test_utils();
|
||||
test_evaluation();
|
||||
test_line_processing();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,4 +133,12 @@ void test_evaluation()
|
|||
evaluate(state, "5 > 0", &resVal, &resType);
|
||||
assert(resType == TYPE_INT);
|
||||
assert(1 == resVal);
|
||||
|
||||
evaluate(state, "5 % 10", &resVal, &resType);
|
||||
assert(resType == TYPE_INT);
|
||||
assert(5 == resVal);
|
||||
|
||||
evaluate(state, "5.3 % 10", &resVal, &resType);
|
||||
assert(resType == TYPE_FLOAT);
|
||||
assert(float_almost_equal(5.3, get_float_from_int_rep(resVal)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ void test_utils()
|
|||
assert(m_factorial(3) == 6);
|
||||
assert(m_factorial(4) == 2*3*4);
|
||||
|
||||
assert(float_almost_equal(2.22, m_float_modulus(2.22, 10)));
|
||||
assert(float_almost_equal(28.619, m_float_modulus(200.22, 34.32)));
|
||||
|
||||
assert(float_almost_equal(2.7182, m_exp(1.0)));
|
||||
assert(float_almost_equal(1, m_exp(0)));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue