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

32 lines
1.1 KiB
Scheme

;;; frozen? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-true (frozen? +))
(assert-true (frozen? (lambda (x) x)))
(assert-true (frozen? '()))
(assert-true (frozen? #false))
;(assert-true (frozen? #\n))
(assert-true (frozen? 'foo))
(assert-false (frozen? "foo"))
(assert-true (frozen? 123))
(assert-false (frozen? (cons 123 456)))
;;; freeze ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-equal + (freeze +))
(let ([f (lambda (x) x)])
(assert-equal f (freeze f)))
(assert-equal '() (freeze '()))
(assert-equal #false (freeze #false))
;(assert-equal #\n (freeze #\n))
(assert-equal 'foo (freeze 'foo))
(assert-equal "foo" (freeze "foo"))
(assert-equal 123 (freeze 123))
(assert-equal (cons 123 456) (freeze (cons 123 456)))
(assert-true (frozen? (freeze +)))
(assert-true (frozen? (freeze (lambda (x) x))))
(assert-true (frozen? (freeze '())))
(assert-true (frozen? (freeze #false)))
;(assert-true (frozen? (freeze #\n)))
(assert-true (frozen? (freeze 'foo)))
(assert-true (frozen? (freeze "foo")))
(assert-true (frozen? (freeze 123)))
(assert-true (frozen? (freeze (cons 123 456))))