From d85fc03775e0f99d1c17ce62d5aad5bbcd8ae106 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Thu, 10 Apr 2014 23:27:50 -0500 Subject: Ruby: add step8_macros --- tests/step8_macros.mal | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'tests/step8_macros.mal') 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) -- cgit v1.2.3