diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-10 23:27:50 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-10 23:27:50 -0500 |
| commit | d85fc03775e0f99d1c17ce62d5aad5bbcd8ae106 (patch) | |
| tree | f7bee4a4f67a61cce150e7125e018f6ebdc8fec2 /tests | |
| parent | 01e254893fede2c88fa7d2210da9e03af3a12617 (diff) | |
| download | mal-d85fc03775e0f99d1c17ce62d5aad5bbcd8ae106.tar.gz mal-d85fc03775e0f99d1c17ce62d5aad5bbcd8ae106.zip | |
Ruby: add step8_macros
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/step8_macros.mal | 58 | ||||
| -rw-r--r-- | tests/stepA_more.mal | 55 |
2 files changed, 58 insertions, 55 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) diff --git a/tests/stepA_more.mal b/tests/stepA_more.mal index 54faa19..f6b01f5 100644 --- a/tests/stepA_more.mal +++ b/tests/stepA_more.mal @@ -71,34 +71,6 @@ ;=>(2 4 6) -;; 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 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 conj function (conj (list) 1) ;=>(1) @@ -122,33 +94,6 @@ (conj [1] [2 3]) ;=>[1 [2 3]] -;; Testing first/rest functions -(first '()) -;=>nil -(first '(6)) -;=>6 -(first '(7 8 9)) -;=>7 -(first []) -;=>nil -(first [10]) -;=>10 -(first [10 11 12]) -;=>10 - -(rest '()) -;=>() -(rest '(6)) -;=>() -(rest '(7 8 9)) -;=>(8 9) -(rest []) -;=>() -(rest [10]) -;=>() -(rest [10 11 12]) -;=>(11 12) - ;; |
