mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
261fec8036
- unwrap_errunion_err for registers - unwrap_errunion_payload for registers - ptr_slice_len_ptr for all MCValues - ptr_slice_ptr_ptr for all MCValues
37 lines
727 B
Zig
37 lines
727 B
Zig
const expect = @import("std").testing.expect;
|
|
const builtin = @import("builtin");
|
|
|
|
const module = @This();
|
|
|
|
fn Point(comptime T: type) type {
|
|
return struct {
|
|
const Self = @This();
|
|
x: T,
|
|
y: T,
|
|
|
|
fn addOne(self: *Self) void {
|
|
self.x += 1;
|
|
self.y += 1;
|
|
}
|
|
};
|
|
}
|
|
|
|
fn add(x: i32, y: i32) i32 {
|
|
return x + y;
|
|
}
|
|
|
|
test "this refer to module call private fn" {
|
|
try expect(module.add(1, 2) == 3);
|
|
}
|
|
|
|
test "this refer to container" {
|
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
|
|
var pt: Point(i32) = undefined;
|
|
pt.x = 12;
|
|
pt.y = 34;
|
|
Point(i32).addOne(&pt);
|
|
try expect(pt.x == 13);
|
|
try expect(pt.y == 35);
|
|
}
|