Updated test

master
Alexandros Naskos 2020-05-18 19:28:26 +03:00
parent 400a91e1c6
commit 75a4c02880
2 changed files with 23 additions and 1 deletions

View File

@ -40,7 +40,7 @@ comptime {
_ = @import("behavior/bugs/3384.zig");
_ = @import("behavior/bugs/3586.zig");
_ = @import("behavior/bugs/3742.zig");
_ = @import("behavior/bugs/4328.zig");
_ = @import("behavior/bugs/4328_5305.zig");
_ = @import("behavior/bugs/4560.zig");
_ = @import("behavior/bugs/4769_a.zig");
_ = @import("behavior/bugs/4769_b.zig");

View File

@ -3,9 +3,11 @@ const expectEqual = @import("std").testing.expectEqual;
const FILE = extern struct {
dummy_field: u8,
};
extern fn printf([*c]const u8, ...) c_int;
extern fn fputs([*c]const u8, noalias [*c]FILE) c_int;
extern fn ftell([*c]FILE) c_long;
extern fn fopen([*c]const u8, [*c]const u8) [*c]FILE;
const S = extern struct {
state: c_short,
@ -47,3 +49,23 @@ test "Peer resolution of extern function calls in @TypeOf" {
Test.doTheTest();
comptime Test.doTheTest();
}
test "Extern function calls, dereferences and field access in @TypeOf" {
const Test = struct {
fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) {
return .{ .dummy_field = 0 };
}
fn test_fn_2(a: var) @TypeOf(fopen("test", "r").*.dummy_field) {
return 255;
}
fn doTheTest() void {
expectEqual(FILE, @TypeOf(test_fn_1(0)));
expectEqual(u8, @TypeOf(test_fn_2(0)));
}
};
Test.doTheTest();
comptime Test.doTheTest();
}