+struct singlectx {
+ unsigned f;
+#define SF_SHOW 1u
+};
+
+static int single_setup(struct tvec_state *tv, const struct tvec_env *env,
+ void *pctx, void *ctx)
+ { struct singlectx *s = ctx; s->f = 0; return (0); }
+
+static int single_set(struct tvec_state *tv, const char *name,
+ const struct tvec_env *env, void *ctx)
+{
+ struct singlectx *s = ctx;
+ union tvec_regval rv;
+ static const struct tvec_regdef rd =
+ { "@show", -1, &tvty_enum, 0, { &tvenum_bool } };
+
+ if (STRCMP(name, ==, "@show")) {
+ if (tvty_enum.parse(&rv, &rd, tv)) return (-1);
+ if (s) {
+ if (rv.i) s->f |= SF_SHOW;
+ else s->f &= ~SF_SHOW;
+ }
+ return (1);
+ } else
+ return (0);
+}
+
+static void single_run(struct tvec_state *tv, tvec_testfn *fn, void *ctx)
+{
+ struct singlectx *s = ctx;
+ unsigned f = s->f;
+
+ fn(tv->in, tv->out, 0);
+ if (tvec_checkregs(tv)) { tvec_fail(tv, 0); f |= SF_SHOW; }
+ if (f&SF_SHOW) tvec_mismatch(tv, TVMF_IN | TVMF_OUT);
+}
+
+static void single_after(struct tvec_state *tv, void *ctx)
+ { struct singlectx *s = ctx; s->f = 0; }
+
+static const struct tvec_env single_testenv =
+ { sizeof(struct singlectx),
+ single_setup,
+ single_set,
+ 0,
+ single_run,
+ single_after,
+ 0 };
+