aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_coerce_to_error_union.zig
blob: 2789a921981ab8d86e4972b79fe32553efa7f358 (plain)
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