fold-2 chunk C4 (drew's Fam8-13 plan): 13 float value-row C drivers re-homed. 11 migrate to test/lang/*_test.ww @test row-tables (exact IEEE-bit asserts); 1 float-overflow reject row -> a runww //ww:error carrier. 956_tuprecv_f64 slims to a w6c_ww asserttyped pin (20 value rows -> @test; the stamp dimension can't be a value/byte-id @test) -- mutation-proven non-vacuous (break #121 stamp -> RED 6/6 -> restore -> GREEN) + an in-test vacuity self-check. 946_structparam/structret stay whole: their SSE register-class .s-grep (SysV ABI conformance, #165/#171a) is the genuine defect-guard, not @test-expressible. Float was the predicted SSE-cursor byte-id hotspot -- zero fresh cs!=ww surfaced; 951_f64cgen (cstage-only before) byte-ids clean. LANGBYTEID floor 82->93; test count 384->374 (10 deleted drivers; 956 + the 2 946 kept).
201 lines
6.3 KiB
C
201 lines
6.3 KiB
C
/*
|
|
* 956_tuprecv_f64_run (SLIM PIN, #5-C4) — the #121 A-narrow asserttyped stamp
|
|
* dimension for the f64 tuple-receive DESTRUCTURE bindings. The runtime VALUE
|
|
* rows + cs==ww byte-id migrated to test/lang/tuprecv_f64_test.ww; what stays
|
|
* here is the one dimension test-lang has no channel for: a wwstage-STDERR grep
|
|
* that w6c_ww emits NO `asserttyped:` diagnostic on the un-annotated float
|
|
* destructure binding (the binding must carry a checker type stamp so cgen's
|
|
* class-aware spill fires). cstage has no ww asserttyped pass, so this is
|
|
* w6c_ww-only by construction (project memory: audit the *_ww binary).
|
|
*
|
|
* NON-VACUITY (drew C4 mutation gate): the grep is LIVE — pre-stamp HEAD w6c_ww
|
|
* fires `asserttyped` on the f64 binding ident (nil n.type_), and the grep
|
|
* mechanically fires on a synthetic `asserttyped:` line (self-checked below at
|
|
* startup; a broken grep FAILS the test before any row runs).
|
|
*
|
|
* Slim sibling of the C2 precedent (954 ctl_destr's asserttyped sub-dimension,
|
|
* test/lang/tuprecv_test.ww). The 6 rows are the chk_stamped subset of the
|
|
* original 956 driver; non-float / control rows carry no stamp dimension and
|
|
* live only in the @test file.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/wait.h>
|
|
|
|
static int
|
|
runwait(const char *cmd)
|
|
{
|
|
int rc = system(cmd);
|
|
if (rc == -1) return -1;
|
|
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
|
return -1;
|
|
}
|
|
|
|
struct row { const char *label; const char *src; };
|
|
|
|
static const struct row rows[] = {
|
|
{ "destr_f64_i64_br",
|
|
"package main;\n"
|
|
"fn issub(n: f64) bool = { return false; };\n"
|
|
"fn norm(n: f64) (f64, i64) = {\n"
|
|
"\tif (issub(n)) { return (n*2.0, -52); };\n"
|
|
"\treturn (n, 0);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
"\tlet (m, i) = norm(16.0);\n"
|
|
"\tif (m != 16.0) { return 1; };\n"
|
|
"\tif (i != 0) { return 2; };\n"
|
|
"\treturn 0;\n"
|
|
"};\n" },
|
|
{ "destr_i64_f64_br",
|
|
"package main;\n"
|
|
"fn issub(n: f64) bool = { return false; };\n"
|
|
"fn norm(n: f64) (i64, f64) = {\n"
|
|
"\tif (issub(n)) { return (-52, n*2.0); };\n"
|
|
"\treturn (0, n);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
"\tlet (i, m) = norm(16.0);\n"
|
|
"\tif (m != 16.0) { return 1; };\n"
|
|
"\tif (i != 0) { return 2; };\n"
|
|
"\treturn 0;\n"
|
|
"};\n" },
|
|
{ "f64f64_destr_br",
|
|
"package main;\n"
|
|
"fn issub(n: f64) bool = { return false; };\n"
|
|
"fn pair(a: f64, b: f64) (f64, f64) = {\n"
|
|
"\tif (issub(a)) { return (a*2.0, b*2.0); };\n"
|
|
"\treturn (a, b);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
"\tlet (x, y) = pair(3.0, 5.0);\n"
|
|
"\tif (x != 3.0) { return 1; };\n"
|
|
"\tif (y != 5.0) { return 2; };\n"
|
|
"\treturn 0;\n"
|
|
"};\n" },
|
|
{ "i64_f64_i64_destr",
|
|
"package main;\n"
|
|
"fn issub(n: i64) bool = { return false; };\n"
|
|
"fn tri(a: i64, b: f64, c: i64) (i64, f64, i64) = {\n"
|
|
"\tif (issub(a)) { return (a*2, b*2.0, c*2); };\n"
|
|
"\treturn (a, b, c);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
"\tlet (x, y, z) = tri(3, 2.0, 7);\n"
|
|
"\tif (x != 3) { return 1; };\n"
|
|
"\tif (y != 2.0) { return 2; };\n"
|
|
"\tif (z != 7) { return 3; };\n"
|
|
"\treturn 0;\n"
|
|
"};\n" },
|
|
{ "f64_str_destr",
|
|
"package main;\n"
|
|
"fn issub(n: f64) bool = { return false; };\n"
|
|
"fn fs(n: f64) (f64, str) = {\n"
|
|
"\tif (issub(n)) { return (n*2.0, \"x\"); };\n"
|
|
"\treturn (n, \"hello\");\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
"\tlet (f, s) = fs(4.0);\n"
|
|
"\tif (f != 4.0) { return 1; };\n"
|
|
"\tif (s.len != 5) { return 2; };\n"
|
|
"\treturn 0;\n"
|
|
"};\n" },
|
|
{ "str_f64_destr",
|
|
"package main;\n"
|
|
"fn issub(n: f64) bool = { return false; };\n"
|
|
"fn sf(n: f64) (str, f64) = {\n"
|
|
"\tif (issub(n)) { return (\"x\", n*2.0); };\n"
|
|
"\treturn (\"hello\", n);\n"
|
|
"};\n"
|
|
"export fn main() i32 = {\n"
|
|
"\tlet (s, f) = sf(4.0);\n"
|
|
"\tif (s.len != 5) { return 1; };\n"
|
|
"\tif (f != 4.0) { return 2; };\n"
|
|
"\treturn 0;\n"
|
|
"};\n" },
|
|
{ NULL, NULL }
|
|
};
|
|
|
|
/* The asserttyped diagnostic only appears in w6c_ww (the wwstage checker audit);
|
|
* an absent w6c_ww means the gate cannot run — fail loud. */
|
|
int
|
|
main(void)
|
|
{
|
|
const char *bin = getenv("BIN");
|
|
if (!bin) bin = "out/bin";
|
|
char absbin[1024];
|
|
if (bin[0] != '/') {
|
|
char cwd[1024];
|
|
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
|
snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin);
|
|
bin = absbin;
|
|
}
|
|
|
|
char w6c_ww[1100];
|
|
snprintf(w6c_ww, sizeof w6c_ww, "%s/w6c_ww", bin);
|
|
if (access(w6c_ww, X_OK) != 0) {
|
|
fprintf(stderr, "tuprecv_f64: w6c_ww missing — cannot run the "
|
|
"asserttyped stamp gate (the whole point of this pin)\n");
|
|
return 1;
|
|
}
|
|
|
|
int n = 0, fail = 0;
|
|
|
|
/* NON-VACUITY self-check: the grep must FIRE on a literal asserttyped
|
|
* line. A grep that never matches would pass every row vacuously. */
|
|
{
|
|
char probe[80], cmd[160];
|
|
snprintf(probe, sizeof probe, "/tmp/wwtupf_probe_%d.txt", getpid());
|
|
FILE *p = fopen(probe, "wb");
|
|
if (!p) { fprintf(stderr, "tuprecv_f64: probe open failed\n"); return 1; }
|
|
fputs("error: asserttyped: e.type_ nil\n", p);
|
|
fclose(p);
|
|
snprintf(cmd, sizeof cmd, "grep -q asserttyped %s", probe);
|
|
if (runwait(cmd) != 0) {
|
|
fprintf(stderr, "tuprecv_f64: grep self-check FAILED — the "
|
|
"asserttyped gate is vacuous\n");
|
|
unlink(probe);
|
|
return 1;
|
|
}
|
|
unlink(probe);
|
|
}
|
|
|
|
for (int i = 0; rows[i].src; i++, n++) {
|
|
char tmpdir[64], src[128], errf[128], rmcmd[160], cmd[2048];
|
|
snprintf(tmpdir, sizeof tmpdir, "/tmp/wwtupf_%d_d_%d",
|
|
getpid(), i);
|
|
mkdir(tmpdir, 0755);
|
|
snprintf(src, sizeof src, "%s/wwtupf_%d_%d.ww",
|
|
tmpdir, getpid(), i);
|
|
snprintf(errf, sizeof errf, "%s/err", tmpdir);
|
|
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
|
|
|
FILE *f = fopen(src, "wb");
|
|
if (f == NULL) { runwait(rmcmd); fail++; continue; }
|
|
fputs(rows[i].src, f);
|
|
fclose(f);
|
|
|
|
snprintf(cmd, sizeof cmd, "%s -o /dev/null %s 2>%s",
|
|
w6c_ww, src, errf);
|
|
runwait(cmd);
|
|
snprintf(cmd, sizeof cmd, "grep -q asserttyped %s", errf);
|
|
if (runwait(cmd) == 0) {
|
|
fprintf(stderr, "row[%s]: w6c_ww emitted asserttyped "
|
|
"(destructure float binding unstamped)\n",
|
|
rows[i].label);
|
|
fail++;
|
|
}
|
|
runwait(rmcmd);
|
|
}
|
|
|
|
if (fail) {
|
|
fprintf(stderr, "%d/%d tuprecv_f64 asserttyped-stamp rows failed\n",
|
|
fail, n);
|
|
return 1;
|
|
}
|
|
printf("tuprecv_f64: %d/%d ok (asserttyped stamp pin, w6c_ww)\n", n, n);
|
|
return 0;
|
|
}
|