authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-04-07 15:24:49+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-04-07 16:56:48+03:00
log95fefcd4c91e517a51f4b55924979421c6f7e8d3
tree4f97c938c754390cab322ac4008d0177279f0286
parente62671f643a5072fb8e56306a87a2772dc357e9c
signaturelock-open Commit is signed but in an unrecognized format.

fix broken tests


6 files changed, 20 insertions(+), 18 deletions(-)

lib/std/json.zig+6-5
......@@ -1327,12 +1327,13 @@ test "Value.jsonStringify" {
13271327 {
13281328 var buffer: [10]u8 = undefined;
13291329 var fbs = std.io.fixedBufferStream(&buffer);
1330 var vals = [_]Value{
1331 .{ .Integer = 1 },
1332 .{ .Integer = 2 },
1333 .{ .Integer = 3 },
1334 };
13301335 try (Value{
1331 .Array = Array.fromOwnedSlice(undefined, &[_]Value{
1332 .{ .Integer = 1 },
1333 .{ .Integer = 2 },
1334 .{ .Integer = 3 },
1335 }),
1336 .Array = Array.fromOwnedSlice(undefined, &vals),
13361337 }).jsonStringify(.{}, fbs.outStream());
13371338 testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]");
13381339 }
lib/std/testing.zig+2-1
......@@ -7,7 +7,8 @@ pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAll
77pub const allocator = &allocator_instance.allocator;
88pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator);
99
10pub const failing_allocator = &FailingAllocator.init(&base_allocator_instance.allocator, 0).allocator;
10pub const failing_allocator = &failing_allocator_instance.allocator;
11pub var failing_allocator_instance = FailingAllocator.init(&base_allocator_instance.allocator, 0);
1112
1213pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]);
1314var allocator_mem: [1024 * 1024]u8 = undefined;
test/compile_errors.zig+5-5
......@@ -997,7 +997,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
997997 \\ const x = 1 << &@as(u8, 10);
998998 \\}
999999 , &[_][]const u8{
1000 "tmp.zig:2:21: error: shift amount has to be an integer type, but found '*u8'",
1000 "tmp.zig:2:21: error: shift amount has to be an integer type, but found '*const u8'",
10011001 "tmp.zig:2:17: note: referenced here",
10021002 });
10031003
......@@ -1006,7 +1006,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10061006 \\ const x = &@as(u8, 1) << 10;
10071007 \\}
10081008 , &[_][]const u8{
1009 "tmp.zig:2:16: error: bit shifting operation expected integer type, found '*u8'",
1009 "tmp.zig:2:16: error: bit shifting operation expected integer type, found '*const u8'",
10101010 "tmp.zig:2:27: note: referenced here",
10111011 });
10121012
......@@ -6033,7 +6033,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
60336033 \\ fn bar(self: *const Foo) void {}
60346034 \\};
60356035 , &[_][]const u8{
6036 "tmp.zig:2:4: error: variable of type '*comptime_int' must be const or comptime",
6036 "tmp.zig:2:4: error: variable of type '*const comptime_int' must be const or comptime",
60376037 "tmp.zig:5:4: error: variable of type '(undefined)' must be const or comptime",
60386038 "tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",
60396039 "tmp.zig:11:4: error: variable of type 'comptime_float' must be const or comptime",
......@@ -6877,12 +6877,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
68776877 \\ const word: u16 = @bitCast(u16, bytes[0..]);
68786878 \\}
68796879 \\export fn foo2() void {
6880 \\ var bytes: []u8 = &[_]u8{1, 2};
6880 \\ var bytes: []const u8 = &[_]u8{1, 2};
68816881 \\ const word: u16 = @bitCast(u16, bytes);
68826882 \\}
68836883 , &[_][]const u8{
68846884 "tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'",
6885 "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]u8' has size 16",
6885 "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]const u8' has size 16",
68866886 "tmp.zig:7:37: note: referenced here",
68876887 });
68886888
test/stage1/behavior/for.zig+2-2
......@@ -161,8 +161,8 @@ test "for copies its payload" {
161161
162162test "for on slice with allowzero ptr" {
163163 const S = struct {
164 fn doTheTest(slice: []u8) void {
165 var ptr = @ptrCast([*]allowzero u8, slice.ptr)[0..slice.len];
164 fn doTheTest(slice: []const u8) void {
165 var ptr = @ptrCast([*]const allowzero u8, slice.ptr)[0..slice.len];
166166 for (ptr) |x, i| expect(x == i + 1);
167167 for (ptr) |*x, i| expect(x.* == i + 1);
168168 }
test/stage1/behavior/pointers.zig+3-3
......@@ -253,7 +253,7 @@ test "pointer sentinel with enums" {
253253 };
254254
255255 fn doTheTest() void {
256 var ptr: [*:.sentinel]Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
256 var ptr: [*:.sentinel]const Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
257257 expect(ptr[4] == .sentinel); // TODO this should be comptime expect, see #3731
258258 }
259259 };
......@@ -264,7 +264,7 @@ test "pointer sentinel with enums" {
264264test "pointer sentinel with optional element" {
265265 const S = struct {
266266 fn doTheTest() void {
267 var ptr: [*:null]?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
267 var ptr: [*:null]const ?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
268268 expect(ptr[4] == null); // TODO this should be comptime expect, see #3731
269269 }
270270 };
......@@ -276,7 +276,7 @@ test "pointer sentinel with +inf" {
276276 const S = struct {
277277 fn doTheTest() void {
278278 const inf = std.math.inf_f32;
279 var ptr: [*:inf]f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
279 var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
280280 expect(ptr[4] == inf); // TODO this should be comptime expect, see #3731
281281 }
282282 };
test/stage1/behavior/slice.zig+2-2
......@@ -218,9 +218,9 @@ test "slice syntax resulting in pointer-to-array" {
218218 }
219219
220220 fn testPointer0() void {
221 var pointer: [*]u0 = &[1]u0{0};
221 var pointer: [*]const u0 = &[1]u0{0};
222222 var slice = pointer[0..1];
223 comptime expect(@TypeOf(slice) == *[1]u0);
223 comptime expect(@TypeOf(slice) == *const [1]u0);
224224 expect(slice[0] == 0);
225225 }
226226