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

49 lines
2.2 KiB
Scheme

(assert-true (null? (arcana/builtin 'foobar)))
; Testing some builtin procedures for sanity
(assert-equal '(1 2 3) ((arcana/builtin 'list) 1 2 3))
(assert-true ((arcana/builtin 'boolean?) #false))
(assert-true ((arcana/builtin 'number?) 123))
(assert-equal "123456" ((arcana/builtin 'number->string) 123456))
(assert-equal 'foobar ((arcana/builtin 'string->symbol) "foobar"))
(assert-equal "foobar" ((arcana/builtin 'symbol->string) 'foobar))
; Assertions
(assert-true (procedure? (arcana/builtin 'assert-equal)))
(assert-true (procedure? (arcana/builtin 'assert-false)))
(assert-true (procedure? (arcana/builtin 'assert-true)))
; Arcana Lisp internals
(assert-true (procedure? (arcana/builtin 'arcana/builtin)))
(assert-true (procedure? (arcana/builtin 'arcana/parse)))
(assert-true (procedure? (arcana/builtin 'arcana/tokenize)))
(assert-true (procedure? (arcana/builtin 'arcana/typeof)))
; Basic data structures
(assert-true (procedure? (arcana/builtin 'car)))
(assert-true (procedure? (arcana/builtin 'cdr)))
(assert-true (procedure? (arcana/builtin 'cons)))
(assert-true (procedure? (arcana/builtin 'list)))
; Type predicates
(assert-true (procedure? (arcana/builtin 'boolean?)))
(assert-true (procedure? (arcana/builtin 'char?)))
(assert-true (procedure? (arcana/builtin 'null?)))
(assert-true (procedure? (arcana/builtin 'number?)))
(assert-true (procedure? (arcana/builtin 'pair?)))
(assert-true (procedure? (arcana/builtin 'procedure?)))
(assert-true (procedure? (arcana/builtin 'string?)))
(assert-true (procedure? (arcana/builtin 'symbol?)))
; Equivalence predicates
(assert-true (procedure? (arcana/builtin 'equal?)))
; Type conversion
(assert-true (procedure? (arcana/builtin 'number->string)))
(assert-true (procedure? (arcana/builtin 'string->symbol)))
(assert-true (procedure? (arcana/builtin 'symbol->string)))
; Logical operators
(assert-true (procedure? (arcana/builtin 'not)))
; Arithmetic operators
(assert-true (procedure? (arcana/builtin '=)))
(assert-true (procedure? (arcana/builtin '+)))
(assert-true (procedure? (arcana/builtin '-)))
; IO
(assert-true (procedure? (arcana/builtin 'display)))
(assert-true (procedure? (arcana/builtin 'displayln)))
(assert-true (procedure? (arcana/builtin 'newline)))