diff options
| author | Joel Martin <github@martintribe.org> | 2014-04-19 15:27:19 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-04-19 15:27:19 -0500 |
| commit | 9af8aee63aad6031c12f2b04ba87c16cc3273077 (patch) | |
| tree | 541b26455395db9a2048a178cf372c5c71b025fc | |
| parent | b5dedee06b3a8fbec962fe23b0d474d7cf037a3d (diff) | |
| download | mal-9af8aee63aad6031c12f2b04ba87c16cc3273077.tar.gz mal-9af8aee63aad6031c12f2b04ba87c16cc3273077.zip | |
Tests: move optional features to end and print header.
| -rw-r--r-- | docs/step_notes.txt | 2 | ||||
| -rw-r--r-- | tests/incB.mal | 3 | ||||
| -rw-r--r-- | tests/step1_read_print.mal | 39 | ||||
| -rw-r--r-- | tests/step2_eval.mal | 3 | ||||
| -rw-r--r-- | tests/step3_env.mal | 2 | ||||
| -rw-r--r-- | tests/step4_if_fn_do.mal | 45 | ||||
| -rw-r--r-- | tests/step6_file.mal | 3 | ||||
| -rw-r--r-- | tests/step8_macros.mal | 50 | ||||
| -rw-r--r-- | tests/stepA_more.mal | 59 |
9 files changed, 121 insertions, 85 deletions
diff --git a/docs/step_notes.txt b/docs/step_notes.txt index 120da6e..951ab3c 100644 --- a/docs/step_notes.txt +++ b/docs/step_notes.txt @@ -43,6 +43,8 @@ Step Notes: variable with checks for it at the beginning of critical code sections +- comments + - vectors - Basically: two array types that retain their boxed types, can be challenging depending on the language (e.g. JS, PHP: no clean diff --git a/tests/incB.mal b/tests/incB.mal index 86960c5..1c68810 100644 --- a/tests/incB.mal +++ b/tests/incB.mal @@ -7,9 +7,6 @@ (def! mymap {"a" 1}) -;; Test commas as whitespace -(def! myvec [1 2, 3]) - (prn "incB.mal finished") "incB.mal return string" diff --git a/tests/step1_read_print.mal b/tests/step1_read_print.mal index de7fcc1..0c715de 100644 --- a/tests/step1_read_print.mal +++ b/tests/step1_read_print.mal @@ -1,11 +1,3 @@ -;; Testing read of comments - ;; whole line comment (not an exception) -1 ; comment after expression -;=>1 -1; comment after expression -;=>1 - - ;; Testing read of nil/true/false nil ;=>nil @@ -80,6 +72,28 @@ abc-def { "a" {"b" { "cde" 3 } }} ;=>{"a" {"b" {"cde" 3}}} +;; Test commas as whitespace +[1 2, 3,,,,],, +;=>[1 2 3] + +;; +;; Testing reader errors +(1 2 +; expected ')', got EOF +[1 2 +; expected ']', got EOF +"abc +; expected '"', got EOF + +;; +;; -------- Optional Functionality -------- + +;; Testing read of comments + ;; whole line comment (not an exception) +1 ; comment after expression +;=>1 +1; comment after expression +;=>1 ;; Testing read of quoting '1 @@ -106,12 +120,3 @@ abc-def ;; Testing read of @/deref @a ;=>(deref a) - -;; -;; Testing reader errors -(1 2 -; expected ')', got EOF -[1 2 -; expected ']', got EOF -"abc -; expected '"', got EOF diff --git a/tests/step2_eval.mal b/tests/step2_eval.mal index b24af93..eb35592 100644 --- a/tests/step2_eval.mal +++ b/tests/step2_eval.mal @@ -14,6 +14,9 @@ (abc 1 2 3) ; .*\'abc\' not found.* +;; +;; -------- Optional Functionality -------- + ;; Testing evaluation within collection literals [1 2 (+ 1 2)] ;=>[1 2 3] diff --git a/tests/step3_env.mal b/tests/step3_env.mal index 448a446..26372e6 100644 --- a/tests/step3_env.mal +++ b/tests/step3_env.mal @@ -32,6 +32,8 @@ x (let* (p (+ 2 3) q (+ 2 p)) (+ p q)) ;=>12 +;; +;; -------- Optional Functionality -------- ;; Testing vector evaluation (let* (a 5 b 6) [3 4 a [b 7] 8]) diff --git a/tests/step4_if_fn_do.mal b/tests/step4_if_fn_do.mal index 4d41380..32d2d66 100644 --- a/tests/step4_if_fn_do.mal +++ b/tests/step4_if_fn_do.mal @@ -151,8 +151,6 @@ ;=>7 (if (list 1 2 3) 7 8) ;=>7 -(if [] 7 8) -;=>7 ;; Testing 1-way if form @@ -238,23 +236,6 @@ (= "" (list)) ;=>false -(= [] (list)) -;=>true -(= (list 1 2) [1 2]) -;=>true -(= (list 1) []) -;=>false -(= [] [1]) -;=>false -(= 0 []) -;=>false -(= [] 0) -;=>false -(= [] "") -;=>false -(= "" []) -;=>false - ;; Testing builtin and user defined functions (+ 1 2) @@ -346,3 +327,29 @@ a ;=>5 (fib 10) ;=>89 + +;; +;; -------- Optional Functionality -------- + +;; Testing vector truthiness +(if [] 7 8) +;=>7 + +;; Testing vector equality +(= [] (list)) +;=>true +(= (list 1 2) [1 2]) +;=>true +(= (list 1) []) +;=>false +(= [] [1]) +;=>false +(= 0 []) +;=>false +(= [] 0) +;=>false +(= [] "") +;=>false +(= "" []) +;=>false + diff --git a/tests/step6_file.mal b/tests/step6_file.mal index c6df3eb..1f4f756 100644 --- a/tests/step6_file.mal +++ b/tests/step6_file.mal @@ -8,6 +8,9 @@ (inc3 9) ;=>12 +;; +;; -------- Optional Functionality -------- + (load-file "../tests/incB.mal") ; "incB.mal finished" ;=>"incB.mal return string" diff --git a/tests/step8_macros.mal b/tests/step8_macros.mal index 023c3d5..8940a89 100644 --- a/tests/step8_macros.mal +++ b/tests/step8_macros.mal @@ -7,10 +7,6 @@ ;=>(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) @@ -21,8 +17,6 @@ ;=>(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)) ;=>() @@ -33,12 +27,6 @@ ;=>6 (first '(7 8 9)) ;=>7 -(first []) -;=>nil -(first [10]) -;=>10 -(first [10 11 12]) -;=>10 ;; Testing rest function (rest '()) @@ -47,12 +35,6 @@ ;=>() (rest '(7 8 9)) ;=>(8 9) -(rest []) -;=>() -(rest [10]) -;=>() -(rest [10 11 12]) -;=>(11 12) @@ -146,7 +128,37 @@ (cond false 7 false 8 false 9) ;=>nil -;; Testing all EVAL of non-default locations +;; Testing EVAL in let* + +(let* (x (or nil "yes")) x) +;=>"yes" + +;; +;; -------- Optional Functionality -------- + +;; Testing cons, concat, first, rest with vectors + +(cons [1] [2 3]) +;=>([1] 2 3) +(cons 1 [2 3]) +;=>(1 2 3) +(concat [1 2] (list 3 4) [5 6]) +;=>(1 2 3 4 5 6) +(first []) +;=>nil +(first [10]) +;=>10 +(first [10 11 12]) +;=>10 +(rest []) +;=>() +(rest [10]) +;=>() +(rest [10 11 12]) +;=>(11 12) + +;; Testing EVAL in vector let* + (let* [x (or nil "yes")] x) ;=>"yes" diff --git a/tests/stepA_more.mal b/tests/stepA_more.mal index 764c47f..2ca58fb 100644 --- a/tests/stepA_more.mal +++ b/tests/stepA_more.mal @@ -40,18 +40,6 @@ (false? true) ;=>false -(sequential? (list 1 2 3)) -;=>true -(sequential? [15]) -;=>true -(sequential? sequential?) -;=>false -(sequential? nil) -;=>false -(sequential? "abc") -;=>false - - ;; Testing apply function (apply + (list 2 3)) ;=>5 @@ -70,6 +58,35 @@ (map double nums) ;=>(2 4 6) +;; +;; Testing read-str and eval +(read-string "(1 2 (3 4) nil)") +;=>(1 2 (3 4) nil) + +(eval (read-string "(+ 4 5)")) +;=>9 + +;; +;; Testing readline +(readline "mal-user> ") +"hello" +;=>"\"hello\"" + +;; +;; -------- Optional Functionality -------- + +;; Testing sequential? function + +(sequential? (list 1 2 3)) +;=>true +(sequential? [15]) +;=>true +(sequential? sequential?) +;=>false +(sequential? nil) +;=>false +(sequential? "abc") +;=>false ;; Testing conj function (conj (list) 1) @@ -94,7 +111,8 @@ (conj [1] [2 3]) ;=>[1 [2 3]] - +(map? []) +;=>false ;; ;; Testing hash-maps @@ -114,7 +132,7 @@ ;=>true (map? 1) ;=>false -(map? []) +(map? "abc") ;=>false (get nil "a") @@ -300,16 +318,3 @@ (f) ;=>9 -;; -;; Testing read-str and eval -(read-string "(1 2 (3 4) nil)") -;=>(1 2 (3 4) nil) - -(eval (read-string "(+ 4 5)")) -;=>9 - -;; -;; Testing readline -(readline "mal-user> ") -"hello" -;=>"\"hello\"" |
