zig/test/behavior/bugs/3046.zig
2021-06-14 00:16:40 +03:00

20 lines
343 B
Zig

const std = @import("std");
const expect = std.testing.expect;
const SomeStruct = struct {
field: i32,
};
fn couldFail() anyerror!i32 {
return 1;
}
var some_struct: SomeStruct = undefined;
test "fixed" {
some_struct = SomeStruct{
.field = couldFail() catch @as(i32, 0),
};
try expect(some_struct.field == 1);
}