~subsetpark/ec

ref: 5b24c4463b2a541ae0a36ae7377481d3f947a5e6 ec/test/regressions.janet -rw-r--r-- 911 bytes
5b24c446 — Zach Smith Refactor command handling 11 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
35
36
37
38
39
40
41
42
43
44
45
(import /src/calc)
(import /src/parser)

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

(use testament)
(use /test-support)

(deftest regression1
  # [1] 1 + 1 +
  (def s (:new calc/Stack))
  (let [in (parser/parse "[1] 1 + 1 +")]
    (calc/push s (in 0))
    (vec= [1] (calc/peek s))
    (calc/push s (in 1))
    (vec= 1 (calc/peek s))
    (calc/push s (in 2))
    (vec= [2] (calc/peek s))
    (calc/push s (in 3))
    (vec= 1 (calc/peek s))
    (calc/push s (in 4)))

  (def res (calc/pop s))
  (vec= [3] res))

(deftest regression2
  # [4 5] 6 +  8 +
  (def s (:new calc/Stack))
  (let [in (parser/parse "[4 5] 6 + 8 +")]
    (push-all s in))

  (def res (calc/pop s))
  (vec= [18 19] res))

(deftest regression3
  # [2 3 4] 1 -
  (def s (:new calc/Stack))
  (let [in (parser/parse "[2 3 4] 1 -")]
    (push-all s in))

  (def res (calc/pop s))
  (vec= [1 2 3] res))

(run-tests!)