summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-10-11 23:05:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-10-11 23:05:16 -0700
commit2cda9b946d701faa308b0915c83ea48fb94d94af (patch)
treea546879daba90dfd65fc370ab1e03475f7778d77 /tests
parentaa02bc7f31edabb9e09f9756d7ae8fbc41995017 (diff)
downloadtxr-2cda9b946d701faa308b0915c83ea48fb94d94af.tar.gz
txr-2cda9b946d701faa308b0915c83ea48fb94d94af.tar.bz2
txr-2cda9b946d701faa308b0915c83ea48fb94d94af.zip
structs: optional init-exprs now useful in :delegate
* stdlib/struct.tl (:delegate): Handle the two-element form of the optional parameter, which specifies the usual initializing expression for the default value. This is just passed through as-is to the generated method. Diagnose if the three-element form occurs. * tests/012/oop.tl: Some new tests. * txr.1: Documented.
Diffstat (limited to 'tests')
-rw-r--r--tests/012/oop.tl12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/012/oop.tl b/tests/012/oop.tl
index b786e0b7..5cdd3ec3 100644
--- a/tests/012/oop.tl
+++ b/tests/012/oop.tl
@@ -102,12 +102,20 @@
(defstruct contractor ()
sub
(:delegate work (me) me.sub.sub)
- (:delegate break (me : min) me.sub.sub relax))
+ (:delegate break (me : min) me.sub.sub relax)
+ (:delegate break20 (me : (min 20)) me.sub.sub relax))
(let ((co (new contractor sub (new contractor sub (new worker name "foo")))))
(mtest co.(work) "worker foo works"
co.(break) "worker foo relaxes for 15 min"
- co.(break 5) "worker foo relaxes for 5 min"))
+ co.(break 5) "worker foo relaxes for 5 min"
+ co.(break20 5) "worker foo relaxes for 5 min"
+ co.(break20) "worker foo relaxes for 20 min"))
+
+(test
+ (defstruct bad-delegate ()
+ (:delegate del (x : (y z w))))
+ :error)
(defstruct api-x ()
(:method get (x a b : c . d) ^(api-x get ,x ,a ,b ,c ,d))