mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge pull request #24448 from matklad/matklad/inline
langref: make example more interesting.
This commit is contained in:
commit
d3cd0b2714
2 changed files with 7 additions and 5 deletions
|
|
@ -1,8 +1,7 @@
|
|||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
const print = std.debug.print;
|
||||
|
||||
test "defer unwinding" {
|
||||
pub fn main() void {
|
||||
print("\n", .{});
|
||||
|
||||
defer {
|
||||
|
|
@ -19,4 +18,4 @@ test "defer unwinding" {
|
|||
}
|
||||
}
|
||||
|
||||
// test
|
||||
// exe=succeed
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
test "inline function call" {
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() void {
|
||||
if (foo(1200, 34) != 1234) {
|
||||
@compileError("bad");
|
||||
}
|
||||
}
|
||||
|
||||
inline fn foo(a: i32, b: i32) i32 {
|
||||
std.debug.print("runtime a = {} b = {}", .{ a, b });
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// test
|
||||
// exe=succeed
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue