enhanced the MLIST syntax - '(obj:message arg1 arg2)'
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2024-01-02 01:41:41 +09:00
parent caebe2c5a9
commit c82b56fdf6
7 changed files with 133 additions and 128 deletions

View File

@ -40,7 +40,7 @@ defclass A
##defun get-c() c;
};
set k (:A newInstance 11 22 33);
set v (:k get-a);
set k (A:newInstance 11 22 33);
set v (k:get-a);
if (= v 11) { printf "OK - %d\n" v; }
else { printf "ERROR - %d\n" v; };

View File

@ -1,53 +1,53 @@
## test class instantiation methods
(defclass A
| a b c |
defclass A | a b c | {
(defun ::* newInstance(x y z)
(set a x)
(set b y)
(set c z)
(return self)
)
defun ::* newInstance(x y z) {
set a x;
set b y;
set c z;
return self;
};
(defun get-a() a)
(defun get-b() b)
(defun get-c() c)
)
defun get-a() { return self.a; };
defun get-b() { return self.b; };
defun get-c() { return self.c; };
};
(defclass B ::: A
| d e f |
defclass B ::: A | d e f | {
(defun ::* newInstance(x y z)
(:super newInstance (* x 2) (* y 2) (* z 2))
(set d x)
(set e y)
(set f z)
(return self)
)
defun ::* newInstance(x y z) {
super:newInstance (* x 2) (* y 2) (* z 2);
set d x;
set e y;
set f z;
return self;
};
(defun sum()
(+ (:super get-a) (:super get-b) (:super get-c) d e f)
)
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);
if (/= a 18) { printf "ERROR: a must be 18\n"; }
else { printf "OK %d\n" a; };
(set a (:(:B newInstance 1 2 3) sum))
(if (/= a 18) (printf "ERROR: a must be 18\n"))
(printf "OK %d\n" a)
set b (B:newInstance 2 3 4);
set a (b:get-a);
(if (/= a 4) (printf "ERROR: a must be 4\n")
else (printf "OK %d\n" a))
(set b (:B newInstance 2 3 4))
(set a (:b get-a))
(if (/= a 4) (printf "ERROR: a must be 4\n"))
(printf "OK %d\n" a)
(set a (:b get-b))
(if (/= a 6) (printf "ERROR: a must be 6\n"))
(printf "OK %d\n" a)
(set a (:b get-c))
(if (/= a 8) (printf "ERROR: a must be 8\n"))
(printf "OK %d\n" a)
(set a (:b sum))
(if (/= a 27) (printf "ERROR: a must be 27\n"))
(printf "OK %d\n" a)
set a (b:get-b);
(if (/= a 6) (printf "ERROR: a must be 6\n")
else (printf "OK %d\n" a))
set a (b:get-c);
(if (/= a 8) (printf "ERROR: a must be 8\n")
else (printf "OK %d\n" a))
set a (b:sum);
(if (/= a 27) (printf "ERROR: a must be 27\n")
else (printf "OK %d\n" a))