authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-06-18 21:03:08+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-06-18 21:11:34+03:00
log14acc65675a35f838b5e73aeaca595ced0c10a0c
tree8f649d016093ef46834225cde79aeb4b162eb988
parenta5379aa3ee376197820f1526c88921607a787a11
signature Commit is signed but in an unrecognized format.

add tests for `@src`


3 files changed, 24 insertions(+), 0 deletions(-)

test/compile_errors.zig+8
......@@ -2,6 +2,14 @@ const tests = @import("tests.zig");
22const std = @import("std");
33
44pub 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
513 cases.add("call assigned to constant",
614 \\const Foo = struct {
715 \\ x: i32,
test/stage1/behavior.zig+1
......@@ -131,4 +131,5 @@ comptime {
131131 }
132132 _ = @import("behavior/while.zig");
133133 _ = @import("behavior/widening.zig");
134 _ = @import("behavior/src.zig");
134135}
test/stage1/behavior/src.zig created+15
......@@ -0,0 +1,15 @@
1const std = @import("std");
2const expect = std.testing.expect;
3
4test "@src" {
5 doTheTest();
6}
7
8fn 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}