✓
Passing This code compiles and runs correctly.
Code
// Test: Test framework reports passing and failing tests
//
// Two ~test bodies — one asserts true, one asserts false.
// post.sh runs `zig test` on the emitted output and inverts
// the exit code: a non-zero zig-test exit means the deliberately
// failing test was correctly detected.
~import std/testing
~event do-thing {}
| done u32
~test(This test passes) {
~do-thing => done 1
~do-thing()
| done _ |> assert(true)
}
~test(This test should fail) {
~do-thing => done 1
~do-thing()
| done _ |> assert(false)
}
Test Configuration
Post-validation Script:
#!/bin/bash
# Run the actual Zig tests - this test has a deliberately failing assertion
# We expect zig test to FAIL (non-zero exit) because one test fails
cd "$(dirname "$0")"
# Run zig test on the generated output
output=$(zig test output_emitted.zig 2>&1)
exit_code=$?
echo "$output"
# We EXPECT failure here (exit_code != 0)
# If zig test fails as expected, that's a PASS for this regression test
if [ $exit_code -ne 0 ]; then
echo ""
echo "=== Test correctly detected failure (expected behavior) ==="
exit 0
else
echo ""
echo "=== ERROR: Test should have failed but passed ==="
exit 1
fi