From 0b1905429cdc010a1ea76ee5d7a9d131ce24e3eb Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 12 Jan 2025 20:47:24 -0500 Subject: [PATCH] Updated tests to include order of operations. --- test/validation/test.bats | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/validation/test.bats b/test/validation/test.bats index 686065e..7f5a2c3 100644 --- a/test/validation/test.bats +++ b/test/validation/test.bats @@ -57,3 +57,29 @@ bin() { ./scl.out $1 | tail -n1; } run bin "-1/-1" [ "$output" = "= 1.000000" ] } + +@test "order of operations" { + run bin "1+2*3" + [ "$output" = "= 7.000000" ] + + run bin "2*3+1" + [ "$output" = "= 7.000000" ] + + run bin "6/2-1" + [ "$output" = "= 2.000000" ] + + run bin "1-6/2" + [ "$output" = "= -2.000000" ] +} + +# Doesn't run without hanging for now. +# @test "order of operations with parenthesis" { +# run bin "(1+2)*3" +# [ "$output" = "= 9.000000" ] +# +# run bin "-(1+2*3)" +# [ "$output" = "= -7.000000" ] +# +# run bin "-(-(1+2)*3)" +# [ "$output" = "= 9.000000" ] +# }