2023-11-09 17:59:41 +00:00
|
|
|
## test class instantiation methods
|
2022-03-17 13:22:17 +00:00
|
|
|
|
2024-01-01 16:41:41 +00:00
|
|
|
defclass A | a b c | {
|
|
|
|
|
2024-02-03 16:57:53 +00:00
|
|
|
defun :*newInstance(x y z) {
|
2024-01-01 16:41:41 +00:00
|
|
|
set a x;
|
|
|
|
set b y;
|
|
|
|
set c z;
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
defun get-a() { return self.a; };
|
|
|
|
defun get-b() { return self.b; };
|
|
|
|
defun get-c() { return self.c; };
|
|
|
|
};
|
|
|
|
|
2024-02-03 16:57:53 +00:00
|
|
|
defclass B :: A | d e f | {
|
2024-01-01 16:41:41 +00:00
|
|
|
|
2024-02-03 16:57:53 +00:00
|
|
|
defun :*newInstance(x y z) {
|
2024-01-01 16:41:41 +00:00
|
|
|
super:newInstance (* x 2) (* y 2) (* z 2);
|
|
|
|
set d x;
|
|
|
|
set e y;
|
|
|
|
set f z;
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
defun sum() {
|
|
|
|
return (+ (super:get-a) (super:get-b) (super:get-c) self.d self.e self.f);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
set a ((B:newInstance 1 2 3):sum);
|
2024-01-18 14:55:50 +00:00
|
|
|
if (/= a 18) { printf "ERROR: a must be 18\n"; } \
|
2024-01-01 16:41:41 +00:00
|
|
|
else { printf "OK %d\n" a; };
|
|
|
|
|
|
|
|
set b (B:newInstance 2 3 4);
|
|
|
|
set a (b:get-a);
|
2024-01-18 14:55:50 +00:00
|
|
|
if (/= a 4) {printf "ERROR: a must be 4\n" } \
|
2024-01-14 15:47:01 +00:00
|
|
|
else { printf "OK %d\n" a };
|
2024-01-01 16:41:41 +00:00
|
|
|
|
|
|
|
set a (b:get-b);
|
2024-01-18 14:55:50 +00:00
|
|
|
if (/= a 6) { printf "ERROR: a must be 6\n" } \
|
2024-01-14 15:47:01 +00:00
|
|
|
else { printf "OK %d\n" a };
|
2024-01-01 16:41:41 +00:00
|
|
|
|
|
|
|
set a (b:get-c);
|
2024-01-18 14:55:50 +00:00
|
|
|
if (/= a 8) { printf "ERROR: a must be 8\n" } \
|
2024-01-14 15:47:01 +00:00
|
|
|
else {printf "OK %d\n" a };
|
2024-01-01 16:41:41 +00:00
|
|
|
|
|
|
|
set a (b:sum);
|
2024-01-18 14:55:50 +00:00
|
|
|
if (/= a 27) { printf "ERROR: a must be 27\n" } \
|
2024-01-14 15:47:01 +00:00
|
|
|
else { printf "OK %d\n" a };
|