summaryrefslogtreecommitdiff
path: root/src/test-mp-equation.c
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-01-02 16:53:11 +0100
committerraveit65 <[email protected]>2020-01-12 14:59:36 +0100
commitd15bf0bc9df66506e5073caefda5e7fcdc3f427a (patch)
tree08188e1adbb72cf0efba2444761b097591a4fd39 /src/test-mp-equation.c
parent6d270dcc067da3ef5cc497339f2652c2f2c3911c (diff)
downloadmate-calc-d15bf0bc9df66506e5073caefda5e7fcdc3f427a.tar.bz2
mate-calc-d15bf0bc9df66506e5073caefda5e7fcdc3f427a.tar.xz
fixes precedence of functions i.e. the result of -ln(1) and add according tests
Diffstat (limited to 'src/test-mp-equation.c')
-rw-r--r--src/test-mp-equation.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test-mp-equation.c b/src/test-mp-equation.c
index ee461aa..0ff3a53 100644
--- a/src/test-mp-equation.c
+++ b/src/test-mp-equation.c
@@ -379,6 +379,38 @@ test_equations()
test("(1+2×3)", "7", 0);
test("2(1+1)", "4", 0);
test("4÷2(1+1)", "4", 0);
+ test ("1 + 2 - 3 * 4 / 5", "0.6", 0);
+ test ("20 / 10 mod 3", "2", 0);
+ test ("12 / 3 √4", "8", 0);
+ test ("√5!", "10.95445115", 0);
+ test ("4 ^ sin 30", "2", 0);
+ test ("4 ^ (sin 30)", "2", 0);
+ test ("4 ^ sin (30)", "2", 0);
+ //test ("sin (30) ^ 4", "0.0625", 0);
+ //test ("sin 30 ^ 4", "0.0625", 0);
+ test ("sin (30 ^ 4)", "0", 0);
+ test ("-ln(1)", "0", 0);
+ test ("ln(-1)", "3.141592654i", 0);
+
+ test ("10 / - 2", "−5", 0);
+ test ("10 * - 2", "−20", 0);
+ test ("10 ^ -2", "0.01", 0);
+ test ("-10 ^ 2", "−100", 0);
+ test ("sin (-30)", "−0.5", 0);
+ test ("sin - 30", "−0.5", 0);
+
+ test ("6 + 3!", "12", 0);
+ test ("4 * 3!", "24", 0);
+ test ("100 mod 3!", "4", 0);
+ test ("5! mod 7", "1", 0);
+ test ("24 / 3!", "4", 0);
+ test ("4! / 6", "4", 0);
+ test ("cos 5!", "−0.5", 0);
+ test ("sin 6!", "0", 0);
+ test ("- 4!", "−24", 0);
+ test ("3! ^ 3", "216", 0);
+ test ("3 ^ 3!", "729", 0);
+ //test ("(−√3)^2", "3", 0);
/* Percentage */
test("100%", "1", 0);