010 unexpected branch fails

✓ Passing This code compiles and runs correctly.

Code

// Test: Unexpected branch causes test failure
//
// This test verifies that if a mock returns a DIFFERENT branch than
// what the test expects, the test FAILS (not silently passes).
//
// The test expects `ok` but the mock returns `error_result`.
// This should cause a test failure due to union field access mismatch.

~import "$std/testing"

~event get_data {}
| ok { value: u32 }
| error_result { code: u32 }

~test(Unexpected branch should fail) {
    // Mock returns error_result, but test only handles ok branch
    ~get_data = error_result { code: 500 }

    ~get_data()
    | ok result |> assert(result.value == 42)
}
input.kz

Test Configuration

Post-validation Script:

#!/bin/bash
# Run the Zig tests - this test should FAIL because the mock returns
# a different branch than the test expects (union field access mismatch)

cd "$(dirname "$0")"

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 failed on unexpected branch (expected behavior) ==="
    exit 0
else
    echo ""
    echo "=== ERROR: Test should have failed but passed (unexpected branch was silently accepted) ==="
    exit 1
fi