chiark / gitweb /
@@@ BROKEN wip
[mLib] / test / tvec-core.c
index 6aa49fa06ca618ad136d167d3b71cf0e17d14ab9..03873dc61e167505a8fbd3446e9e1ee61f01dcbd 100644 (file)
@@ -392,7 +392,7 @@ static void begin_test_group(struct tvec_state *tv, struct groupstate *g)
   }
 }
 
-void tvec_reportgroup(struct tvec_state *tv)
+static void report_group(struct tvec_state *tv)
 {
   unsigned i, out, nrun;
 
@@ -404,7 +404,7 @@ void tvec_reportgroup(struct tvec_state *tv)
   else {
     if (tv->curr[TVOUT_LOSE]) out = TVOUT_LOSE;
     else out = TVOUT_WIN;
-    tv->grps[out]++; tv->output->ops->egroup(tv->output, out);
+    tv->grps[out]++; tv->output->ops->egroup(tv->output);
   }
 }
 
@@ -415,7 +415,7 @@ static void end_test_group(struct tvec_state *tv, struct groupstate *g)
 
   if (!t) return;
   if (tv->f&TVSF_OPEN) check(tv, g);
-  if (!(tv->f&TVSF_SKIP)) tvec_reportgroup(tv);
+  if (!(tv->f&TVSF_SKIP)) report_group(tv);
   env = t->env; if (env && env->teardown) env->teardown(tv, g->ctx);
   release_registers(tv); tv->test = 0; xfree(g->ctx); g->ctx = 0;
 }
@@ -548,9 +548,7 @@ void tvec_begin(struct tvec_state *tv_out,
 
   tv_out->tests = config->tests; tv_out->test = 0;
   tv_out->infile = 0; tv_out->lno = 0; tv_out->fp = 0;
-  o->tv = tv_out; tv_out->output = o;
-
-  tv_out->output->ops->bsession(tv_out->output);
+  tv_out->output = o; tv_out->output->ops->bsession(tv_out->output, tv_out);
 }
 
 int tvec_end(struct tvec_state *tv)
@@ -636,7 +634,7 @@ void tvec_begingroup(struct tvec_state *tv, const char *name,
 
 void tvec_endgroup(struct tvec_state *tv)
 {
-  if (!(tv->f&TVSF_SKIP)) tvec_reportgroup(tv);
+  if (!(tv->f&TVSF_SKIP)) report_group(tv);
   tv->test = 0;
 }
 
@@ -680,19 +678,27 @@ static void adhoc_claim_teardown(struct tvec_state *tv,
   if (ck->f&ACF_FRESH) tvec_endtest(tv);
 }
 
-int tvec_claim(struct tvec_state *tv, int ok,
-              const char *file, unsigned lno, const char *expr, ...)
+int tvec_claim_v(struct tvec_state *tv, int ok,
+                const char *file, unsigned lno,
+                const char *msg, va_list *ap)
 {
   struct adhoc_claim ck;
-  va_list ap;
 
   adhoc_claim_setup(tv, &ck, 0, file, lno);
-  if (!ok)
-    { va_start(ap, expr); tvec_fail_v(tv, expr, &ap); va_end(ap); }
+  if (!ok) tvec_fail_v(tv, msg, ap);
   adhoc_claim_teardown(tv, &ck);
   return (ok);
 }
 
+int tvec_claim(struct tvec_state *tv, int ok,
+              const char *file, unsigned lno, const char *msg, ...)
+{
+  va_list ap;
+
+  va_start(ap, msg); tvec_claim_v(tv, ok, file, lno, msg, &ap); va_end(ap);
+  return (ok);
+}
+
 int tvec_claimeq(struct tvec_state *tv,
                 const struct tvec_regty *ty, const union tvec_misc *arg,
                 const char *file, unsigned lno, const char *expr)