mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 13:55:55 +03:00
Tests: move optional features to end and print header.
This commit is contained in:
parent
b5dedee06b
commit
9af8aee63a
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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])
|
||||
|
@ -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
|
||||
|
||||
|
@ -8,6 +8,9 @@
|
||||
(inc3 9)
|
||||
;=>12
|
||||
|
||||
;;
|
||||
;; -------- Optional Functionality --------
|
||||
|
||||
(load-file "../tests/incB.mal")
|
||||
; "incB.mal finished"
|
||||
;=>"incB.mal return string"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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\""
|
||||
|
Loading…
Reference in New Issue
Block a user