Verified Commit 116019cf authored by Vladimir Sedach's avatar Vladimir Sedach
Browse files

Added misc unit tests

parent 59d82b98
......@@ -779,3 +779,24 @@
(test-js-eval dotimes-block-return
(1+ (dotimes (x 3) (if (= x 2) (return (+ x x)))))
5)
(test-js-eval labels-factorial
(progn
(defun fac (n)
(labels ((f (n a)
(if (< n 2)
a
(f (- n 1) (* n a)))))
(f n 1)))
(fac 5))
120)
(test-js-eval destructuring-bind1
((lambda (a)
(when a
(destructuring-bind (b . c)
a
(list b c))))
'(1 2 3))
'(1 (2 3)))
......@@ -2512,9 +2512,8 @@ return x;
(test-ps-js return-macrolet1
(defun foo ()
(return-from foo
(symbol-macrolet ((x 2))
(loop do (+ x x)))))
(symbol-macrolet ((x 2))
(loop do (+ x x))))
"function foo() {
while (true) {
2 + 2;
......@@ -2704,6 +2703,21 @@ try {
};
};")
(test-ps-js try-finally-return-from
(defun xyz ()
(return-from xyz
(ps:try (when (blah) 4)
(:finally (foo))))
(dont-call-me))
"function xyz() {
try {
return blah() ? 4 : null;
} finally {
foo();
};
return dontCallMe();
};")
(test-ps-js defun-setf-optional
(defun (setf foo) (new-value b &optional c)
(setf (aref b (or c 0)) new-value))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment