update behavior tests and compile error tests

This commit is contained in:
Andrew Kelley 2022-01-31 22:33:49 -07:00
parent 75bbc74d56
commit 4d22fa5a2a
4 changed files with 2 additions and 38 deletions

View file

@ -149,6 +149,7 @@ test {
_ = @import("behavior/bugs/10147.zig");
_ = @import("behavior/byteswap.zig");
_ = @import("behavior/const_slice_child.zig");
_ = @import("behavior/export_self_referential_type_info.zig");
_ = @import("behavior/field_parent_ptr.zig");
_ = @import("behavior/floatop_stage1.zig");
_ = @import("behavior/fn_delegation.zig");

View file

@ -0,0 +1 @@
export const foo = @typeInfo(@This()).Struct.decls;

View file

@ -286,10 +286,6 @@ fn testStruct() !void {
try expect(struct_info.Struct.fields[3].alignment == 1);
try expect(struct_info.Struct.decls.len == 2);
try expect(struct_info.Struct.decls[0].is_pub);
try expect(!struct_info.Struct.decls[0].data.Fn.is_extern);
try expect(struct_info.Struct.decls[0].data.Fn.lib_name == null);
try expect(struct_info.Struct.decls[0].data.Fn.return_type == void);
try expect(struct_info.Struct.decls[0].data.Fn.fn_type == fn (*const TestStruct) void);
}
const TestUnpackedStruct = struct {
@ -420,34 +416,6 @@ test "type info: TypeId -> TypeInfo impl cast" {
_ = comptime passTypeInfo(TypeId.Void);
}
test "type info: extern fns with and without lib names" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
const S = struct {
extern fn bar1() void;
extern "cool" fn bar2() void;
};
const info = @typeInfo(S);
comptime {
for (info.Struct.decls) |decl| {
if (std.mem.eql(u8, decl.name, "bar1")) {
try expect(decl.data.Fn.lib_name == null);
} else {
try expectEqualStrings("cool", decl.data.Fn.lib_name.?);
}
}
}
}
test "data field is a compile-time value" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
const S = struct {
const Bar = @as(isize, -1);
};
comptime try expect(@typeInfo(S).Struct.decls[0].data.Var == isize);
}
test "sentinel of opaque pointer type" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO

View file

@ -1199,12 +1199,6 @@ pub fn addCases(ctx: *TestContext) !void {
"tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void'",
});
ctx.testErrStage1("dependency loop in top-level decl with @TypeInfo when accessing the decls",
\\export const foo = @typeInfo(@This()).Struct.decls;
, &[_][]const u8{
"tmp.zig:1:20: error: dependency loop detected",
});
ctx.objErrStage1("function call assigned to incorrect type",
\\export fn entry() void {
\\ var arr: [4]f32 = undefined;