| author | |
| committer | |
| log | 95fefcd4c91e517a51f4b55924979421c6f7e8d3 |
| tree | 4f97c938c754390cab322ac4008d0177279f0286 |
| parent | e62671f643a5072fb8e56306a87a2772dc357e9c |
| signature |
6 files changed, 20 insertions(+), 18 deletions(-)
lib/std/json.zig+6-5| ... | ... | @@ -1327,12 +1327,13 @@ test "Value.jsonStringify" { |
| 1327 | 1327 | { |
| 1328 | 1328 | var buffer: [10]u8 = undefined; |
| 1329 | 1329 | var fbs = std.io.fixedBufferStream(&buffer); |
| 1330 | var vals = [_]Value{ | |
| 1331 | .{ .Integer = 1 }, | |
| 1332 | .{ .Integer = 2 }, | |
| 1333 | .{ .Integer = 3 }, | |
| 1334 | }; | |
| 1330 | 1335 | try (Value{ |
| 1331 | .Array = Array.fromOwnedSlice(undefined, &[_]Value{ | |
| 1332 | .{ .Integer = 1 }, | |
| 1333 | .{ .Integer = 2 }, | |
| 1334 | .{ .Integer = 3 }, | |
| 1335 | }), | |
| 1336 | .Array = Array.fromOwnedSlice(undefined, &vals), | |
| 1336 | 1337 | }).jsonStringify(.{}, fbs.outStream()); |
| 1337 | 1338 | testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]"); |
| 1338 | 1339 | } |
lib/std/testing.zig+2-1| ... | ... | @@ -7,7 +7,8 @@ pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAll |
| 7 | 7 | pub const allocator = &allocator_instance.allocator; |
| 8 | 8 | pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator); |
| 9 | 9 | |
| 10 | pub const failing_allocator = &FailingAllocator.init(&base_allocator_instance.allocator, 0).allocator; | |
| 10 | pub const failing_allocator = &failing_allocator_instance.allocator; | |
| 11 | pub var failing_allocator_instance = FailingAllocator.init(&base_allocator_instance.allocator, 0); | |
| 11 | 12 | |
| 12 | 13 | pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]); |
| 13 | 14 | var allocator_mem: [1024 * 1024]u8 = undefined; |
test/compile_errors.zig+5-5| ... | ... | @@ -997,7 +997,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 997 | 997 | \\ const x = 1 << &@as(u8, 10); |
| 998 | 998 | \\} |
| 999 | 999 | , &[_][]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'", | |
| 1001 | 1001 | "tmp.zig:2:17: note: referenced here", |
| 1002 | 1002 | }); |
| 1003 | 1003 | |
| ... | ... | @@ -1006,7 +1006,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1006 | 1006 | \\ const x = &@as(u8, 1) << 10; |
| 1007 | 1007 | \\} |
| 1008 | 1008 | , &[_][]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'", | |
| 1010 | 1010 | "tmp.zig:2:27: note: referenced here", |
| 1011 | 1011 | }); |
| 1012 | 1012 | |
| ... | ... | @@ -6033,7 +6033,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6033 | 6033 | \\ fn bar(self: *const Foo) void {} |
| 6034 | 6034 | \\}; |
| 6035 | 6035 | , &[_][]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", | |
| 6037 | 6037 | "tmp.zig:5:4: error: variable of type '(undefined)' must be const or comptime", |
| 6038 | 6038 | "tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime", |
| 6039 | 6039 | "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 { |
| 6877 | 6877 | \\ const word: u16 = @bitCast(u16, bytes[0..]); |
| 6878 | 6878 | \\} |
| 6879 | 6879 | \\export fn foo2() void { |
| 6880 | \\ var bytes: []u8 = &[_]u8{1, 2}; | |
| 6880 | \\ var bytes: []const u8 = &[_]u8{1, 2}; | |
| 6881 | 6881 | \\ const word: u16 = @bitCast(u16, bytes); |
| 6882 | 6882 | \\} |
| 6883 | 6883 | , &[_][]const u8{ |
| 6884 | 6884 | "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", | |
| 6886 | 6886 | "tmp.zig:7:37: note: referenced here", |
| 6887 | 6887 | }); |
| 6888 | 6888 |
test/stage1/behavior/for.zig+2-2| ... | ... | @@ -161,8 +161,8 @@ test "for copies its payload" { |
| 161 | 161 | |
| 162 | 162 | test "for on slice with allowzero ptr" { |
| 163 | 163 | 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]; | |
| 166 | 166 | for (ptr) |x, i| expect(x == i + 1); |
| 167 | 167 | for (ptr) |*x, i| expect(x.* == i + 1); |
| 168 | 168 | } |
test/stage1/behavior/pointers.zig+3-3| ... | ... | @@ -253,7 +253,7 @@ test "pointer sentinel with enums" { |
| 253 | 253 | }; |
| 254 | 254 | |
| 255 | 255 | 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 }; | |
| 257 | 257 | expect(ptr[4] == .sentinel); // TODO this should be comptime expect, see #3731 |
| 258 | 258 | } |
| 259 | 259 | }; |
| ... | ... | @@ -264,7 +264,7 @@ test "pointer sentinel with enums" { |
| 264 | 264 | test "pointer sentinel with optional element" { |
| 265 | 265 | const S = struct { |
| 266 | 266 | 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 }; | |
| 268 | 268 | expect(ptr[4] == null); // TODO this should be comptime expect, see #3731 |
| 269 | 269 | } |
| 270 | 270 | }; |
| ... | ... | @@ -276,7 +276,7 @@ test "pointer sentinel with +inf" { |
| 276 | 276 | const S = struct { |
| 277 | 277 | fn doTheTest() void { |
| 278 | 278 | 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 }; | |
| 280 | 280 | expect(ptr[4] == inf); // TODO this should be comptime expect, see #3731 |
| 281 | 281 | } |
| 282 | 282 | }; |
test/stage1/behavior/slice.zig+2-2| ... | ... | @@ -218,9 +218,9 @@ test "slice syntax resulting in pointer-to-array" { |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | fn testPointer0() void { |
| 221 | var pointer: [*]u0 = &[1]u0{0}; | |
| 221 | var pointer: [*]const u0 = &[1]u0{0}; | |
| 222 | 222 | var slice = pointer[0..1]; |
| 223 | comptime expect(@TypeOf(slice) == *[1]u0); | |
| 223 | comptime expect(@TypeOf(slice) == *const [1]u0); | |
| 224 | 224 | expect(slice[0] == 0); |
| 225 | 225 | } |
| 226 | 226 |