zig/doc/langref/test_coerce_to_error_union.zig

13 lines
271 B
Zig

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