mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: calc parses negative numbers
This commit is contained in:
committed by
Tienson Qin
parent
d05c39b534
commit
4c10750fce
@@ -22,7 +22,12 @@
|
||||
98123 "9,8,123"
|
||||
1123.0 " 112,3.0 "
|
||||
22.1124131 "2,2.1124131"
|
||||
100.01231 " 1,00.01231 ")))
|
||||
100.01231 " 1,00.01231 "))
|
||||
(testing "even when they are negative"
|
||||
(are [value expr] (= value (run expr))
|
||||
-98123 "-98123"
|
||||
-1123.0 " -112,3.0 "
|
||||
-22.1124131 "-2,2.1124131")))
|
||||
(testing "basic operations work"
|
||||
(are [value expr] (= value (run expr))
|
||||
1 "1 + 0"
|
||||
@@ -32,11 +37,15 @@
|
||||
1 "(2-1 ) "
|
||||
211 "100 + 111"
|
||||
2111 "1,000 + 11,11"
|
||||
-111 "1,000 + -11,11"
|
||||
0 "1 + 2 + 3 + 4 + 5 -1-2-3-4-5"
|
||||
1 "1 * 1"
|
||||
-1 "1 * -1"
|
||||
2 "1*2"
|
||||
-2 "-1*2"
|
||||
9 " 3 *3"
|
||||
1 " 2 * 3 / 3 / 2"
|
||||
-1 " 2 * 3 / 3 / -2"
|
||||
#?(:clj 1/2
|
||||
:cljs 0.5) " 1 / 2"
|
||||
0.5 " 1/ 2.0"))
|
||||
@@ -62,6 +71,7 @@
|
||||
1.0e1 "1.0e01"
|
||||
1.23e-10 "123.0e-12"
|
||||
12.3 "123.0e-1"
|
||||
-12.3 "-123.0e-1"
|
||||
12.3 "123.0E-1"
|
||||
2.0 "1e0 + 1e0"))
|
||||
(testing "scientific functions"
|
||||
@@ -80,9 +90,11 @@
|
||||
(calc/eval env (calc/parse expr))
|
||||
(= final-env @env))
|
||||
{"a" 1} "a = 1"
|
||||
{"a" -1} "a = -1"
|
||||
{"variable" 1} "variable = 1 + 0 * 2"
|
||||
{"x" 1} "x= 2 * 1 - 1 "
|
||||
{"y" 4} "y =8 / 4 + 2 * 1 - 25 * 0 / 1"
|
||||
{"y" 4} "y =8 / 4 + 2 * 1 - 25 * 0 / 1"
|
||||
{"zzz" 14.0} "zzz=3 *2 ^ 2 + 1 * 2"
|
||||
{"foo" 74.0} "foo = (((3*2) ^ 2 + 1) * 2)"))
|
||||
(testing "variables can have underscores"
|
||||
|
||||
Reference in New Issue
Block a user