zig/test/behavior/import.zig

23 lines
615 B
Zig
Raw Normal View History

const expect = @import("std").testing.expect;
const expectEqual = @import("std").testing.expectEqual;
const a_namespace = @import("import/a_namespace.zig");
test "call fn via namespace lookup" {
try expectEqual(@as(i32, 1234), a_namespace.foo());
}
test "importing the same thing gives the same import" {
try expect(@import("std") == @import("std"));
}
test "import in non-toplevel scope" {
const S = struct {
usingnamespace @import("import/a_namespace.zig");
};
try expectEqual(@as(i32, 1234), S.foo());
}
2020-10-27 01:42:23 +08:00
test "import empty file" {
const empty = @import("import/empty.zig");
}