authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-05-18 19:28:26+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-05-18 19:28:26+03:00
log75a4c02880393c08e245c80ed6114e97e2c47a25
tree33da3518f431b9e1437be67382052c95e7ce8b67
parent400a91e1c644228a66aa1702b9d800f018712105

Updated test


2 files changed, 23 insertions(+), 1 deletions(-)

test/stage1/behavior.zig+1-1
...@@ -40,7 +40,7 @@ comptime {...@@ -40,7 +40,7 @@ comptime {
40 _ = @import("behavior/bugs/3384.zig");40 _ = @import("behavior/bugs/3384.zig");
41 _ = @import("behavior/bugs/3586.zig");41 _ = @import("behavior/bugs/3586.zig");
42 _ = @import("behavior/bugs/3742.zig");42 _ = @import("behavior/bugs/3742.zig");
43 _ = @import("behavior/bugs/4328.zig");43 _ = @import("behavior/bugs/4328_5305.zig");
44 _ = @import("behavior/bugs/4560.zig");44 _ = @import("behavior/bugs/4560.zig");
45 _ = @import("behavior/bugs/4769_a.zig");45 _ = @import("behavior/bugs/4769_a.zig");
46 _ = @import("behavior/bugs/4769_b.zig");46 _ = @import("behavior/bugs/4769_b.zig");
test/stage1/behavior/bugs/4328_5305.zig+22
...@@ -3,9 +3,11 @@ const expectEqual = @import("std").testing.expectEqual;...@@ -3,9 +3,11 @@ const expectEqual = @import("std").testing.expectEqual;
3const FILE = extern struct {3const FILE = extern struct {
4 dummy_field: u8,4 dummy_field: u8,
5};5};
6
6extern fn printf([*c]const u8, ...) c_int;7extern fn printf([*c]const u8, ...) c_int;
7extern fn fputs([*c]const u8, noalias [*c]FILE) c_int;8extern fn fputs([*c]const u8, noalias [*c]FILE) c_int;
8extern fn ftell([*c]FILE) c_long;9extern fn ftell([*c]FILE) c_long;
10extern fn fopen([*c]const u8, [*c]const u8) [*c]FILE;
911
10const S = extern struct {12const S = extern struct {
11 state: c_short,13 state: c_short,
...@@ -47,3 +49,23 @@ test "Peer resolution of extern function calls in @TypeOf" {...@@ -47,3 +49,23 @@ test "Peer resolution of extern function calls in @TypeOf" {
47 Test.doTheTest();49 Test.doTheTest();
48 comptime Test.doTheTest();50 comptime Test.doTheTest();
49}51}
52
53test "Extern function calls, dereferences and field access in @TypeOf" {
54 const Test = struct {
55 fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) {
56 return .{ .dummy_field = 0 };
57 }
58
59 fn test_fn_2(a: var) @TypeOf(fopen("test", "r").*.dummy_field) {
60 return 255;
61 }
62
63 fn doTheTest() void {
64 expectEqual(FILE, @TypeOf(test_fn_1(0)));
65 expectEqual(u8, @TypeOf(test_fn_2(0)));
66 }
67 };
68
69 Test.doTheTest();
70 comptime Test.doTheTest();
71}
\ No newline at end of file