| author | |
| committer | |
| log | 14acc65675a35f838b5e73aeaca595ced0c10a0c |
| tree | 8f649d016093ef46834225cde79aeb4b162eb988 |
| parent | a5379aa3ee376197820f1526c88921607a787a11 |
| signature |
3 files changed, 24 insertions(+), 0 deletions(-)
test/compile_errors.zig+8| ... | @@ -2,6 +2,14 @@ const tests = @import("tests.zig"); | ... | @@ -2,6 +2,14 @@ const tests = @import("tests.zig"); |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | 3 | ||
| 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.add("@src outside function", | ||
| 6 | \\comptime { | ||
| 7 | \\ @src(); | ||
| 8 | \\} | ||
| 9 | , &[_][]const u8{ | ||
| 10 | "tmp.zig:2:5: error: @src outside function", | ||
| 11 | }); | ||
| 12 | |||
| 5 | cases.add("call assigned to constant", | 13 | cases.add("call assigned to constant", |
| 6 | \\const Foo = struct { | 14 | \\const Foo = struct { |
| 7 | \\ x: i32, | 15 | \\ x: i32, |
test/stage1/behavior.zig+1| ... | @@ -131,4 +131,5 @@ comptime { | ... | @@ -131,4 +131,5 @@ comptime { |
| 131 | } | 131 | } |
| 132 | _ = @import("behavior/while.zig"); | 132 | _ = @import("behavior/while.zig"); |
| 133 | _ = @import("behavior/widening.zig"); | 133 | _ = @import("behavior/widening.zig"); |
| 134 | _ = @import("behavior/src.zig"); | ||
| 134 | } | 135 | } |
test/stage1/behavior/src.zig created+15| ... | @@ -0,0 +1,15 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const expect = std.testing.expect; | ||
| 3 | |||
| 4 | test "@src" { | ||
| 5 | doTheTest(); | ||
| 6 | } | ||
| 7 | |||
| 8 | fn doTheTest() void { | ||
| 9 | const src = @src(); | ||
| 10 | |||
| 11 | expect(src.line == 9); | ||
| 12 | expect(src.column == 17); | ||
| 13 | expect(std.mem.endsWith(u8, src.fn_name, "doTheTest")); | ||
| 14 | expect(std.mem.endsWith(u8, src.file, "src.zig")); | ||
| 15 | } | ||