~subsetpark/ec

ref: e85c9853e2f2332e47aaa381a543d0f78de5cd4e ec/test-support.janet -rw-r--r-- 600 bytes
e85c9853 — Zach Smith test-arity helper 10 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
(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- make-element
  [x]
  (if (number? x) (:new calc/Int x) x))

(defn wrap
  [& args]
  (calc/wrap ;(map make-element args)))

(defn quote-wrap
  [& args]
  (calc/quote-wrap ;(map make-element args)))

(defn pop-and-compare
  [val s]
  (let [found (match (calc/pop s)
                {:value value} value)]
    (is (== val found))))

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