diff options
| author | Mistivia <i@mistivia.com> | 2025-06-23 20:29:57 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-23 20:29:57 +0800 |
| commit | 15821fd796d3f1e1b14bbb4aa32715aab4f49c56 (patch) | |
| tree | 996f215d25d5897c3b666df4fdb48d198072b1d2 /tests | |
| parent | 69e9065635b1c20fe0f973bdebeb2745171bace1 (diff) | |
add string functions
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/string.lisp | 29 | ||||
| -rw-r--r-- | tests/tailcall-big.lisp | 24 | ||||
| -rw-r--r-- | tests/tailcall.lisp | 2 | ||||
| -rw-r--r-- | tests/test.lisp | 5 |
4 files changed, 34 insertions, 26 deletions
diff --git a/tests/string.lisp b/tests/string.lisp new file mode 100644 index 0000000..a55e558 --- /dev/null +++ b/tests/string.lisp @@ -0,0 +1,29 @@ +(assert (equal "abc" (string #\a #\b #\c))) +(assert (equal "ABC" (string 65 66 67))) + +(assert (string= "abc" (string #\a #\b #\c))) +(assert (string= "ABC" (string 65 66 67))) + +(defvar s1 "a1s") +(defvar s2 "a2s") + +(assert (string= s1 s1)) +(assert (string>= s1 s1)) +(assert (string<= s1 s1)) +(assert (string> s2 s1)) +(assert (string>= s2 s1)) +(assert (string< s1 s2)) +(assert (string<= s1 s2)) +(assert (string/= s1 s2)) + +(assert (not (string/= s1 s1))) +(assert (not (string< s1 s1))) +(assert (not (string> s1 s1))) +(assert (not (string<= s2 s1))) +(assert (not (string< s2 s1))) +(assert (not (string>= s1 s2))) +(assert (not (string> s1 s2))) + +(assert (string= "abc" (strip-string "\n\tabc \t\n"))) +(assert (equal ("a" "b" "c") (split-string "a,b,c" #\,))) + diff --git a/tests/tailcall-big.lisp b/tests/tailcall-big.lisp deleted file mode 100644 index ebf64c6..0000000 --- a/tests/tailcall-big.lisp +++ /dev/null @@ -1,24 +0,0 @@ -(assert (is-even 10000)) -(assert (cnt-down 10000)) - -;; can pass without stack overflow, -;; but comment out for too time-consuming -;; (assert (is-even 1000000)) -;; (assert (cnt-down 1000000)) - -(let ((my-evenp - (lambda (x) - (if (= x 0) - #t - (funcall my-oddp (- x 1))))) - (my-oddp - (lambda (x) - (if (= x 0) - #f - (funcall my-evenp (- x 1)))))) - (assert (funcall my-evenp 10000)) - (assert (funcall my-oddp 10009)) - (assert (not (funcall my-evenp 10009))) - (assert (not (funcall my-oddp 10000)))) - - diff --git a/tests/tailcall.lisp b/tests/tailcall.lisp index 1aa5e38..1b39fb0 100644 --- a/tests/tailcall.lisp +++ b/tests/tailcall.lisp @@ -6,6 +6,7 @@ (defun is-odd (x) (is-even (- x 1))) +(assert (is-even 100)) (assert (is-even 10)) (assert (is-even 0)) (assert (is-odd 1)) @@ -17,3 +18,4 @@ (progn (cnt-down (- x 1))))) +(cnt-down 100) diff --git a/tests/test.lisp b/tests/test.lisp index 614fcec..a303ed3 100644 --- a/tests/test.lisp +++ b/tests/test.lisp @@ -12,12 +12,12 @@ (test-module error) (test-module logic) (test-module tailcall) -(test-module tailcall-big) (test-module control-flow) (test-module lambda) (test-module comment) (test-module macro) (test-module let-binding) +(test-module string) (princ "\n\nTest with intensive GC:\n\n") (_alwaysgc #t) @@ -26,13 +26,14 @@ (test-module symbol) (test-module eq) (test-module arithmetic) -(test-module tailcall) (test-module error) (test-module logic) +(test-module tailcall) (test-module control-flow) (test-module lambda) (test-module comment) (test-module macro) (test-module let-binding) +(test-module string) (exit) |
