Skip to content

Commit 6cc848e

Browse files
committed
incremental: add new test cases
These cover the fixes from the last few commits.
1 parent f01029c commit 6cc848e

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#target=x86_64-linux-selfhosted
2+
#target=x86_64-linux-cbe
3+
#target=x86_64-windows-cbe
4+
#update=initial version
5+
#file=main.zig
6+
pub fn main() !u8 {
7+
var a: u8 = undefined;
8+
a = 255;
9+
_ = a + 1;
10+
return 1;
11+
}
12+
pub const Panic = struct {
13+
pub const call = myPanic;
14+
pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch;
15+
pub const unwrapError = std.debug.FormattedPanic.unwrapError;
16+
pub const outOfBounds = std.debug.FormattedPanic.outOfBounds;
17+
pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd;
18+
pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField;
19+
pub const messages = std.debug.FormattedPanic.messages;
20+
};
21+
fn myPanic(msg: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
22+
std.io.getStdOut().writer().print("panic message: {s}\n", .{msg}) catch {};
23+
std.process.exit(0);
24+
}
25+
const std = @import("std");
26+
#expect_stdout="panic message: integer overflow\n"
27+
28+
#update=change the panic handler body
29+
#file=main.zig
30+
pub fn main() !u8 {
31+
var a: u8 = undefined;
32+
a = 255;
33+
_ = a + 1;
34+
return 1;
35+
}
36+
pub const Panic = struct {
37+
pub const call = myPanic;
38+
pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch;
39+
pub const unwrapError = std.debug.FormattedPanic.unwrapError;
40+
pub const outOfBounds = std.debug.FormattedPanic.outOfBounds;
41+
pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd;
42+
pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField;
43+
pub const messages = std.debug.FormattedPanic.messages;
44+
};
45+
fn myPanic(msg: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
46+
std.io.getStdOut().writer().print("new panic message: {s}\n", .{msg}) catch {};
47+
std.process.exit(0);
48+
}
49+
const std = @import("std");
50+
#expect_stdout="new panic message: integer overflow\n"
51+
52+
#update=change the panic handler function value
53+
#file=main.zig
54+
pub fn main() !u8 {
55+
var a: u8 = undefined;
56+
a = 255;
57+
_ = a + 1;
58+
return 1;
59+
}
60+
pub const Panic = struct {
61+
pub const call = myPanicNew;
62+
pub const sentinelMismatch = std.debug.FormattedPanic.sentinelMismatch;
63+
pub const unwrapError = std.debug.FormattedPanic.unwrapError;
64+
pub const outOfBounds = std.debug.FormattedPanic.outOfBounds;
65+
pub const startGreaterThanEnd = std.debug.FormattedPanic.startGreaterThanEnd;
66+
pub const inactiveUnionField = std.debug.FormattedPanic.inactiveUnionField;
67+
pub const messages = std.debug.FormattedPanic.messages;
68+
};
69+
fn myPanicNew(msg: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
70+
std.io.getStdOut().writer().print("third panic message: {s}\n", .{msg}) catch {};
71+
std.process.exit(0);
72+
}
73+
const std = @import("std");
74+
#expect_stdout="third panic message: integer overflow\n"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#target=x86_64-linux-selfhosted
2+
#target=x86_64-linux-cbe
3+
#target=x86_64-windows-cbe
4+
#update=initial version
5+
#file=main.zig
6+
const std = @import("std");
7+
pub fn main() !void {}
8+
#expect_stdout=""
9+
10+
#update=introduce parse error
11+
#file=main.zig
12+
pub fn main() !void {
13+
#expect_error=ignored
14+
15+
#update=fix parse error
16+
#file=main.zig
17+
pub fn main() !void {}
18+
#expect_stdout=""

0 commit comments

Comments
 (0)