1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-27 14:52:16 +03:00
mal/impls/tests/step2_eval.mal
Ben Harris a8e337b291 Step 2: Test empty vectors and hash-maps
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.
2020-05-28 11:28:38 +01:00

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
[]
;=>[]
{}
;=>{}