mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 01:05:32 +01:00
Added some other tests
- builtin eq test - load_file return resul Signed-off-by: teo3300 <matteo.rogora@live.it>
This commit is contained in:
58
tests/equals.mal
Normal file
58
tests/equals.mal
Normal file
@ -0,0 +1,58 @@
|
||||
; This is used for assert-eq in other tests
|
||||
|
||||
; For each type do the following tests:
|
||||
; single element
|
||||
; equal elements
|
||||
; 1 different
|
||||
; compare with foreign type
|
||||
|
||||
; empty
|
||||
(assert (=)) ; nothing to compare with
|
||||
|
||||
; nil
|
||||
(assert (= nil))
|
||||
(assert (= nil nil nil))
|
||||
(assert (not (= nil true)))
|
||||
(assert (not (= nil 1)))
|
||||
|
||||
; bool
|
||||
(assert (= true))
|
||||
(assert (= true true true))
|
||||
(assert (not (= true false true)))
|
||||
(assert (not (= true 1)))
|
||||
|
||||
; int
|
||||
(assert (= 1))
|
||||
(assert (= 1 1 1))
|
||||
(assert (not (= 1 2 1)))
|
||||
(assert (not (= 1 nil)))
|
||||
|
||||
; key
|
||||
(assert (= :a))
|
||||
(assert (= :a :a :a))
|
||||
(assert (not (= :a :b :a)))
|
||||
(assert (not (= :a "a")))
|
||||
|
||||
; string
|
||||
(assert (= "a"))
|
||||
(assert (= "a" "a" "a"))
|
||||
(assert (not (= "a" "b" "a")))
|
||||
(assert (not (= "a" :a)))
|
||||
|
||||
; add comparison for same elements with different length
|
||||
|
||||
; list
|
||||
(assert (= (list 1 1 1)))
|
||||
(assert (= (list 1 1 1) (list 1 1 1) (list 1 1 1)))
|
||||
(assert (not (= (list 1 1 1) (list 1 2 1) (list 1 1 1))))
|
||||
(assert (not (= (list 1) (list 1 1))))
|
||||
(assert (not (= (list 1 1) (list 1))))
|
||||
(assert (not (= () (list 1))))
|
||||
(assert (not (= (list 1) ())))
|
||||
(assert (not (= (list 1 1 1) [1 1 1])))
|
||||
|
||||
; vector
|
||||
(assert (= [1 1 1]))
|
||||
(assert (= [1 1 1] [1 1 1] [1 1 1]))
|
||||
(assert (not (= [1 1 1] [1 2 1] [1 1 1])))
|
||||
(assert (not (= [1 1 1] (list 1 1 1))))
|
||||
Reference in New Issue
Block a user