add tests for @src
This commit is contained in:
@@ -2,6 +2,14 @@ const tests = @import("tests.zig");
|
||||
const std = @import("std");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add("@src outside function",
|
||||
\\comptime {
|
||||
\\ @src();
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:5: error: @src outside function",
|
||||
});
|
||||
|
||||
cases.add("call assigned to constant",
|
||||
\\const Foo = struct {
|
||||
\\ x: i32,
|
||||
|
||||
@@ -131,4 +131,5 @@ comptime {
|
||||
}
|
||||
_ = @import("behavior/while.zig");
|
||||
_ = @import("behavior/widening.zig");
|
||||
_ = @import("behavior/src.zig");
|
||||
}
|
||||
|
||||
15
test/stage1/behavior/src.zig
Normal file
15
test/stage1/behavior/src.zig
Normal file
@@ -0,0 +1,15 @@
|
||||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "@src" {
|
||||
doTheTest();
|
||||
}
|
||||
|
||||
fn doTheTest() void {
|
||||
const src = @src();
|
||||
|
||||
expect(src.line == 9);
|
||||
expect(src.column == 17);
|
||||
expect(std.mem.endsWith(u8, src.fn_name, "doTheTest"));
|
||||
expect(std.mem.endsWith(u8, src.file, "src.zig"));
|
||||
}
|
||||
Reference in New Issue
Block a user