From 758d5e953b3030631691bab81eade05f0406101b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 3 Jan 2024 00:45:34 +0900 Subject: [PATCH] updated multiple test files --- t/feed-01.err | 8 ++------ t/ret-01.hcl | 50 ++++++++++++++++++++++++------------------------- t/retvar-01.hcl | 38 ++++++++++++++++++------------------- t/va-01.hcl | 22 +++++++++++----------- 4 files changed, 57 insertions(+), 61 deletions(-) diff --git a/t/feed-01.err b/t/feed-01.err index f5d6623..b8c4a56 100644 --- a/t/feed-01.err +++ b/t/feed-01.err @@ -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 diff --git a/t/ret-01.hcl b/t/ret-01.hcl index 82ed230..b526470 100644 --- a/t/ret-01.hcl +++ b/t/ret-01.hcl @@ -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"; diff --git a/t/retvar-01.hcl b/t/retvar-01.hcl index 2ba8c54..e60ef78 100644 --- a/t/retvar-01.hcl +++ b/t/retvar-01.hcl @@ -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; +})); diff --git a/t/va-01.hcl b/t/va-01.hcl index c3fbbc9..298f20f 100644 --- a/t/va-01.hcl +++ b/t/va-01.hcl @@ -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")