/* -*-sod-*- */
-code h : includes {
+code h: includes {
#include "sod.h"
}
-code c : includes {
+code c: includes {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "test.h"
}
-code c : early_user {
+code c: early_user {
/*----- Preliminary definitions -------------------------------------------*/
/* Confuse the fragment scanner... */
}
-code c : (tests head)
+code c: (tests head)
[user (tests head) tests (tests tail) main (user end)]
{
/*----- Test machinery ----------------------------------------------------*/
static void tests(void)
LBRACE
}
-code c : (tests tail) {
+code c: (tests tail) {
RBRACE
}
-code c : main {
+code c: main {
/*----- Main program ------------------------------------------------------*/
int main(void)
/*----- Various kinds of method combinations ------------------------------*/
-code h : early_user {
+code h: early_user {
struct item {
struct item *next;
const char *p;
}
-code c : early_user {
+code c: early_user {
static void *xmalloc(size_t n)
{
void *p = malloc(n);
}
[link = SodObject, nick = t1base]
-class T1Base : SodObject {
+class T1Base: SodObject {
[combination = progn] void aprogn() { STEP(1); }
[combination = sum] int asum() { return 1; }
[combination = and] int aand() { return 8; }
}
[link = T1Base, nick = t1sub]
-class T1Sub : T1Base {
+class T1Sub: T1Base {
void t1base.aprogn() { STEP(0); }
int t1base.asum() { return 2; }
int t1base.aand() { return 6; }
int t1base.avec() { return 4; }
}
-code c : tests {
+code c: tests {
prepare("aggregate, base");
{ SOD_DECL(T1Base, t1, NO_KWARGS);
struct item *l;
/*----- Slot and user initargs --------------------------------------------*/
[link = SodObject, nick = t2]
-class T2 : SodObject {
+class T2: SodObject {
[initarg = x] int x = 0;
initarg int y = 1;
init { if (!y) STEP(0); }
}
-code c : tests {
+code c: tests {
prepare("initargs, defaults");
{ SOD_DECL(T2, t, NO_KWARGS);
if (t->t2.x == 0) STEP(0);
}
}
+/*----- 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 -------------------------------------------------*/