~subsetpark/ec

ref: big ec/test/eval.janet -rw-r--r-- 680 bytes
3f9b6ebe — Zach Smith Support bigints (note: this does not work on account of floats being coerced to big ints) 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(import /src/calc)
(import /src/parser)
(import /src/eval)
(import /src/env)

(import /src/operations :prefix "o/")
(import /src/adverbs :prefix "a/")

(use testament)
(use /test-support)

(deftest pushable
  (let [s (env/new-env)
        parsed (parser/parse "4 5 +")]
    (eval-all s parsed)

    (is (= 1 (length (s :data))))
    (def res (first (s :data)))

    (is (= 9 (res :value)))
    (is (calc/Float? res))))

(deftest push-adverb
  (let [s (env/new-env)
        parsed (parser/parse "[1 2 3] 0 (+) dist")]
    (eval-all s parsed)

    (is (= 1 (length (s :data))))
    (def res (first (s :data)))

    (is (= 6 (res :value)))
    (is (calc/Float? res))))

(run-tests!)