1
0
Fork 0
lesson-lisp/tests/equiv.scm

56 lines
1.9 KiB
Scheme
Raw Normal View History

2023-05-06 13:26:27 -04:00
(begin
2023-05-06 15:13:35 -04:00
;;; equal? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2023-05-06 13:26:27 -04:00
; No args
2023-05-06 15:13:35 -04:00
(assert-true (equal?))
2023-05-06 13:26:27 -04:00
; A single arg
2023-05-06 15:13:35 -04:00
(assert-true (equal? '()))
(assert-true (equal? +))
(assert-true (equal? (cons 123 456)))
(assert-true (equal? #false))
(assert-true (equal? #true))
;(assert-true (equal? #\n))
(assert-true (equal? 'foo))
(assert-true (equal? "foo"))
(assert-true (equal? 123))
2023-05-06 13:26:27 -04:00
; Two equal args
2023-05-06 15:13:35 -04:00
(assert-true (equal? '() '()))
(assert-true (equal? + +))
(assert-true (equal? (cons 123 456) (cons 123 456)))
(assert-true (equal? #false #false))
(assert-true (equal? #true #true))
;(assert-true (equal? #\n #\n))
(assert-true (equal? 'foo 'foo))
(assert-true (equal? "foo" "foo"))
(assert-true (equal? 123 123))
2023-05-06 13:26:27 -04:00
; Two different args
2023-05-06 15:13:35 -04:00
(assert-false (equal? '() '(1)))
(assert-false (equal? + -))
(assert-false (equal? (cons 123 456) (cons 123 789)))
(assert-false (equal? #false #true))
(assert-false (equal? #true #false))
;(assert-false (equal? #\n #\t))
(assert-false (equal? 'foo 'bar))
(assert-false (equal? "foo" "bar"))
(assert-false (equal? 123 789))
2023-05-06 13:26:27 -04:00
; Three equal args
2023-05-06 15:13:35 -04:00
(assert-true (equal? '() '() '()))
(assert-true (equal? + + +))
(assert-true (equal? (cons 123 456) (cons 123 456) (cons 123 456)))
(assert-true (equal? #false #false #false))
(assert-true (equal? #true #true #true))
;(assert-true (equal? #\n #\n #\n))
(assert-true (equal? 'foo 'foo 'foo))
(assert-true (equal? "foo" "foo" "foo"))
(assert-true (equal? 123 123 123))
2023-05-06 13:26:27 -04:00
; Three different args
2023-05-06 15:13:35 -04:00
(assert-false (equal? '() '() '(1)))
(assert-false (equal? + + -))
(assert-false (equal? (cons 123 456) (cons 123 456) (cons 123 789)))
(assert-false (equal? #false #false #true))
(assert-false (equal? #true #true #false))
;(assert-false (equal? #\n #\n #\t))
(assert-false (equal? 'foo 'foo 'bar))
(assert-false (equal? "foo" "foo" "bar"))
(assert-false (equal? 123 123 789))
2023-05-06 13:26:27 -04:00
)