1 2 3 4 5 6 7 8 9 10 11 12
const std = @import("std"); const expect = std.testing.expect; test "coercion to error unions" { const x: anyerror!i32 = 1234; const y: anyerror!i32 = error.Failure; try expect((try x) == 1234); try std.testing.expectError(error.Failure, y); } // test