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) (list 'if (list '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))
30 ;; Test that macros do not break empty list
37 ;; -------- Deferrable Functionality --------
39 ;; Testing non-macro function
42 ;;; This should fail if it is a macro
46 ;; Testing nth, first and rest functions
52 (nth (list 1 2 nil) 2)
55 (def! x (nth (list 1 2) 2))
84 (cond false 7 false 8 "else" 9)
86 (cond false 7 (= 2 2) 8 "else" 9)
88 (cond false 7 false 8 false 9)
91 ;; Testing EVAL in let*
93 (let* (x (cond false "no" true "yes")) x)
97 ;; Testing nth, first, rest with vectors
106 (def! x (nth [1 2] 2))
126 (rest (cons 10 [11 12]))
129 ;; Testing EVAL in vector let*
131 (let* [x (cond false "no" true "yes")] x)
137 ;; ------- Optional Functionality --------------
138 ;; ------- (Not needed for self-hosting) -------
140 ;; Test that macros use closures
142 (defmacro! a (fn* [] x))