|
@@ -15,6 +15,11 @@
|
|
|
[ "$result" = "-1" ]
|
|
|
}
|
|
|
|
|
|
+@test "Substraction with left priority" {
|
|
|
+ result="$(echo '8 - 2 - 1 =' | ./eval.out)"
|
|
|
+ [ "$result" = "5" ]
|
|
|
+}
|
|
|
+
|
|
|
@test "Multiplication priority over addition" {
|
|
|
result="$(echo '1+2*3=' | ./eval.out)"
|
|
|
[ "$result" = "7" ]
|
|
@@ -52,14 +57,38 @@
|
|
|
}
|
|
|
|
|
|
@test "Basic division" {
|
|
|
- skip "Feature not implemented"
|
|
|
result="$(echo '42 / 7 =' | ./eval.out)"
|
|
|
[ "$result" = "6" ]
|
|
|
}
|
|
|
|
|
|
@test "Basic truncated division" {
|
|
|
- skip "Feature not implemented"
|
|
|
result="$(echo '16 / 3 =' | ./eval.out)"
|
|
|
[ "$result" = "5" ]
|
|
|
}
|
|
|
|
|
|
+@test "Division with left priority" {
|
|
|
+ result="$(echo '8 / 4 / 2 =' | ./eval.out)"
|
|
|
+ [ "$result" = "1" ]
|
|
|
+}
|
|
|
+
|
|
|
+@test "Division by zero" {
|
|
|
+ # To improve
|
|
|
+ result="$(echo '42 / 0 =' | ./eval.out)"
|
|
|
+ [ "$result" = "42" ]
|
|
|
+}
|
|
|
+
|
|
|
+@test "Complex division" {
|
|
|
+ result="$(echo '192 / 3 / 16 =' | ./eval.out)"
|
|
|
+ [ "$result" = "4" ]
|
|
|
+}
|
|
|
+
|
|
|
+@test "Complex truncated division" {
|
|
|
+ result="$(echo '182 / 3 / 15 =' | ./eval.out)"
|
|
|
+ [ "$result" = "4" ]
|
|
|
+}
|
|
|
+
|
|
|
+@test "Mixed operation with * + / -" {
|
|
|
+ result="$(echo '15 * (1 + 1 + 1 + 4 - 2*2) / 3 / 15 =' | ./eval.out)"
|
|
|
+ [ "$result" = "1" ]
|
|
|
+}
|
|
|
+
|