mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
23 lines
379 B
Zig
23 lines
379 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
const print = std.debug.print;
|
|
|
|
test "defer unwinding" {
|
|
print("\n", .{});
|
|
|
|
defer {
|
|
print("1 ", .{});
|
|
}
|
|
defer {
|
|
print("2 ", .{});
|
|
}
|
|
if (false) {
|
|
// defers are not run if they are never executed.
|
|
defer {
|
|
print("3 ", .{});
|
|
}
|
|
}
|
|
}
|
|
|
|
// test
|