authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-31 22:33:49-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-31 22:33:49-07:00
log4d22fa5a2a4afce59b91efc7a6142ec633f0bd4d
treec0eefd69483492a922bfcb0ae2bb85db76eed111
parent75bbc74d56f26da812c47436c6f5712d3cfde12d

update behavior tests and compile error tests


4 files changed, 2 insertions(+), 38 deletions(-)

test/behavior.zig+1
...@@ -149,6 +149,7 @@ test {...@@ -149,6 +149,7 @@ test {
149 _ = @import("behavior/bugs/10147.zig");149 _ = @import("behavior/bugs/10147.zig");
150 _ = @import("behavior/byteswap.zig");150 _ = @import("behavior/byteswap.zig");
151 _ = @import("behavior/const_slice_child.zig");151 _ = @import("behavior/const_slice_child.zig");
152 _ = @import("behavior/export_self_referential_type_info.zig");
152 _ = @import("behavior/field_parent_ptr.zig");153 _ = @import("behavior/field_parent_ptr.zig");
153 _ = @import("behavior/floatop_stage1.zig");154 _ = @import("behavior/floatop_stage1.zig");
154 _ = @import("behavior/fn_delegation.zig");155 _ = @import("behavior/fn_delegation.zig");
test/behavior/export_self_referential_type_info.zig created+1
...@@ -0,0 +1 @@
1export const foo = @typeInfo(@This()).Struct.decls;
test/behavior/type_info.zig-32
...@@ -286,10 +286,6 @@ fn testStruct() !void {...@@ -286,10 +286,6 @@ fn testStruct() !void {
286 try expect(struct_info.Struct.fields[3].alignment == 1);286 try expect(struct_info.Struct.fields[3].alignment == 1);
287 try expect(struct_info.Struct.decls.len == 2);287 try expect(struct_info.Struct.decls.len == 2);
288 try expect(struct_info.Struct.decls[0].is_pub);288 try expect(struct_info.Struct.decls[0].is_pub);
289 try expect(!struct_info.Struct.decls[0].data.Fn.is_extern);
290 try expect(struct_info.Struct.decls[0].data.Fn.lib_name == null);
291 try expect(struct_info.Struct.decls[0].data.Fn.return_type == void);
292 try expect(struct_info.Struct.decls[0].data.Fn.fn_type == fn (*const TestStruct) void);
293}289}
294290
295const TestUnpackedStruct = struct {291const TestUnpackedStruct = struct {
...@@ -420,34 +416,6 @@ test "type info: TypeId -> TypeInfo impl cast" {...@@ -420,34 +416,6 @@ test "type info: TypeId -> TypeInfo impl cast" {
420 _ = comptime passTypeInfo(TypeId.Void);416 _ = comptime passTypeInfo(TypeId.Void);
421}417}
422418
423test "type info: extern fns with and without lib names" {
424 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
425
426 const S = struct {
427 extern fn bar1() void;
428 extern "cool" fn bar2() void;
429 };
430 const info = @typeInfo(S);
431 comptime {
432 for (info.Struct.decls) |decl| {
433 if (std.mem.eql(u8, decl.name, "bar1")) {
434 try expect(decl.data.Fn.lib_name == null);
435 } else {
436 try expectEqualStrings("cool", decl.data.Fn.lib_name.?);
437 }
438 }
439 }
440}
441
442test "data field is a compile-time value" {
443 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
444
445 const S = struct {
446 const Bar = @as(isize, -1);
447 };
448 comptime try expect(@typeInfo(S).Struct.decls[0].data.Var == isize);
449}
450
451test "sentinel of opaque pointer type" {419test "sentinel of opaque pointer type" {
452 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO420 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
453421
test/compile_errors.zig-6
...@@ -1199,12 +1199,6 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1199,12 +1199,6 @@ pub fn addCases(ctx: *TestContext) !void {
1199 "tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void'",1199 "tmp.zig:5:22: error: expected type 'fn([*c]u8, ...) callconv(.C) void', found 'fn([*:0]u8, ...) callconv(.C) void'",
1200 });1200 });
12011201
1202 ctx.testErrStage1("dependency loop in top-level decl with @TypeInfo when accessing the decls",
1203 \\export const foo = @typeInfo(@This()).Struct.decls;
1204 , &[_][]const u8{
1205 "tmp.zig:1:20: error: dependency loop detected",
1206 });
1207
1208 ctx.objErrStage1("function call assigned to incorrect type",1202 ctx.objErrStage1("function call assigned to incorrect type",
1209 \\export fn entry() void {1203 \\export fn entry() void {
1210 \\ var arr: [4]f32 = undefined;1204 \\ var arr: [4]f32 = undefined;