1 ;; Testing trivial macros
2 (defmacro! one (fn* () 1))
5 (defmacro! two (fn* () 2))
9 ;; Testing unless macros
10 (defmacro! unless (fn* (pred a b) `(if ~pred ~b ~a)))
15 (defmacro! unless2 (fn* (pred a b) `(if (not ~pred) ~a ~b)))
21 ;; Testing macroexpand
22 (macroexpand (unless2 2 3 4))
25 ;; Testing evaluation of macro result
26 (defmacro! identity (fn* (x) x))
27 (let* (a 123) (identity a))
33 ;; -------- Deferrable Functionality --------
35 ;; Testing non-macro function
38 ;;; This should fail if it is a macro
42 ;; Testing nth, first and rest functions
49 (def! x (nth (list 1 2) 2))
79 (or false nil false false nil 4)
81 (or false nil 3 false nil 4)
96 (cond false 7 false 8 "else" 9)
98 (cond false 7 (= 2 2) 8 "else" 9)
100 (cond false 7 false 8 false 9)
103 ;; Testing EVAL in let*
105 (let* (x (or nil "yes")) x)
111 ;; -------- Optional Functionality --------
113 ;; Testing nth, first, rest with vectors
120 (def! x (nth [1 2] 2))
141 ;; Testing EVAL in vector let*
143 (let* [x (or nil "yes")] x)
148 (load-file "../core.mal")
153 (-> (list 7 8 9) first)
155 (-> (list 7 8 9) (first))
157 (-> (list 7 8 9) first (+ 7))
159 (-> (list 7 8 9) rest (rest) first (+ 7))
165 (->> "L" (str "A") (str "M"))
167 (->> [4] (concat [3]) (concat [2]) rest (concat [1]))