diff options
| author | Alexandros Naskos <alex_naskos@hotmail.com> | 2020-04-27 15:22:15 +0300 |
|---|---|---|
| committer | Alexandros Naskos <alex_naskos@hotmail.com> | 2020-04-27 15:22:15 +0300 |
| commit | 908b908481260322b60f479ccf4cabff72fcc5d5 (patch) | |
| tree | 56262a1724b716c182ea375ef3ab0a21f3faa352 /test | |
| parent | 179423ec2712956e04f188bf8b904e4fb9b48656 (diff) | |
| download | zig-908b908481260322b60f479ccf4cabff72fcc5d5.tar.gz zig-908b908481260322b60f479ccf4cabff72fcc5d5.zip | |
Added tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage1/behavior.zig | 1 | ||||
| -rw-r--r-- | test/stage1/behavior/bugs/4328.zig | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig index 61b0c1aa56..a420fd6886 100644 --- a/test/stage1/behavior.zig +++ b/test/stage1/behavior.zig @@ -40,6 +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/4560.zig"); _ = @import("behavior/bugs/4769_a.zig"); _ = @import("behavior/bugs/4769_b.zig"); diff --git a/test/stage1/behavior/bugs/4328.zig b/test/stage1/behavior/bugs/4328.zig new file mode 100644 index 0000000000..631c213df1 --- /dev/null +++ b/test/stage1/behavior/bugs/4328.zig @@ -0,0 +1,36 @@ +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; + +test "Extern function call in @TypeOf" { + const Test = struct { + fn test_fn(a: var, b: var) @TypeOf(printf("%d %s\n", a, b)) { + return 0; + } + + fn doTheTest() void { + expectEqual(c_int, @TypeOf(test_fn(0, 42))); + } + }; + + Test.doTheTest(); + comptime Test.doTheTest(); +} + +test "Peer resolution of extern function calls in @TypeOf" { + const Test = struct { + fn test_fn() @TypeOf(ftell(null), fputs(null, null)) { + return 0; + } + + fn doTheTest() void { + expectEqual(c_long, @TypeOf(test_fn())); + } + }; + + Test.doTheTest(); + comptime Test.doTheTest(); +} |
