Merge pull request #155 from ekmartin/nested_equal_elixir
[jackhill/mal.git] / tests / step7_quote.mal
1 ;; Testing cons function
2 (cons 1 (list))
3 ;=>(1)
4 (cons 1 (list 2))
5 ;=>(1 2)
6 (cons 1 (list 2 3))
7 ;=>(1 2 3)
8 (cons (list 1) (list 2 3))
9 ;=>((1) 2 3)
10
11 ;; Testing concat function
12 (concat)
13 ;=>()
14 (concat (list 1 2))
15 ;=>(1 2)
16 (concat (list 1 2) (list 3 4))
17 ;=>(1 2 3 4)
18 (concat (list 1 2) (list 3 4) (list 5 6))
19 ;=>(1 2 3 4 5 6)
20 (concat (concat))
21 ;=>()
22
23
24 ;; Testing regular quote
25 (quote 7)
26 ;=>7
27 '7
28 ;=>7
29 (quote (1 2 3))
30 ;=>(1 2 3)
31 '(1 2 3)
32 ;=>(1 2 3)
33 (quote (1 2 (3 4)))
34 ;=>(1 2 (3 4))
35 '(1 2 (3 4))
36 ;=>(1 2 (3 4))
37
38
39 ;; Testing simple quasiquote
40 (quasiquote 7)
41 ;=>7
42 `7
43 ;=>7
44 (quasiquote (1 2 3))
45 ;=>(1 2 3)
46 `(1 2 3)
47 ;=>(1 2 3)
48 (quasiquote (1 2 (3 4)))
49 ;=>(1 2 (3 4))
50 `(1 2 (3 4))
51 ;=>(1 2 (3 4))
52 (quasiquote (nil))
53 ;=>(nil)
54 `(nil)
55 ;=>(nil)
56
57
58 ;; Testing unquote
59 `~7
60 ;=>7
61 (def! a 8)
62 ;=>8
63 `a
64 ;=>a
65 `~a
66 ;=>8
67 `(1 a 3)
68 ;=>(1 a 3)
69 `(1 ~a 3)
70 ;=>(1 8 3)
71 (def! b '(1 "b" "d"))
72 ;=>(1 "b" "d")
73 `(1 b 3)
74 ;=>(1 b 3)
75 `(1 ~b 3)
76 ;=>(1 (1 "b" "d") 3)
77
78
79 ;; Testing splice-unquote
80 (def! c '(1 "b" "d"))
81 ;=>(1 "b" "d")
82 `(1 c 3)
83 ;=>(1 c 3)
84 `(1 ~@c 3)
85 ;=>(1 1 "b" "d" 3)
86
87
88 ;; Testing symbol equality
89 (= 'abc 'abc)
90 ;=>true
91 (= 'abc 'abcd)
92 ;=>false
93 (= 'abc "abc")
94 ;=>false
95 (= "abc" 'abc)
96 ;=>false
97 (= "abc" (str 'abc))
98 ;=>true
99
100 ;;;;; Test quine
101 ;;; TODO: needs expect line length fix
102 ;;;((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
103 ;;;=>((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
104
105 ;;
106 ;; -------- Optional Functionality --------
107
108 ;; Testing cons, concat, first, rest with vectors
109
110 (cons [1] [2 3])
111 ;=>([1] 2 3)
112 (cons 1 [2 3])
113 ;=>(1 2 3)
114 (concat [1 2] (list 3 4) [5 6])
115 ;=>(1 2 3 4 5 6)
116
117 ;; Testing unquote with vectors
118 (def! a 8)
119 ;=>8
120 `[1 a 3]
121 ;=>(1 a 3)
122 ;;; TODO: fix this
123 ;;;;=>[1 a 3]
124
125 ;; Testing splice-unquote with vectors
126 (def! c '(1 "b" "d"))
127 ;=>(1 "b" "d")
128 `[1 ~@c 3]
129 ;=>(1 1 "b" "d" 3)
130 ;;; TODO: fix this
131 ;;;;=>[1 1 "b" "d" 3]
132