✓
Passing This code compiles and runs correctly.
Code
// Pins: an `[abstract]` tor that nothing implements must announce itself and
// die when reached, exactly like the plain tor in 395_012 — the annotation buys
// no exemption from the loud hole.
//
// `[abstract]` is a contract that an implementation lives SOMEWHERE. The wall
// that enforces it (KORU047) fires at the invocation, upstream of the passes
// that rewrite implementations, so a pass downstream can take the only
// implementation away and leave the contract unmet with nobody left to notice.
// The emitter's guard reads the program actually being emitted, which is the
// one position no later pass can outrun.
//
// A test block stands KORU047 down wholesale (see 395_012), which is what lets
// an unimplemented event reach emission at all.
~import std/testing
~import std/io
~[abstract] tor fetch { id: u32 }
| found u32
| missing
~tor run-it { id: u32 }
| ok u32
| gone
~run-it = fetch(id)
| found f => ok f
| missing => gone
~test(a test block exists, and mocks nothing) {
~assert.ok()
}
~run-it(id: 1)
| ok v |> std/io:print.ln("value = {{ v:d }}")
| gone |> std/io:print.ln("nothing there")
Flows
subflow ~run-it click a branch to expand · @labels scroll to their anchor
fetch (id)
flow ~test click a branch to expand · @labels scroll to their anchor
test (a test block exists, and mocks nothing, source: ~assert.ok())
flow ~run-it click a branch to expand · @labels scroll to their anchor
run-it (id: 1)
Test Configuration
Post-validation Script:
#!/bin/bash
# The program must DIE at the unimplemented abstract event, naming it. It must
# never print a value it invented. Passing here means `[abstract]` is not a way
# to buy silence.
cd "$(dirname "$0")"
bin=""
for candidate in ./output ./a.out; do
[ -x "$candidate" ] && bin="$candidate" && break
done
if [ -z "$bin" ]; then
echo "FAIL: no executable was produced"
exit 1
fi
out=$("$bin" 2>&1)
rc=$?
if printf '%s' "$out" | grep -q 'value = '; then
echo "FAIL: the unimplemented abstract 'fetch' fabricated an answer instead of dying"
echo " program printed: $out"
exit 1
fi
if [ $rc -eq 0 ]; then
echo "FAIL: reaching an unimplemented abstract exited 0"
echo " program printed: $out"
exit 1
fi
if ! printf '%s' "$out" | grep -q 'fetch'; then
echo "FAIL: the program died but did not name the event it died on"
echo " program printed: $out"
exit 1
fi
echo "PASS: reaching unimplemented abstract 'fetch' died loudly and named itself"
exit 0