1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
mal/tests/step7_quote.mal
2015-01-06 21:57:02 -06:00

81 lines
1.2 KiB
Plaintext

;; Testing regular quote
(quote 7)
;=>7
'7
;=>7
(quote (1 2 3))
;=>(1 2 3)
'(1 2 3)
;=>(1 2 3)
(quote (1 2 (3 4)))
;=>(1 2 (3 4))
'(1 2 (3 4))
;=>(1 2 (3 4))
;; Testing simple quasiquote
(quasiquote 7)
;=>7
`7
;=>7
(quasiquote (1 2 3))
;=>(1 2 3)
`(1 2 3)
;=>(1 2 3)
(quasiquote (1 2 (3 4)))
;=>(1 2 (3 4))
`(1 2 (3 4))
;=>(1 2 (3 4))
;; Testing unquote
`~7
;=>7
(def! a 8)
;=>8
`a
;=>a
`~a
;=>8
`(1 a 3)
;=>(1 a 3)
`(1 ~a 3)
;=>(1 8 3)
(def! b '(1 "b" "d"))
;=>(1 "b" "d")
`(1 b 3)
;=>(1 b 3)
`(1 ~b 3)
;=>(1 (1 "b" "d") 3)
;;; TODO: fix this
;;;`[1 ~b 3]
;;;;=>[1 (1 "b" "d") 3]
;; Testing splice-unquote
(def! c '(1 "b" "d"))
;=>(1 "b" "d")
`(1 c 3)
;=>(1 c 3)
`(1 ~@c 3)
;=>(1 1 "b" "d" 3)
;;; TODO: fix this
;;;`[1 ~@c 3]
;;;;=>[1 1 "b" "d" 3]
;; Testing symbol equality
(= 'abc 'abc)
;=>true
(= 'abc 'abcd)
;=>false
(= 'abc "abc")
;=>false
(= "abc" 'abc)
;=>false
;;;;; Test quine
;;; TODO: needs expect line length fix
;;;((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
;;;=>((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))