~subsetpark/ec

ref: 5b24c4463b2a541ae0a36ae7377481d3f947a5e6 ec/test-support.janet -rw-r--r-- 489 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
(import /src/calc)

(use testament)

(defn unwrap
  [obj]
  (match obj
    {:data data} (map unwrap data)
    {:value value} value))

(defn vec=
  [val obj]
  (is (== val (unwrap obj))))

(defn wrap
  [& args]
  (calc/wrap ;(map |(if (number? $)
                      (:new calc/Int $)
                      $)
                   args)))

(defn pop-and-compare
  [val s]
  (is (= val (calc/value (calc/pop s)))))

(defn push-all
  [stack args]
  (each arg args
    (calc/push stack arg)))