1 ;; -----------------------------------------------------
4 ;; Testing list functions
21 (if (> (count (list 1 2 3)) 3) "yes" "no")
23 (if (>= (count (list 1 2 3)) 3) "yes" "no")
32 (if true (+ 1 7) (+ 1 8))
34 (if false (+ 1 7) (+ 1 8))
50 ;; Testing 1-way if form
59 ;; Testing basic conditionals
122 (= (list 1 2) (list 1 2))
138 ;; Testing builtin and user defined functions
141 ( (fn* (a b) (+ b a)) 3 4)
146 ( (fn* (f x) (f x)) (fn* (a) (+ 1 a)) 7)
151 ( ( (fn* (a) (fn* (b) (+ a b))) 5) 7)
154 (def! gen-plus5 (fn* () (fn* (b) (+ 5 b))))
155 (def! plus5 (gen-plus5))
159 (def! gen-plusX (fn* (x) (fn* (b) (+ x b))))
160 (def! plus7 (gen-plusX 7))
165 ;; Testing variable length arguments
167 ( (fn* (& more) (count more)) 1 2 3)
169 ( (fn* (& more) (count more)) 1)
171 ( (fn* (& more) (count more)) )
173 ( (fn* (a & more) (count more)) 1 2 3)
175 ( (fn* (a & more) (count more)) 1)
179 ;; Testing language defined not function
191 (do (prn "prn output1"))
194 (do (prn "prn output2") 7)
197 (do (prn "prn output1") (prn "prn output2") (+ 1 2))
202 (do (def! a 6) 7 (+ a 8))
208 ;; Testing recursive sumdown function
209 (def! sumdown (fn* (N) (if (> N 0) (+ N (sumdown (- N 1))) 0)))
218 ;; Testing recursive fibonacci function
219 (def! fib (fn* (N) (if (= N 0) 1 (if (= N 1) 1 (+ (fib (- N 1)) (fib (- N 2)))))))
226 ;;; Too slow for bash, erlang, make and miniMAL
230 ;; -----------------------------------------------------
232 ;; Testing string quoting
258 (pr-str "abc def" "ghi jkl")
259 ;=>"\"abc def\" \"ghi jkl\""
264 (pr-str (list 1 2 "abc" "\"") "def")
265 ;=>"(1 2 \"abc\" \"\\\"\") \"def\""
285 (str "abc def" "ghi jkl")
288 ;;; TODO: get this working properly
289 ;;;(str (list 1 2 "abc" "\"") "def")
290 ;;;;=>"(1 2 \"abc\" \"\\\"\")def"
306 (prn "abc def" "ghi jkl")
307 ; "abc def" "ghi jkl"
313 (prn (list 1 2 "abc" "\"") "def")
314 ; (1 2 "abc" "\"") "def"
331 (println "abc def" "ghi jkl")
338 (println (list 1 2 "abc" "\"") "def")
343 ;; -------- Optional Functionality --------
353 ;; Testing vector truthiness
357 ;; Testing vector functions
367 ;; Testing vector equality
385 ;; Testing vector parameter lists
388 ( (fn* [f x] (f x)) (fn* [a] (+ 1 a)) 7)