mirror of
https://github.com/ziglang/zig.git
synced 2026-01-13 10:55:11 +00:00
And fix test cases to make them pass. This is in preparation for starting to pass behavior tests with self-hosted.
18 lines
399 B
Zig
18 lines
399 B
Zig
const expect = @import("std").testing.expect;
|
|
|
|
fn get_foo() fn (*u8) usize {
|
|
comptime {
|
|
return struct {
|
|
fn func(ptr: *u8) usize {
|
|
var u = @ptrToInt(ptr);
|
|
return u;
|
|
}
|
|
}.func;
|
|
}
|
|
}
|
|
|
|
test "define a function in an anonymous struct in comptime" {
|
|
const foo = get_foo();
|
|
expect(foo(@intToPtr(*u8, 12345)) == 12345);
|
|
}
|