I found some more passing behavior tests

This commit is contained in:
Andrew Kelley
2021-11-29 22:36:52 -07:00
parent 20e19e75fd
commit 0a9b4d092f
6 changed files with 248 additions and 262 deletions

View File

@@ -1,4 +1,5 @@
const std = @import("std");
const expect = std.testing.expect;
const A = struct {
pub const B = bool;
@@ -11,3 +12,42 @@ const C = struct {
test "basic usingnamespace" {
try std.testing.expect(C.B == bool);
}
fn Foo(comptime T: type) type {
return struct {
usingnamespace T;
};
}
test "usingnamespace inside a generic struct" {
const std2 = Foo(std);
const testing2 = Foo(std.testing);
try std2.testing.expect(true);
try testing2.expect(true);
}
usingnamespace struct {
pub const foo = 42;
};
test "usingnamespace does not redeclare an imported variable" {
comptime try std.testing.expect(@This().foo == 42);
}
usingnamespace @import("usingnamespace/foo.zig");
test "usingnamespace omits mixing in private functions" {
try expect(@This().privateFunction());
try expect(!@This().printText());
}
fn privateFunction() bool {
return true;
}
test {
_ = @import("usingnamespace/import_segregation.zig");
}
usingnamespace @import("usingnamespace/a.zig");
test "two files usingnamespace import each other" {
try expect(@This().ok());
}