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. ## you can't have another colon before the method..
## so the semicolon after it is a redundant one. `do {};` would work because the semicolon (obj: :method) ##ERROR: syntax error - : disallowed
## terminates the auto-forged list of `do` and `{}`.
{
printf "hello, world\n";
}; ##ERROR: syntax error - unexpected semicolon

View File

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

View File

@ -1,16 +1,17 @@
((lambda ()
((fun() {
## test return variables ## test return variables
| v1 v2 v3 i a b c d | | v1 v2 v3 i a b c d |
(set i 100) set i 100;
(defun ff(a b ::: x y z) defun ff(a b ::: x y z) {
(set x (+ a b i)) set x (+ a b i);
(set y (+ x x)) set y (+ x x);
(set z (+ 999 i)) set z (+ 999 i);
(set i (* i 10)) set i (* i 10);
) };
(set-r v1 v2 v3 (ff 10 20)) (set-r v1 v2 v3 (ff 10 20))
(if (/= v1 130) (printf "ERROR: v1 must be 130\n")) (if (/= v1 130) (printf "ERROR: v1 must be 130\n"))
@ -28,22 +29,21 @@
## test return variables in message sends ## test return variables in message sends
(defclass B defclass B ::: | X1 X2 | {
::: | X1 X2 |
(set X1 999) set X1 999;
(set X2 888) set X2 888;
(defun ::: get ( ::: x y) defun ::: get ( ::: x y) {
(set x X1) (set x X1)
(set y X2) (set y X2)
) };
(defun ::: get2 (inc ::: x y) defun ::: get2 (inc ::: x y) {
(set x (+ X1 inc)) (set x (+ X1 inc))
(set y (+ X2 inc)) (set y (+ X2 inc))
) };
) };
(set-r a b (:B get)) (set-r a b (:B get))
(set-r c d (:B get2 -100)) (set-r c d (:B get2 -100))
@ -53,5 +53,5 @@
(if (/= c 899) (printf "ERROR: c must be 899\n")) (if (/= c 899) (printf "ERROR: c must be 899\n"))
(if (/= d 788) (printf "ERROR: d must be 788\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 | | i |
(set i 0) set i 0;
(while (< i (va-count va-ctx)) while (< i (va-count va-ctx)) {
(printf "fn-y=>Y-VA[%d]=>[%d]\n" i (va-get i va-ctx)) (printf "fn-y=>Y-VA[%d]=>[%d]\n" i (va-get i va-ctx))
(set i (+ i 1)) (set i (+ i 1))
) };
) };
(defun x(a b ... ::: x y z) defun x(a b ... ::: x y z) {
|i| |i|
(set x (va-count)) (set x (va-count))
(set y (* a b)) (set y (* a b))
(set z (+ a b)) (set z (+ a b))
(set i 0) set i 0;
(while (< i (va-count)) while (< i (va-count)) {
(printf "VA[%d]=>[%d]\n" i (va-get i)) (printf "VA[%d]=>[%d]\n" i (va-get i))
(set i (+ i 1)) (set i (+ i 1))
) };
(fn-y "hello" "world" (va-context)) fn-y "hello" "world" (va-context);
(return) (return)
) };
(set t (x 10 20 30)) (set t (x 10 20 30))
(if (/= t 1) (printf "ERROR: t is not 1\n") (if (/= t 1) (printf "ERROR: t is not 1\n")