diff options
| author | Mistivia <i@mistivia.com> | 2025-12-27 01:45:03 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-12-27 01:45:03 +0800 |
| commit | 0ab2f1ed9db065dac95f8827df0ef523a8597bd9 (patch) | |
| tree | 52377c351db11317c364798c1df0a00fd44ca48a /tests | |
| parent | 1232e077f5273d86600cb4a4c34269310f9f2b9f (diff) | |
exts
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/dict.lisp | 15 | ||||
| -rw-r--r-- | tests/io-test-input.txt | 3 | ||||
| -rw-r--r-- | tests/io.lisp | 13 | ||||
| -rw-r--r-- | tests/test.lisp | 4 | ||||
| -rw-r--r-- | tests/vector.lisp | 2 |
5 files changed, 35 insertions, 2 deletions
diff --git a/tests/dict.lisp b/tests/dict.lisp new file mode 100644 index 0000000..379863e --- /dev/null +++ b/tests/dict.lisp @@ -0,0 +1,15 @@ +(defvar d (make-dict)) + +(dict-set d "a" 1) +(dict-set d "b" 2) +(dict-set d "c" 3) + +(assert (equal? (dict-keys d) (list "a" "b" "c"))) +(assert (equal? (dict-get d "a") 1)) +(assert (equal? (dict-get d "b") 2)) +(dict-set d "a" 5) +(assert (equal? (dict-get d "a") 5)) + +(dict-remove d "b") + +(assert (equal? (dict-keys d) (list "a" "c")))
\ No newline at end of file diff --git a/tests/io-test-input.txt b/tests/io-test-input.txt new file mode 100644 index 0000000..9e9f1b9 --- /dev/null +++ b/tests/io-test-input.txt @@ -0,0 +1,3 @@ +abc +1234 +123
\ No newline at end of file diff --git a/tests/io.lisp b/tests/io.lisp new file mode 100644 index 0000000..9a7d3dc --- /dev/null +++ b/tests/io.lisp @@ -0,0 +1,13 @@ +(defvar fp (open-file "./tests/io-test-input.txt" "r")) +(assert (char= #\a (read-char fp))) +(assert (char= #\b (read-char fp))) +(assert (char= #\c (read-char fp))) +(stream-close fp) + +(defvar fp (open-file "./tests/io-test-input.txt" "r")) +(assert (string= "abc" (read-line fp))) +(stream-close fp) + +(defvar fp (open-file "./tests/io-test-input.txt" "r")) +(assert (equal? (list "abc" "1234" "123") (lines fp))) +(stream-close fp)
\ No newline at end of file diff --git a/tests/test.lisp b/tests/test.lisp index 241f69c..f97acba 100644 --- a/tests/test.lisp +++ b/tests/test.lisp @@ -23,6 +23,8 @@ (test-module char) (test-module bitwise) (test-module vector) +(test-module dict) +(test-module io) (princ "\n\nTest with intensive GC:\n\n") (_alwaysgc #t) @@ -45,5 +47,7 @@ (test-module char) (test-module bitwise) (test-module vector) +(test-module dict) +(test-module io) (exit) diff --git a/tests/vector.lisp b/tests/vector.lisp index 10afde4..d4f7231 100644 --- a/tests/vector.lisp +++ b/tests/vector.lisp @@ -1,5 +1,3 @@ -(loadext "ext_example/vector.so") - (assert (vector? (make-vector))) (assert (not (vector? 1))) |
