code c : tests {
prepare("aggregate, base");
- { SOD_DECL(T1Base, t1);
+ { SOD_DECL(T1Base, t1, NO_KWARGS);
struct item *l;
struct vec v;
STEP(0); T1Base_aprogn(t1); /* 1 */
DONE(7);
}
prepare("aggregate, sub");
- { SOD_DECL(T1Sub, t1);
+ { SOD_DECL(T1Sub, t1, NO_KWARGS);
struct item *l;
struct vec v;
T1Base_aprogn(t1); /* 0, 1 */
}
}
+/*----- Slot and user initargs --------------------------------------------*/
+
+[link = SodObject, nick = t2]
+class T2 : SodObject {
+ [initarg = x] int x = 0;
+
+ initarg int y = 1;
+ init { if (!y) STEP(0); }
+}
+
+code c : tests {
+ prepare("initargs, defaults");
+ { SOD_DECL(T2, t, NO_KWARGS);
+ if (t->t2.x == 0) STEP(0);
+ DONE(1);
+ }
+ prepare("initargs, explicit");
+ { SOD_DECL(T2, t, KWARGS(K(x, 42) K(y, 0)));
+ if (t->t2.x == 42) STEP(1);
+ DONE(2);
+ }
+}
+
+/*----- Keyword argument propagation --------------------------------------*/
+
+[link = SodObject, nick = base]
+class T3Base : SodObject {
+ void m0(?int x) { STEP(x); }
+ void m1(?) { }
+}
+
+[link = T3Base, nick = mid]
+class T3Mid : T3Base {
+ void base.m0(?int y) { STEP(y); CALL_NEXT_METHOD; }
+ void base.m1(?) { STEP(4); CALL_NEXT_METHOD; }
+}
+
+[link = T3Mid, nick = sub]
+class T3Sub : T3Mid {
+ void base.m0(?int z) { STEP(z); CALL_NEXT_METHOD; }
+ void base.m1(?int z) { STEP(z); CALL_NEXT_METHOD; }
+}
+
+code c : tests {
+ prepare("kwargs");
+ { SOD_DECL(T3Sub, t, NO_KWARGS);
+ T3Base_m0(t, KWARGS(K(z, 0) K(y, 1) K(x, 2)));
+ T3Base_m1(t, KWARGS(K(z, 3)));
+ DONE(5);
+ }
+}
+
/*----- That's all, folks -------------------------------------------------*/