updated multiple test files
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
hyung-hwan 2024-01-03 00:45:34 +09:00
parent 309442e307
commit 758d5e953b
4 changed files with 57 additions and 61 deletions

View File

@ -1,6 +1,2 @@
## the left brace opens a list explicitly and doesn't auto-forge a container list.
## so the semicolon after it is a redundant one. `do {};` would work because the semicolon
## terminates the auto-forged list of `do` and `{}`.
{
printf "hello, world\n";
}; ##ERROR: syntax error - unexpected semicolon
## you can't have another colon before the method..
(obj: :method) ##ERROR: syntax error - : disallowed

View File

@ -1,35 +1,35 @@
(defun repeat(n f)
(while (> n 0)
(f)
(set n (- n 1))
)
)
defun repeat(n f) {
while (> n 0) {
f;
set n (- n 1);
};
};
(defun test-non-local-ret-1(k)
(repeat 10 (lambda()
(set k (+ k 2))
(if (= k 28) (return-from-home k))
))
defun test-non-local-ret-1(k) {
repeat 10 (fun() {
set k (+ k 2);
if (= k 28) { return-from-home k };
});
(return k)
)
return k;
};
(set a (test-non-local-ret-1 20))
(if (/= a 28) (printf "ERROR: a must be 28\n"))
(printf "OK %d\n" a)
set a (test-non-local-ret-1 20);
if (/= a 28) { printf "ERROR: a must be 28\n" }
else { (printf "OK %d\n" a) };
(set a (test-non-local-ret-1 21))
(if (/= a 41) (printf "ERROR: a must be 41\n"))
(printf "OK %d\n" a)
set a (test-non-local-ret-1 21);
if (/= a 41) { printf "ERROR: a must be 41\n" }
else { printf "OK %d\n" a };
(defun ff() (return 999))
defun ff() { return 999 };
## test a normal block return
(set a (ff))
(if (/= a 999) (printf "ERROR: a must be 999\n"))
(printf "OK %d\n" a)
set a (ff);
if (/= a 999) { printf "ERROR: a must be 999\n" }
else { printf "OK %d\n" a };
## return from top-level
(return 10)
(printf "ERROR: this line must not be printed\n")
return 10;
printf "ERROR: this line must not be printed\n";

View File

@ -1,16 +1,17 @@
((lambda ()
((fun() {
## test return variables
| v1 v2 v3 i a b c d |
(set i 100)
set i 100;
(defun ff(a b ::: x y z)
(set x (+ a b i))
(set y (+ x x))
(set z (+ 999 i))
(set i (* i 10))
)
defun ff(a b ::: x y z) {
set x (+ a b i);
set y (+ x x);
set z (+ 999 i);
set i (* i 10);
};
(set-r v1 v2 v3 (ff 10 20))
(if (/= v1 130) (printf "ERROR: v1 must be 130\n"))
@ -28,22 +29,21 @@
## test return variables in message sends
(defclass B
::: | X1 X2 |
defclass B ::: | X1 X2 | {
(set X1 999)
(set X2 888)
set X1 999;
set X2 888;
(defun ::: get ( ::: x y)
defun ::: get ( ::: x y) {
(set x X1)
(set y X2)
)
};
(defun ::: get2 (inc ::: x y)
defun ::: get2 (inc ::: x y) {
(set x (+ X1 inc))
(set y (+ X2 inc))
)
)
};
};
(set-r a b (:B get))
(set-r c d (:B get2 -100))
@ -53,5 +53,5 @@
(if (/= c 899) (printf "ERROR: c must be 899\n"))
(if (/= d 788) (printf "ERROR: d must be 788\n"))
(printf "OK a=%d b=%d c=%d d=%d\n" a b c d)
))
printf "OK a=%d b=%d c=%d d=%d\n" a b c d;
}));

View File

@ -1,28 +1,28 @@
(defun fn-y (t1 t2 va-ctx)
defun fn-y (t1 t2 va-ctx) {
| i |
(set i 0)
(while (< i (va-count va-ctx))
set i 0;
while (< i (va-count va-ctx)) {
(printf "fn-y=>Y-VA[%d]=>[%d]\n" i (va-get i va-ctx))
(set i (+ i 1))
)
)
};
};
(defun x(a b ... ::: x y z)
defun x(a b ... ::: x y z) {
|i|
(set x (va-count))
(set y (* a b))
(set z (+ a b))
(set i 0)
(while (< i (va-count))
set i 0;
while (< i (va-count)) {
(printf "VA[%d]=>[%d]\n" i (va-get i))
(set i (+ i 1))
)
(fn-y "hello" "world" (va-context))
};
fn-y "hello" "world" (va-context);
(return)
)
};
(set t (x 10 20 30))
(if (/= t 1) (printf "ERROR: t is not 1\n")