1
0
Fork 0

Improve tests

This commit is contained in:
Alex Kotov 2023-05-07 16:56:04 +04:00
parent e87d6d6083
commit 6941128db3
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 39 additions and 38 deletions

View file

@ -25,6 +25,7 @@ test: arcana-lisp
$(CAT) tests/arcana.scm | ./arcana-lisp
$(CAT) tests/arcana/builtin.scm | ./arcana-lisp
$(CAT) tests/arcana/tokenize.scm | ./arcana-lisp
$(CAT) tests/arcana/parse.scm | ./arcana-lisp
$(CAT) tests/arithm_ops.scm | ./arcana-lisp
$(CAT) tests/basic_data_structs.scm | ./arcana-lisp
$(CAT) tests/equiv.scm | ./arcana-lisp

View file

@ -1,42 +1,4 @@
(begin
;;; arcana/parse ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-equal
(arcana/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 ")")))
'(displayln (+ 123 456)))
(assert-equal
(quote
(quasiquote
(cons
(unquote (+ 12 34))
(unquote (+ 56 78)))))
(arcana/parse
(list
(cons 'TOKEN_QUASI_QUOTE "`")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "cons")
(cons 'TOKEN_QUASI_UNQUOTE ",")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "+")
(cons 'TOKEN_NUM "12")
(cons 'TOKEN_NUM "34")
(cons 'TOKEN_ROUND_CLOSE ")")
(cons 'TOKEN_QUASI_UNQUOTE ",")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "+")
(cons 'TOKEN_NUM "56")
(cons 'TOKEN_NUM "78")
(cons 'TOKEN_ROUND_CLOSE ")")
(cons 'TOKEN_ROUND_CLOSE ")"))))
;;; arcana/typeof ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(assert-equal 'null (arcana/typeof '()))
(assert-equal 'procedure (arcana/typeof +))

38
tests/arcana/parse.scm Normal file
View file

@ -0,0 +1,38 @@
(begin
(assert-equal
'(displayln (+ 123 456))
(arcana/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 ")"))))
(assert-equal
'(quasiquote
(cons
(unquote (+ 12 34))
(unquote (+ 56 78))))
(arcana/parse
(list
(cons 'TOKEN_QUASI_QUOTE "`")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "cons")
(cons 'TOKEN_QUASI_UNQUOTE ",")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "+")
(cons 'TOKEN_NUM "12")
(cons 'TOKEN_NUM "34")
(cons 'TOKEN_ROUND_CLOSE ")")
(cons 'TOKEN_QUASI_UNQUOTE ",")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "+")
(cons 'TOKEN_NUM "56")
(cons 'TOKEN_NUM "78")
(cons 'TOKEN_ROUND_CLOSE ")")
(cons 'TOKEN_ROUND_CLOSE ")"))))
)