New feature: initialization keyword arguments.
[sod] / test / test.sod
index 71fdd68..f7f3537 100644 (file)
@@ -202,4 +202,27 @@ code c : tests {
   }
 }
 
+/*----- 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);
+  }
+}
+
 /*----- That's all, folks -------------------------------------------------*/