1
0
Fork 0
lesson-lisp/tests/type_preds.scm
2023-05-07 18:13:37 +04:00

87 lines
2.8 KiB
Scheme

;;; boolean? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-false (boolean? +))
(assert-false (boolean? '()))
(assert-true (boolean? #true))
(assert-true (boolean? #false))
;(assert-false (boolean? #\n))
(assert-false (boolean? 'foo))
(assert-false (boolean? "foo"))
(assert-false (boolean? 123))
(assert-false (boolean? (cons 123 456)))
;;; char? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-false (char? +))
(assert-false (char? '()))
(assert-false (char? #true))
(assert-false (char? #false))
;(assert-true (char? #\n))
(assert-false (char? 'foo))
(assert-false (char? "foo"))
(assert-false (char? 123))
(assert-false (char? (cons 123 456)))
;;; null? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-false (null? +))
(assert-true (null? '()))
(assert-false (null? #true))
(assert-false (null? #false))
;(assert-false (null? #\n))
(assert-false (null? 'foo))
(assert-false (null? "foo"))
(assert-false (null? 123))
(assert-false (null? (cons 123 456)))
;;; number? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-false (number? +))
(assert-false (number? '()))
(assert-false (number? #true))
(assert-false (number? #false))
;(assert-false (number? #\n))
(assert-false (number? 'foo))
(assert-false (number? "foo"))
(assert-true (number? 123))
(assert-false (number? (cons 123 456)))
;;; pair? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-false (pair? +))
(assert-false (pair? '()))
(assert-false (pair? #true))
(assert-false (pair? #false))
;(assert-false (pair? #\n))
(assert-false (pair? 'foo))
(assert-false (pair? "foo"))
(assert-false (pair? 123))
(assert-true (pair? (cons 123 456)))
;;; procedure? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-true (procedure? +))
(assert-false (procedure? '()))
(assert-false (procedure? #true))
(assert-false (procedure? #false))
;(assert-false (procedure? #\n))
(assert-false (procedure? 'foo))
(assert-false (procedure? "foo"))
(assert-false (procedure? 123))
(assert-false (procedure? (cons 123 456)))
;;; string? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-false (string? +))
(assert-false (string? '()))
(assert-false (string? #true))
(assert-false (string? #false))
;(assert-false (string? #\n))
(assert-false (string? 'foo))
(assert-true (string? "foo"))
(assert-false (string? 123))
(assert-false (string? (cons 123 456)))
;;; symbol? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-false (symbol? +))
(assert-false (symbol? '()))
(assert-false (symbol? #true))
(assert-false (symbol? #false))
;(assert-false (symbol? #\n))
(assert-true (symbol? 'foo))
(assert-false (symbol? "foo"))
(assert-false (symbol? 123))
(assert-false (symbol? (cons 123 456)))