summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-12-12 18:10:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-12-13 08:19:53 -0800
commitb1fe95fef05b7e8d26ff82645d373c2ef0b5c449 (patch)
tree7220391285ce26f06a969d7087396275e50d2e46 /tests
parent2eaa8bdbb3a6d426a9de4d916dad63f77fd54092 (diff)
downloadtxr-b1fe95fef05b7e8d26ff82645d373c2ef0b5c449.tar.gz
txr-b1fe95fef05b7e8d26ff82645d373c2ef0b5c449.tar.bz2
txr-b1fe95fef05b7e8d26ff82645d373c2ef0b5c449.zip
multiple-inheritance: super-method loose ends.
* struct.c (do_super): New function. Now the common implementation for call_super_method, call_super_fun and super_method. (call_super_method, call_super_fun): Reduced to small wrappers around do_super. (super_method): Drill into the object to geet the struct_type handle, and then use do_super to get the method. * tests/012/oop-mi.tl: New tests for call-super-fun and call-super-method. * tests/012/oop-mi.expected: Updated. * txr.1: Updated.
Diffstat (limited to 'tests')
-rw-r--r--tests/012/oop-mi.expected6
-rw-r--r--tests/012/oop-mi.tl24
2 files changed, 26 insertions, 4 deletions
diff --git a/tests/012/oop-mi.expected b/tests/012/oop-mi.expected
index 91bc05df..301c7460 100644
--- a/tests/012/oop-mi.expected
+++ b/tests/012/oop-mi.expected
@@ -6,3 +6,9 @@ gs0
gs1-b1
(meth base3 b3m0)
(meth der1 b3m1)
+m1
+m2
+gm
+m1
+m2
+gm
diff --git a/tests/012/oop-mi.tl b/tests/012/oop-mi.tl
index 162c0243..7561d096 100644
--- a/tests/012/oop-mi.tl
+++ b/tests/012/oop-mi.tl
@@ -4,17 +4,21 @@
(gx 'gx)
(gy 'gy)
(:static gs0 'gs0)
- (:static gs1 'gs1))
+ (:static gs1 'gs1)
+ (:method gm (me) 'gm))
-(defstruct base0 nil)
+(defstruct base0 nil
+ (:method m (me) 'm0))
(defstruct base1 grand
(x 'b1x)
- (:static gs1 'gs1-b1))
+ (:static gs1 'gs1-b1)
+ (:method m (me) 'm1))
(defstruct base2 grand
(y 'b2y)
- (:static gs1 'gs1-b2))
+ (:static gs1 'gs1-b2)
+ (:method m (me) 'm2))
(defstruct base3 nil
(x 'b3x)
@@ -45,3 +49,15 @@
(prinl (func-get-name d0.b3m0))
(prinl (func-get-name d1.b3m1))
+
+(defstruct der2 (base3 base1 base2))
+(defstruct der3 (base3 base2 base1))
+
+(prinl (call-super-method (new der2) 'm))
+(prinl (call-super-method (new der3) 'm))
+(prinl (call-super-method (new der3) 'gm))
+(prinl (call-super-fun 'der2 'm nil))
+(prinl (call-super-fun 'der3 'm nil))
+(prinl (call-super-fun 'der3 'gm nil))
+
+