003 pure event no mock

✓ Passing This code compiles and runs correctly.

Code

// Test: Pure events don't require mocks
//
// Events with ~[pure] procs can be called in tests without mocking.
// Only impure events (side effects) need mocks.

~import "$std/testing"

// Pure computation - no side effects
~event add_numbers { a: u32, b: u32 }
| result { sum: u32 }

~[pure] proc add_numbers {
    return .{ .result = .{ .sum = a + b } };
}

// Test: Pure event called directly, no mock needed
// Actually verify the computation result!
~test(Pure event works without mock) {
    ~add_numbers(a: 5, b: 3)
    | result r |> assert(r.sum == 8)
}

pub fn main() void {}
input.kz

Test Configuration

Post-validation Script:

#!/bin/bash
# Run the actual Zig tests to verify pure events work without mocks

cd "$(dirname "$0")"

# Run zig test on the generated output
zig test output_emitted.zig 2>&1
exit $?