hcl/t/va-01.hcl

55 lines
967 B
HCL
Raw Normal View History

2024-01-02 15:45:34 +00:00
defun fn-y (t1 t2 va-ctx) {
2022-05-05 14:38:43 +00:00
| i |
2024-01-14 15:47:01 +00:00
i := 0;
2024-01-02 15:45:34 +00:00
while (< i (va-count va-ctx)) {
2024-01-14 15:47:01 +00:00
printf "fn-y=>Y-VA[%d]=>[%d]\n" i (va-get i va-ctx);
i := (+ i 1);
2024-01-02 15:45:34 +00:00
};
};
2022-05-05 14:38:43 +00:00
defun x(a b ... :: x y z) {
2022-05-05 14:38:43 +00:00
|i|
2024-01-14 15:47:01 +00:00
set x (va-count);
set y (* a b);
set z (+ a b);
2022-05-05 14:38:43 +00:00
2024-01-02 15:45:34 +00:00
set i 0;
while (< i (va-count)) {
2024-01-14 15:47:01 +00:00
printf "VA[%d]=>[%d]\n" i (va-get i);
set i (+ i 1);
2024-01-02 15:45:34 +00:00
};
fn-y "hello" "world" (va-context);
2022-05-05 14:38:43 +00:00
2024-01-14 15:47:01 +00:00
return;
2024-01-02 15:45:34 +00:00
};
2022-05-05 14:38:43 +00:00
2024-01-14 15:47:01 +00:00
set t (x 10 20 30);
if (/= t 1) {
printf "ERROR: t is not 1\n"
} else {
printf "OK: %d\n" t
};
2024-01-14 15:47:01 +00:00
set t (set-r a b c (x 10 20 30 40 50));
if (/= t 3) {
printf "ERROR: t is not 3\n"
} else {
printf "OK: %d\n" t
};
if (/= a 3) {
printf "ERROR: a is not 3\n"
} else {
printf "OK: %d\n" a
};
if (/= b 200) {
printf "ERROR: b is not 200\n"
} else {
printf "OK: %d\n" b
};
if (/= c 30) {
printf "ERROR: c is not 30\n"
} else {
printf "OK: %d\n" c
};