aboutsummaryrefslogtreecommitdiff
path: root/tests/step8_macros.mal
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-10 23:27:50 -0500
committerJoel Martin <github@martintribe.org>2014-04-10 23:27:50 -0500
commitd85fc03775e0f99d1c17ce62d5aad5bbcd8ae106 (patch)
treef7bee4a4f67a61cce150e7125e018f6ebdc8fec2 /tests/step8_macros.mal
parent01e254893fede2c88fa7d2210da9e03af3a12617 (diff)
downloadmal-d85fc03775e0f99d1c17ce62d5aad5bbcd8ae106.tar.gz
mal-d85fc03775e0f99d1c17ce62d5aad5bbcd8ae106.zip
Ruby: add step8_macros
Diffstat (limited to 'tests/step8_macros.mal')
-rw-r--r--tests/step8_macros.mal58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/step8_macros.mal b/tests/step8_macros.mal
index 351e0ca..03128ca 100644
--- a/tests/step8_macros.mal
+++ b/tests/step8_macros.mal
@@ -1,3 +1,61 @@
+;; Testing cons function
+(cons 1 (list))
+;=>(1)
+(cons 1 (list 2))
+;=>(1 2)
+(cons 1 (list 2 3))
+;=>(1 2 3)
+(cons (list 1) (list 2 3))
+;=>((1) 2 3)
+(cons [1] [2 3])
+;=>([1] 2 3)
+(cons 1 [2 3])
+;=>(1 2 3)
+
+;; Testing concat function
+(concat)
+;=>()
+(concat (list 1 2))
+;=>(1 2)
+(concat (list 1 2) (list 3 4))
+;=>(1 2 3 4)
+(concat (list 1 2) (list 3 4) (list 5 6))
+;=>(1 2 3 4 5 6)
+(concat [1 2] (list 3 4) [5 6])
+;=>(1 2 3 4 5 6)
+(concat (concat))
+;=>()
+
+;; Testing first function
+(first '())
+;=>nil
+(first '(6))
+;=>6
+(first '(7 8 9))
+;=>7
+(first [])
+;=>nil
+(first [10])
+;=>10
+(first [10 11 12])
+;=>10
+
+;; Testing rest function
+(rest '())
+;=>()
+(rest '(6))
+;=>()
+(rest '(7 8 9))
+;=>(8 9)
+(rest [])
+;=>()
+(rest [10])
+;=>()
+(rest [10 11 12])
+;=>(11 12)
+
+
+
;; Testing trivial macros
(defmacro! one (fn* () 1))
(one)