229 lines
7.6 KiB
Scheme
229 lines
7.6 KiB
Scheme
(begin
|
|
(displayln "Hello, World!")
|
|
(newline)
|
|
(displayln "=== GROUP: Syntax ==============================================")
|
|
(newline)
|
|
(displayln "--- TEST: begin ------------------------------------------------")
|
|
(displayln (begin))
|
|
(displayln (begin 123))
|
|
(displayln (begin 123 456))
|
|
(displayln (begin 123 456 789))
|
|
(newline)
|
|
(displayln "--- TEST: if ---------------------------------------------------")
|
|
(displayln (if #true 123 456))
|
|
(displayln (if "foo" 123 456))
|
|
(displayln (if #false 123 456))
|
|
(newline)
|
|
(displayln "--- TEST: quote ------------------------------------------------")
|
|
(displayln (quote +))
|
|
(displayln '+)
|
|
(displayln (quote ()))
|
|
(displayln '())
|
|
(displayln (quote #true))
|
|
(displayln '#true)
|
|
(displayln (quote #false))
|
|
(displayln '#false)
|
|
;(displayln (quote #\n))
|
|
;(displayln '#\n)
|
|
(displayln (quote foo))
|
|
(displayln 'foo)
|
|
(displayln (quote "foo"))
|
|
(displayln '"foo")
|
|
(displayln (quote 123))
|
|
(displayln '123)
|
|
(displayln (quote (cons 123 456)))
|
|
(displayln '(cons 123 456))
|
|
(newline)
|
|
(displayln "=== GROUP: Arcane Scheme Lisp internals ========================")
|
|
(newline)
|
|
(displayln "--- TEST: arcane/parse -----------------------------------------")
|
|
(displayln
|
|
(arcane/parse
|
|
(list
|
|
(cons 'TOKEN_ROUND_OPEN "(")
|
|
(cons 'TOKEN_IDENT "displayln")
|
|
(cons 'TOKEN_ROUND_OPEN "(")
|
|
(cons 'TOKEN_IDENT "+")
|
|
(cons 'TOKEN_NUM "123")
|
|
(cons 'TOKEN_NUM "456")
|
|
(cons 'TOKEN_ROUND_CLOSE ")")
|
|
(cons 'TOKEN_ROUND_CLOSE ")"))))
|
|
(newline)
|
|
(displayln "--- TEST: arcane/tokenize --------------------------------------")
|
|
(displayln (arcane/tokenize "("))
|
|
(displayln (arcane/tokenize "#false"))
|
|
;(displayln (arcane/tokenize "\"\""))
|
|
;(displayln (arcane/tokenize "\"qwe\""))
|
|
(displayln (arcane/tokenize "(displayln (list 1))"))
|
|
(newline)
|
|
(displayln "--- TEST: arcane/typeof ----------------------------------------")
|
|
(displayln (arcane/typeof '()))
|
|
(displayln (arcane/typeof +))
|
|
(displayln (arcane/typeof (cons 123 456)))
|
|
(displayln (arcane/typeof #false))
|
|
;(displayln (arcane/typeof #\n))
|
|
(displayln (arcane/typeof 'foo))
|
|
(displayln (arcane/typeof "foo"))
|
|
(displayln (arcane/typeof 123))
|
|
(newline)
|
|
(displayln "=== GROUP: Basic data structures ===============================")
|
|
(newline)
|
|
(displayln "--- TEST: car --------------------------------------------------")
|
|
(displayln (car (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: cdr --------------------------------------------------")
|
|
(displayln (cdr (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: list -------------------------------------------------")
|
|
(displayln (list))
|
|
(displayln (list 123))
|
|
(displayln (list 123 456))
|
|
(newline)
|
|
(displayln "=== GROUP: Type predicates =====================================")
|
|
(newline)
|
|
(displayln "--- TEST: boolean? ---------------------------------------------")
|
|
(displayln (boolean? +))
|
|
(displayln (boolean? '()))
|
|
(displayln (boolean? #true))
|
|
(displayln (boolean? #false))
|
|
;(displayln (boolean? #\n))
|
|
(displayln (boolean? 'foo))
|
|
(displayln (boolean? "foo"))
|
|
(displayln (boolean? 123))
|
|
(displayln (boolean? (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: char? ------------------------------------------------")
|
|
(displayln (char? +))
|
|
(displayln (char? '()))
|
|
(displayln (char? #true))
|
|
(displayln (char? #false))
|
|
;(displayln (char? #\n))
|
|
(displayln (char? 'foo))
|
|
(displayln (char? "foo"))
|
|
(displayln (char? 123))
|
|
(displayln (char? (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: null? ------------------------------------------------")
|
|
(displayln (null? +))
|
|
(displayln (null? '()))
|
|
(displayln (null? #true))
|
|
(displayln (null? #false))
|
|
;(displayln (null? #\n))
|
|
(displayln (null? 'foo))
|
|
(displayln (null? "foo"))
|
|
(displayln (null? 123))
|
|
(displayln (null? (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: number? ----------------------------------------------")
|
|
(displayln (number? +))
|
|
(displayln (number? '()))
|
|
(displayln (number? #true))
|
|
(displayln (number? #false))
|
|
;(displayln (number? #\n))
|
|
(displayln (number? 'foo))
|
|
(displayln (number? "foo"))
|
|
(displayln (number? 123))
|
|
(displayln (number? (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: pair? ------------------------------------------------")
|
|
(displayln (pair? +))
|
|
(displayln (pair? '()))
|
|
(displayln (pair? #true))
|
|
(displayln (pair? #false))
|
|
;(displayln (pair? #\n))
|
|
(displayln (pair? 'foo))
|
|
(displayln (pair? "foo"))
|
|
(displayln (pair? 123))
|
|
(displayln (pair? (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: procedure? -------------------------------------------")
|
|
(displayln (procedure? +))
|
|
(displayln (procedure? '()))
|
|
(displayln (procedure? #true))
|
|
(displayln (procedure? #false))
|
|
;(displayln (procedure? #\n))
|
|
(displayln (procedure? 'foo))
|
|
(displayln (procedure? "foo"))
|
|
(displayln (procedure? 123))
|
|
(displayln (procedure? (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: string? ----------------------------------------------")
|
|
(displayln (string? +))
|
|
(displayln (string? '()))
|
|
(displayln (string? #true))
|
|
(displayln (string? #false))
|
|
;(displayln (string? #\n))
|
|
(displayln (string? 'foo))
|
|
(displayln (string? "foo"))
|
|
(displayln (string? 123))
|
|
(displayln (string? (cons 123 456)))
|
|
(newline)
|
|
(displayln "--- TEST: symbol? ----------------------------------------------")
|
|
(displayln (symbol? +))
|
|
(displayln (symbol? '()))
|
|
(displayln (symbol? #true))
|
|
(displayln (symbol? #false))
|
|
;(displayln (symbol? #\n))
|
|
(displayln (symbol? 'foo))
|
|
(displayln (symbol? "foo"))
|
|
(displayln (symbol? 123))
|
|
(displayln (symbol? (cons 123 456)))
|
|
(newline)
|
|
(displayln "=== GROUP: Type conversion =====================================")
|
|
(newline)
|
|
(displayln "--- TEST: number->string ---------------------------------------")
|
|
(displayln (number->string 123))
|
|
;(displayln (number->string -123))
|
|
(displayln (number->string 123456 16))
|
|
(newline)
|
|
(displayln "--- TEST: string->symbol ---------------------------------------")
|
|
(displayln (string->symbol ""))
|
|
(displayln (string->symbol " "))
|
|
(displayln (string->symbol "foo"))
|
|
(newline)
|
|
(displayln "--- TEST: symbol->string ---------------------------------------")
|
|
(displayln (symbol->string 'foo))
|
|
(newline)
|
|
(displayln "=== GROUP: Logical operators ===================================")
|
|
(newline)
|
|
(displayln "--- TEST: not --------------------------------------------------")
|
|
(displayln (not '()))
|
|
(displayln (not #true))
|
|
(displayln (not #false))
|
|
;(displayln (not #\n))
|
|
(displayln (not 'foo))
|
|
(displayln (not "foo"))
|
|
(displayln (not 123))
|
|
(displayln (not (cons 123 456)))
|
|
(newline)
|
|
(displayln "=== GROUP: Arithmetic operators ================================")
|
|
(newline)
|
|
(displayln "--- TEST: = ----------------------------------------------------")
|
|
(displayln(= 123))
|
|
(displayln(= 123 123))
|
|
(displayln(= 123 456))
|
|
(displayln(= 123 123 123))
|
|
(displayln(= 456 123 123))
|
|
(displayln(= 123 456 123))
|
|
(displayln(= 123 123 456))
|
|
(displayln(= 123 123 123 123))
|
|
(displayln(= 456 123 123 123))
|
|
(displayln(= 123 456 123 123))
|
|
(displayln(= 123 123 456 123))
|
|
(displayln(= 123 123 123 456))
|
|
(newline)
|
|
(displayln "--- TEST: + ----------------------------------------------------")
|
|
(displayln (+))
|
|
(displayln (+ 123))
|
|
(displayln (+ 1 10))
|
|
(displayln (+ 1 10 100))
|
|
(displayln (+ 1 10 100 1000))
|
|
(newline)
|
|
(displayln "--- TEST: - ----------------------------------------------------")
|
|
(displayln (- 0))
|
|
(displayln (- 123))
|
|
(displayln (- 100 1))
|
|
(displayln (- 100 1 2))
|
|
(displayln (- 100 1 2 3))
|
|
(displayln (- 100 1 2 3 4))
|
|
)
|