authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-16 20:44:40-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-17 23:50:38-07:00
log95f5e17e49d32a301d6a9d6f9948719d65469b09
treecf0457ec85038f2133ffbc7075e0ccf82d0ec7d1
parent00f3d84f38c54e70716cf8e2908c899b49de1d88

behavior tests: correction of C pointer test

This test was also covering this behavior: ```zig test "equality of pointers to comptime const" { const a: i32 = undefined; comptime assert(&a == &a); } ``` This check belongs in its own behavior test which isolates this behavior; not bundled along with a C pointer test.

2 files changed, 13 insertions(+), 2 deletions(-)

test/behavior/eval.zig+7
...@@ -1110,3 +1110,10 @@ test "no dependency loop for alignment of self tagged union" {...@@ -1110,3 +1110,10 @@ test "no dependency loop for alignment of self tagged union" {
1110 };1110 };
1111 try S.doTheTest();1111 try S.doTheTest();
1112}1112}
1113
1114test "equality of pointers to comptime const" {
1115 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
1116
1117 const a: i32 = undefined;
1118 comptime assert(&a == &a);
1119}
test/behavior/pointers.zig+6-2
...@@ -214,7 +214,10 @@ test "allowzero pointer and slice" {...@@ -214,7 +214,10 @@ test "allowzero pointer and slice" {
214}214}
215215
216test "assign null directly to C pointer and test null equality" {216test "assign null directly to C pointer and test null equality" {
217 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO217 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
218 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
219 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
220 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
218221
219 var x: [*c]i32 = null;222 var x: [*c]i32 = null;
220 try expect(x == null);223 try expect(x == null);
...@@ -238,7 +241,8 @@ test "assign null directly to C pointer and test null equality" {...@@ -238,7 +241,8 @@ test "assign null directly to C pointer and test null equality" {
238 @panic("fail");241 @panic("fail");
239 }242 }
240 const othery: i32 = undefined;243 const othery: i32 = undefined;
241 comptime try expect((y orelse &othery) == &othery);244 const ptr_othery = &othery;
245 comptime try expect((y orelse ptr_othery) == ptr_othery);
242246
243 var n: i32 = 1234;247 var n: i32 = 1234;
244 var x1: [*c]i32 = &n;248 var x1: [*c]i32 = &n;