zig/test/behavior/bugs/3046.zig
Andrew Kelley 4307436b99 move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for
starting to pass behavior tests with self-hosted.
2021-04-29 15:54:04 -07: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),
};
expect(some_struct.field == 1);
}