mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 01:05:32 +01:00
Other tests
Lotta tests in - eval - functional tests Signed-off-by: teo3300 <matteo.rogora@live.it>
This commit is contained in:
51
tests/arithmetic.mal
Normal file
51
tests/arithmetic.mal
Normal file
@ -0,0 +1,51 @@
|
||||
; +
|
||||
(assert (= (+) 0))
|
||||
(assert (= (+ 1) 1))
|
||||
(assert (= (+ 1 1) 2))
|
||||
(assert (= (+ 1 2 3 4) 10))
|
||||
|
||||
; -
|
||||
(assert (= (-) 0))
|
||||
(assert (= (- 1) -1))
|
||||
(assert (= (- 1 2) -1))
|
||||
(assert (= (- 10 1 2 3) 4))
|
||||
|
||||
; *
|
||||
(assert (= (*) 1))
|
||||
(assert (= (* 2) 2))
|
||||
(assert (= (* 2 3) 6))
|
||||
(assert (= (* -2 3) -6))
|
||||
(assert (= (* -2 -3) 6))
|
||||
(assert (= (* 10 1 2 3) 60))
|
||||
|
||||
; /
|
||||
(assert (= (/) 1))
|
||||
(assert (= (/ 1) 1))
|
||||
(assert (= (/ 2) 0))
|
||||
(assert (= (/ 3 2) 1))
|
||||
(assert (= (/ 128 2 4) 16))
|
||||
|
||||
; >
|
||||
(assert (not (>)))
|
||||
(assert (> 1))
|
||||
(assert (> 3 2 1))
|
||||
(assert (not (> 3 1 2)))
|
||||
(assert (not (> 1 1)))
|
||||
; <
|
||||
(assert (not (<)))
|
||||
(assert (< 1))
|
||||
(assert (< 1 2 3))
|
||||
(assert (not (< 1 3 2)))
|
||||
(assert (not (< 1 1)))
|
||||
; >=
|
||||
(assert (not (>=)))
|
||||
(assert (>= 1))
|
||||
(assert (>= 3 2 1))
|
||||
(assert (not (>= 3 1 2)))
|
||||
(assert (>= 1 1))
|
||||
; <=
|
||||
(assert (not (<=)))
|
||||
(assert (<= 1))
|
||||
(assert (<= 1 2 3))
|
||||
(assert (not (<= 1 3 2)))
|
||||
(assert (<= 1 1))
|
||||
9
tests/lists.mal
Normal file
9
tests/lists.mal
Normal file
@ -0,0 +1,9 @@
|
||||
; list?
|
||||
(assert (list? (list 1 2 3)))
|
||||
(assert (not (list? 1)))
|
||||
|
||||
; empty?
|
||||
(assert (empty? ()))
|
||||
(assert (empty? (list)))
|
||||
(assert (not (empty? ())))
|
||||
(assert (not (empty? (list (1 2 3)))))
|
||||
Reference in New Issue
Block a user