Split Scheme Lisp tests
This commit is contained in:
parent
cee72a9c82
commit
8bb9e7cfa3
20 changed files with 426 additions and 442 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,6 +1,5 @@
|
|||
/src/*.o
|
||||
|
||||
/arcane-scheme-lisp
|
||||
/arcane-scheme-lisp-test
|
||||
|
||||
/test.out
|
||||
/src/*.o
|
||||
/tests/*.out
|
||||
|
|
31
Makefile
31
Makefile
|
@ -7,10 +7,6 @@ RM_F = rm -f
|
|||
|
||||
CFLAGS = -Wall -Wextra
|
||||
|
||||
TEST_SCM = test.scm
|
||||
TEST_EXP = test.txt
|
||||
TEST_OUT = test.out
|
||||
|
||||
OBJS = \
|
||||
src/builtins.c.o \
|
||||
src/ctype.c.o \
|
||||
|
@ -21,19 +17,35 @@ OBJS = \
|
|||
src/syntax.c.o \
|
||||
src/tokens.c.o
|
||||
|
||||
TEST_OUTS = \
|
||||
tests/arithm_ops.out \
|
||||
tests/basic_data_structs.out \
|
||||
tests/hello.out \
|
||||
tests/arcane.out \
|
||||
tests/logic_ops.out \
|
||||
tests/syntax.out \
|
||||
tests/type_conv.out \
|
||||
tests/type_preds.out
|
||||
|
||||
MAIN_OBJS = $(OBJS) src/main.c.o
|
||||
TEST_OBJS = $(OBJS) src/main-test.c.o
|
||||
|
||||
repl: arcane-scheme-lisp
|
||||
./arcane-scheme-lisp
|
||||
|
||||
test: arcane-scheme-lisp arcane-scheme-lisp-test
|
||||
test: arcane-scheme-lisp-test $(TEST_OUTS)
|
||||
./arcane-scheme-lisp-test
|
||||
$(CAT) $(TEST_SCM) | ./arcane-scheme-lisp > $(TEST_OUT)
|
||||
$(DIFF_Q) $(TEST_EXP) $(TEST_OUT)
|
||||
$(DIFF_Q) tests/arithm_ops.txt tests/arithm_ops.out
|
||||
$(DIFF_Q) tests/basic_data_structs.txt tests/basic_data_structs.out
|
||||
$(DIFF_Q) tests/hello.txt tests/hello.out
|
||||
$(DIFF_Q) tests/arcane.txt tests/arcane.out
|
||||
$(DIFF_Q) tests/logic_ops.txt tests/logic_ops.out
|
||||
$(DIFF_Q) tests/syntax.txt tests/syntax.out
|
||||
$(DIFF_Q) tests/type_conv.txt tests/type_conv.out
|
||||
$(DIFF_Q) tests/type_preds.txt tests/type_preds.out
|
||||
|
||||
clean:
|
||||
$(RM_F) arcane-scheme-lisp arcane-scheme-lisp-test $(MAIN_OBJS) $(TEST_OBJS) $(TEST_OUT)
|
||||
$(RM_F) arcane-scheme-lisp arcane-scheme-lisp-test $(MAIN_OBJS) $(TEST_OBJS) $(TEST_OUTS)
|
||||
|
||||
arcane-scheme-lisp: $(MAIN_OBJS)
|
||||
$(CC) -o $@ $^ $(CFLAGS)
|
||||
|
@ -43,3 +55,6 @@ arcane-scheme-lisp-test: $(TEST_OBJS)
|
|||
|
||||
%.c.o: %.c
|
||||
$(CC) -c $< -o $@ $(CFLAGS)
|
||||
|
||||
tests/%.out: tests/%.scm arcane-scheme-lisp
|
||||
$(CAT) $< | ./arcane-scheme-lisp > $@
|
||||
|
|
229
test.scm
229
test.scm
|
@ -1,229 +0,0 @@
|
|||
(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))
|
||||
)
|
202
test.txt
202
test.txt
|
@ -1,202 +0,0 @@
|
|||
"Hello, World!"
|
||||
|
||||
"=== GROUP: Syntax =============================================="
|
||||
|
||||
"--- TEST: begin ------------------------------------------------"
|
||||
()
|
||||
123
|
||||
456
|
||||
789
|
||||
|
||||
"--- TEST: if ---------------------------------------------------"
|
||||
123
|
||||
123
|
||||
456
|
||||
|
||||
"--- TEST: quote ------------------------------------------------"
|
||||
+
|
||||
+
|
||||
()
|
||||
()
|
||||
#true
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
foo
|
||||
foo
|
||||
"foo"
|
||||
"foo"
|
||||
123
|
||||
123
|
||||
(cons 123 456)
|
||||
(cons 123 456)
|
||||
|
||||
"=== GROUP: Arcane Scheme Lisp internals ========================"
|
||||
|
||||
"--- TEST: arcane/parse -----------------------------------------"
|
||||
(displayln (+ 123 456))
|
||||
|
||||
"--- TEST: arcane/tokenize --------------------------------------"
|
||||
((TOKEN_ROUND_OPEN . "("))
|
||||
((TOKEN_TAG . "false"))
|
||||
((TOKEN_ROUND_OPEN . "(") (TOKEN_IDENT . "displayln") (TOKEN_ROUND_OPEN . "(") (TOKEN_IDENT . "list") (TOKEN_NUM . "1") (TOKEN_ROUND_CLOSE . ")") (TOKEN_ROUND_CLOSE . ")"))
|
||||
|
||||
"--- TEST: arcane/typeof ----------------------------------------"
|
||||
null
|
||||
procedure
|
||||
pair
|
||||
boolean
|
||||
symbol
|
||||
string
|
||||
number
|
||||
|
||||
"=== GROUP: Basic data structures ==============================="
|
||||
|
||||
"--- TEST: car --------------------------------------------------"
|
||||
123
|
||||
|
||||
"--- TEST: cdr --------------------------------------------------"
|
||||
456
|
||||
|
||||
"--- TEST: list -------------------------------------------------"
|
||||
()
|
||||
(123)
|
||||
(123 456)
|
||||
|
||||
"=== GROUP: Type predicates ====================================="
|
||||
|
||||
"--- TEST: boolean? ---------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: char? ------------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: null? ------------------------------------------------"
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: number? ----------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
|
||||
"--- TEST: pair? ------------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
|
||||
"--- TEST: procedure? -------------------------------------------"
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: string? ----------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: symbol? ----------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"=== GROUP: Type conversion ====================================="
|
||||
|
||||
"--- TEST: number->string ---------------------------------------"
|
||||
"123"
|
||||
"1e240"
|
||||
|
||||
"--- TEST: string->symbol ---------------------------------------"
|
||||
|
||||
|
||||
foo
|
||||
|
||||
"--- TEST: symbol->string ---------------------------------------"
|
||||
"foo"
|
||||
|
||||
"=== GROUP: Logical operators ==================================="
|
||||
|
||||
"--- TEST: not --------------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"=== GROUP: Arithmetic operators ================================"
|
||||
|
||||
"--- TEST: = ----------------------------------------------------"
|
||||
#true
|
||||
#true
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: + ----------------------------------------------------"
|
||||
0
|
||||
123
|
||||
11
|
||||
111
|
||||
1111
|
||||
|
||||
"--- TEST: - ----------------------------------------------------"
|
||||
0
|
||||
123
|
||||
99
|
||||
97
|
||||
94
|
||||
90
|
31
tests/arcane.scm
Normal file
31
tests/arcane.scm
Normal file
|
@ -0,0 +1,31 @@
|
|||
(begin
|
||||
(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))
|
||||
)
|
16
tests/arcane.txt
Normal file
16
tests/arcane.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
"--- TEST: arcane/parse -----------------------------------------"
|
||||
(displayln (+ 123 456))
|
||||
|
||||
"--- TEST: arcane/tokenize --------------------------------------"
|
||||
((TOKEN_ROUND_OPEN . "("))
|
||||
((TOKEN_TAG . "false"))
|
||||
((TOKEN_ROUND_OPEN . "(") (TOKEN_IDENT . "displayln") (TOKEN_ROUND_OPEN . "(") (TOKEN_IDENT . "list") (TOKEN_NUM . "1") (TOKEN_ROUND_CLOSE . ")") (TOKEN_ROUND_CLOSE . ")"))
|
||||
|
||||
"--- TEST: arcane/typeof ----------------------------------------"
|
||||
null
|
||||
procedure
|
||||
pair
|
||||
boolean
|
||||
symbol
|
||||
string
|
||||
number
|
30
tests/arithm_ops.scm
Normal file
30
tests/arithm_ops.scm
Normal file
|
@ -0,0 +1,30 @@
|
|||
(begin
|
||||
(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))
|
||||
)
|
28
tests/arithm_ops.txt
Normal file
28
tests/arithm_ops.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
"--- TEST: = ----------------------------------------------------"
|
||||
#true
|
||||
#true
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: + ----------------------------------------------------"
|
||||
0
|
||||
123
|
||||
11
|
||||
111
|
||||
1111
|
||||
|
||||
"--- TEST: - ----------------------------------------------------"
|
||||
0
|
||||
123
|
||||
99
|
||||
97
|
||||
94
|
||||
90
|
12
tests/basic_data_structs.scm
Normal file
12
tests/basic_data_structs.scm
Normal file
|
@ -0,0 +1,12 @@
|
|||
(begin
|
||||
(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))
|
||||
)
|
10
tests/basic_data_structs.txt
Normal file
10
tests/basic_data_structs.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
"--- TEST: car --------------------------------------------------"
|
||||
123
|
||||
|
||||
"--- TEST: cdr --------------------------------------------------"
|
||||
456
|
||||
|
||||
"--- TEST: list -------------------------------------------------"
|
||||
()
|
||||
(123)
|
||||
(123 456)
|
1
tests/hello.scm
Normal file
1
tests/hello.scm
Normal file
|
@ -0,0 +1 @@
|
|||
(displayln "Hello, World!")
|
1
tests/hello.txt
Normal file
1
tests/hello.txt
Normal file
|
@ -0,0 +1 @@
|
|||
"Hello, World!"
|
11
tests/logic_ops.scm
Normal file
11
tests/logic_ops.scm
Normal file
|
@ -0,0 +1,11 @@
|
|||
(begin
|
||||
(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)))
|
||||
)
|
8
tests/logic_ops.txt
Normal file
8
tests/logic_ops.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
"--- TEST: not --------------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
32
tests/syntax.scm
Normal file
32
tests/syntax.scm
Normal file
|
@ -0,0 +1,32 @@
|
|||
(begin
|
||||
(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))
|
||||
)
|
28
tests/syntax.txt
Normal file
28
tests/syntax.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
"--- TEST: begin ------------------------------------------------"
|
||||
()
|
||||
123
|
||||
456
|
||||
789
|
||||
|
||||
"--- TEST: if ---------------------------------------------------"
|
||||
123
|
||||
123
|
||||
456
|
||||
|
||||
"--- TEST: quote ------------------------------------------------"
|
||||
+
|
||||
+
|
||||
()
|
||||
()
|
||||
#true
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
foo
|
||||
foo
|
||||
"foo"
|
||||
"foo"
|
||||
123
|
||||
123
|
||||
(cons 123 456)
|
||||
(cons 123 456)
|
14
tests/type_conv.scm
Normal file
14
tests/type_conv.scm
Normal file
|
@ -0,0 +1,14 @@
|
|||
(begin
|
||||
(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))
|
||||
)
|
11
tests/type_conv.txt
Normal file
11
tests/type_conv.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
"--- TEST: number->string ---------------------------------------"
|
||||
"123"
|
||||
"1e240"
|
||||
|
||||
"--- TEST: string->symbol ---------------------------------------"
|
||||
|
||||
|
||||
foo
|
||||
|
||||
"--- TEST: symbol->string ---------------------------------------"
|
||||
"foo"
|
89
tests/type_preds.scm
Normal file
89
tests/type_preds.scm
Normal file
|
@ -0,0 +1,89 @@
|
|||
(begin
|
||||
(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)))
|
||||
)
|
79
tests/type_preds.txt
Normal file
79
tests/type_preds.txt
Normal file
|
@ -0,0 +1,79 @@
|
|||
"--- TEST: boolean? ---------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: char? ------------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: null? ------------------------------------------------"
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: number? ----------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
|
||||
"--- TEST: pair? ------------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
|
||||
"--- TEST: procedure? -------------------------------------------"
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: string? ----------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
|
||||
"--- TEST: symbol? ----------------------------------------------"
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#false
|
||||
#true
|
||||
#false
|
||||
#false
|
||||
#false
|
Loading…
Reference in a new issue