updated test cases
All checks were successful
continuous-integration/drone/push Build is passing

implementing method defintion outside the class definition block
This commit is contained in:
2024-03-14 23:26:38 +09:00
parent 37e0efc74a
commit 9ff7c32262
4 changed files with 83 additions and 31 deletions

View File

@ -21,3 +21,19 @@ defclass X :: B | a b | {
}
};
---
defclass X {
defun :* xxx() {
return X;
}
defun :* qqq() {
return "hello"
}
defun String:length() { ##ERROR: syntax error - class name prohibited
return (str.length self)
}
}

View File

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