mirror of
https://github.com/kanaka/mal.git
synced 2024-10-27 14:52:16 +03:00
a8e337b291
An empty vector or hash-map should evaluate to itself, but I reached the test of (empty? []) in step 4 before I discovered that I'd got [] evaluating to 0. Add tests for both cases to step 2.
50 lines
619 B
Plaintext
50 lines
619 B
Plaintext
;; Testing evaluation of arithmetic operations
|
|
(+ 1 2)
|
|
;=>3
|
|
|
|
(+ 5 (* 2 3))
|
|
;=>11
|
|
|
|
(- (+ 5 (* 2 3)) 3)
|
|
;=>8
|
|
|
|
(/ (- (+ 5 (* 2 3)) 3) 4)
|
|
;=>2
|
|
|
|
(/ (- (+ 515 (* 87 311)) 302) 27)
|
|
;=>1010
|
|
|
|
(* -3 6)
|
|
;=>-18
|
|
|
|
(/ (- (+ 515 (* -87 311)) 296) 27)
|
|
;=>-994
|
|
|
|
;;; This should throw an error with no return value
|
|
(abc 1 2 3)
|
|
;/.+
|
|
|
|
;; Testing empty list
|
|
()
|
|
;=>()
|
|
|
|
;>>> deferrable=True
|
|
;;
|
|
;; -------- Deferrable Functionality --------
|
|
|
|
;; Testing evaluation within collection literals
|
|
[1 2 (+ 1 2)]
|
|
;=>[1 2 3]
|
|
|
|
{"a" (+ 7 8)}
|
|
;=>{"a" 15}
|
|
|
|
{:a (+ 7 8)}
|
|
;=>{:a 15}
|
|
|
|
;; Check that evaluation hasn't broken empty collections
|
|
[]
|
|
;=>[]
|
|
{}
|
|
;=>{}
|