add test case for already fixed bug

closes #3046
This commit is contained in:
Andrew Kelley 2019-09-20 13:19:06 -04:00
parent 3b4a6679a6
commit c9a5a6b83a
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 20 additions and 0 deletions

View File

@ -31,6 +31,7 @@ comptime {
_ = @import("behavior/bugs/2346.zig");
_ = @import("behavior/bugs/2578.zig");
_ = @import("behavior/bugs/2692.zig");
_ = @import("behavior/bugs/3046.zig");
_ = @import("behavior/bugs/3112.zig");
_ = @import("behavior/bugs/394.zig");
_ = @import("behavior/bugs/421.zig");

View File

@ -0,0 +1,19 @@
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 |_| i32(0),
};
expect(some_struct.field == 1);
}