1 ;; Testing non-macro function
4 ;;; This should fail if it is a macro
9 ;; Testing trivial macros
10 (defmacro! one (fn* () 1))
13 (defmacro! two (fn* () 2))
17 ;; Testing unless macros
18 (defmacro! unless (fn* (pred a b) `(if ~pred ~b ~a)))
23 (defmacro! unless2 (fn* (pred a b) `(if (not ~pred) ~a ~b)))
29 ;; Testing macroexpand
30 (macroexpand (unless2 2 3 4))
33 ;; Testing evaluation of macro result
34 (defmacro! identity (fn* (x) x))
35 (let* (a 123) (identity a))
39 ;; Testing nth, first and rest functions
46 (def! x (nth '(1 2) 2))
76 (or false nil false false nil 4)
78 (or false nil 3 false nil 4)
93 (cond false 7 false 8 "else" 9)
95 (cond false 7 (= 2 2) 8 "else" 9)
97 (cond false 7 false 8 false 9)
100 ;; Testing EVAL in let*
102 (let* (x (or nil "yes")) x)
106 ;; -------- Optional Functionality --------
108 ;; Testing nth, first, rest with vectors
115 (def! x (nth [1 2] 2))
136 ;; Testing EVAL in vector let*
138 (let* [x (or nil "yes")] x)
143 (load-file "../core.mal")
148 (-> (list 7 8 9) first)
150 (-> (list 7 8 9) (first))
152 (-> (list 7 8 9) first (+ 7))
154 (-> (list 7 8 9) rest (rest) first (+ 7))
160 (->> "L" (str "A") (str "M"))
162 (->> [4] (concat [3]) (concat [2]) rest (concat [1]))