nx_number_envelope_gate.nx source
↩ module page · 39 lines · 4204 B
1// nx_number_envelope_gate.nx -- CE6 (codeeffectiveness ce_number_envelope): the envelope primitive in the gate base
2// class publishes a figure ONLY with n, an interval containing it and a null control, and refuses every other shape
3// BY NAME with its own code. In-process: the subject is nx_gate_verdict.nx itself, so this gate is RED the moment the
4// primitive stops discriminating (a primitive that publishes everything passes every well-formed tooth and fails the
5// bite). The fixture figures are the estate's own scorer numbers (419 permil on all 365 judged queries) so the demo
6// lines read like a real emit, and every expected code was decided before the run.
7// exit: 0 GREEN . 1 RED . 3 SKIP license_tier: ORIGINAL No hw writes.
8import "nx_syscalls.nx"
9import "nx_gate_verdict.nx"
10
11const ENV_N: i64 = 365 // observations behind the fixture figure
12const ENV_V: i64 = 419 // the figure, permil
13const ENV_LO: i64 = 388 // interval floor, permil
14const ENV_HI: i64 = 450 // interval ceiling, permil
15const ENV_NULL: i64 = 21 // what the same ruler read on the null subject, permil
16const ENV_NEG_N: i64 = 0 - 3
17
18func main(argc: i64, argv: *i64) -> i64 {
19 let ctr: *i64 = gv_ctr()
20 gv_head("NX-NUMBER-ENVELOPE-GATE: a figure publishes with n, an interval and a null control, or is refused by name" as *u8)
21 gv_check_eq("well-formed-figure-publishes" as *u8, ce_number_envelope("demo_permil" as *u8, ENV_V, ENV_N, ENV_LO, ENV_HI, ENV_NULL), CE_ENV_PUBLISHED, ctr)
22 gv_check_eq("bare-percentage-n-zero-refused-BARE-NUMBER" as *u8, ce_number_envelope("bare_pct" as *u8, ENV_V, 0, ENV_LO, ENV_HI, ENV_NULL), CE_ENV_REFUSED_BARE, ctr)
23 gv_check_eq("negative-n-refused-BARE-NUMBER" as *u8, ce_number_envelope("bare_pct_negn" as *u8, ENV_V, ENV_NEG_N, ENV_LO, ENV_HI, ENV_NULL), CE_ENV_REFUSED_BARE, ctr)
24 gv_check_eq("inverted-interval-refused-NO-INTERVAL" as *u8, ce_number_envelope("no_interval" as *u8, ENV_V, ENV_N, ENV_HI, ENV_LO, ENV_NULL), CE_ENV_REFUSED_NO_INTERVAL, ctr)
25 gv_check_eq("value-below-its-interval-refused-INTERVAL-EXCLUDES-VALUE" as *u8, ce_number_envelope("below" as *u8, ENV_LO - 1, ENV_N, ENV_LO, ENV_HI, ENV_NULL), CE_ENV_REFUSED_EXCLUDES, ctr)
26 gv_check_eq("value-above-its-interval-refused-INTERVAL-EXCLUDES-VALUE" as *u8, ce_number_envelope("above" as *u8, ENV_HI + 1, ENV_N, ENV_LO, ENV_HI, ENV_NULL), CE_ENV_REFUSED_EXCLUDES, ctr)
27 gv_check_eq("value-on-the-interval-floor-publishes" as *u8, ce_number_envelope("on_floor" as *u8, ENV_LO, ENV_N, ENV_LO, ENV_HI, ENV_NULL), CE_ENV_PUBLISHED, ctr)
28 gv_check_eq("value-on-the-interval-ceiling-publishes" as *u8, ce_number_envelope("on_ceiling" as *u8, ENV_HI, ENV_N, ENV_LO, ENV_HI, ENV_NULL), CE_ENV_PUBLISHED, ctr)
29 gv_check_eq("degenerate-interval-lo-equals-hi-equals-value-with-n-1-publishes" as *u8, ce_number_envelope("exact" as *u8, ENV_V, 1, ENV_V, ENV_V, 0), CE_ENV_PUBLISHED, ctr)
30 gv_check_eq("null-control-equal-to-the-value-still-publishes-the-reader-judges-it" as *u8, ce_number_envelope("null_eq" as *u8, ENV_V, ENV_N, ENV_LO, ENV_HI, ENV_V), CE_ENV_PUBLISHED, ctr)
31 gv_check("refusal-codes-are-three-distinct-non-zero-names" as *u8, (((CE_ENV_REFUSED_BARE - CE_ENV_REFUSED_NO_INTERVAL) * (CE_ENV_REFUSED_NO_INTERVAL - CE_ENV_REFUSED_EXCLUDES) * (CE_ENV_REFUSED_BARE - CE_ENV_REFUSED_EXCLUDES) * CE_ENV_REFUSED_BARE * CE_ENV_REFUSED_NO_INTERVAL * CE_ENV_REFUSED_EXCLUDES) != 0) as i64, ctr)
32 gv_bite("bare-percentage-refused-and-the-well-formed-figure-not" as *u8, (ce_number_envelope("bite_bare" as *u8, ENV_V, 0, ENV_LO, ENV_HI, ENV_NULL) != CE_ENV_PUBLISHED) as i64, (ce_number_envelope("bite_ok" as *u8, ENV_V, ENV_N, ENV_LO, ENV_HI, ENV_NULL) != CE_ENV_PUBLISHED) as i64, ctr)
33 gv_values_head()
34 gv_kv("fixture_n" as *u8, ENV_N)
35 gv_kv("fixture_value_permil" as *u8, ENV_V)
36 gv_kv("fixture_interval_width_permil" as *u8, ENV_HI - ENV_LO)
37 gv_kv("fixture_null_permil" as *u8, ENV_NULL)
38 return gv_verdict("nx_number_envelope_gate" as *u8, ctr, "the envelope primitive publishes only a figure carrying n, an interval containing it and a null control; every malformed shape is refused with its own named code" as *u8)
39}