evalexpr/tests/tests.inc

33 lines
1.1 KiB
SQL

FAILURE(empty, "")
FAILURE(trailing_operator, "1 +")
FAILURE(trailing_expression, "1 1")
FAILURE(double_operator, "1 * * 1")
SUCCESS(one, "1", 1)
SUCCESS(the_answer, "42", 42)
SUCCESS(int_max, "2147483647", 2147483647)
SUCCESS(whitespace, " 1 ", 1)
SUCCESS(more_whitespace, " 1 + 2 ", 3)
SUCCESS(one_plus_one, "1+1", 2)
SUCCESS(one_minus_one, "1-1", 0)
SUCCESS(additions, "1+1+1+1+1", 5)
SUCCESS(substractions, "1-1-1-1-1", -3)
SUCCESS(multiplication, "2 * 3", 6)
SUCCESS(multiplications, "1 * 2 * 3 * 4", 24)
SUCCESS(division, "12 / 3", 4)
SUCCESS(divisions, "24 / 4 / 3 / 2", 1)
SUCCESS(simple_priority, "1 + 2 * 3", 7)
SUCCESS(more_priority, "1 + 6 / 3 + 4 * 6 + 14 / 7", 29)
FAILURE(fail_parenthesis, "(1 + 2))")
SUCCESS(simple_parenthesis, "(1 + 2) * 3", 9)
SUCCESS(more_parentheses, "(1 + 2) * (3 - 4)", -3)
SUCCESS(unary_minus, "-1", -1)
SUCCESS(unary_plus, "+1", 1)
SUCCESS(unary_torture, "--+++--+-+-+-1", -1)
SUCCESS(factorial, "3!", 6)
FAILURE(fail_factorial, "3!!")
SUCCESS(power, "4^3", 64)
SUCCESS(powers, "4^3^2", 262144)
SUCCESS(fact_and_power, "2^3!", 64)
SUCCESS(altogether, " - 3 ^ 2 + - 4 * 8 / 2 + + 3! -- 2 + ((-1) + 1) * 2 ", -17)