fix broken tests
parent
e62671f643
commit
95fefcd4c9
|
@ -1327,12 +1327,13 @@ test "Value.jsonStringify" {
|
|||
{
|
||||
var buffer: [10]u8 = undefined;
|
||||
var fbs = std.io.fixedBufferStream(&buffer);
|
||||
var vals = [_]Value{
|
||||
.{ .Integer = 1 },
|
||||
.{ .Integer = 2 },
|
||||
.{ .Integer = 3 },
|
||||
};
|
||||
try (Value{
|
||||
.Array = Array.fromOwnedSlice(undefined, &[_]Value{
|
||||
.{ .Integer = 1 },
|
||||
.{ .Integer = 2 },
|
||||
.{ .Integer = 3 },
|
||||
}),
|
||||
.Array = Array.fromOwnedSlice(undefined, &vals),
|
||||
}).jsonStringify(.{}, fbs.outStream());
|
||||
testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]");
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAll
|
|||
pub const allocator = &allocator_instance.allocator;
|
||||
pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator);
|
||||
|
||||
pub const failing_allocator = &FailingAllocator.init(&base_allocator_instance.allocator, 0).allocator;
|
||||
pub const failing_allocator = &failing_allocator_instance.allocator;
|
||||
pub var failing_allocator_instance = FailingAllocator.init(&base_allocator_instance.allocator, 0);
|
||||
|
||||
pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]);
|
||||
var allocator_mem: [1024 * 1024]u8 = undefined;
|
||||
|
|
|
@ -997,7 +997,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\ const x = 1 << &@as(u8, 10);
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:21: error: shift amount has to be an integer type, but found '*u8'",
|
||||
"tmp.zig:2:21: error: shift amount has to be an integer type, but found '*const u8'",
|
||||
"tmp.zig:2:17: note: referenced here",
|
||||
});
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\ const x = &@as(u8, 1) << 10;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:16: error: bit shifting operation expected integer type, found '*u8'",
|
||||
"tmp.zig:2:16: error: bit shifting operation expected integer type, found '*const u8'",
|
||||
"tmp.zig:2:27: note: referenced here",
|
||||
});
|
||||
|
||||
|
@ -6033,7 +6033,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\ fn bar(self: *const Foo) void {}
|
||||
\\};
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:4: error: variable of type '*comptime_int' must be const or comptime",
|
||||
"tmp.zig:2:4: error: variable of type '*const comptime_int' must be const or comptime",
|
||||
"tmp.zig:5:4: error: variable of type '(undefined)' must be const or comptime",
|
||||
"tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",
|
||||
"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 {
|
|||
\\ const word: u16 = @bitCast(u16, bytes[0..]);
|
||||
\\}
|
||||
\\export fn foo2() void {
|
||||
\\ var bytes: []u8 = &[_]u8{1, 2};
|
||||
\\ var bytes: []const u8 = &[_]u8{1, 2};
|
||||
\\ const word: u16 = @bitCast(u16, bytes);
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'",
|
||||
"tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]u8' has size 16",
|
||||
"tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]const u8' has size 16",
|
||||
"tmp.zig:7:37: note: referenced here",
|
||||
});
|
||||
|
||||
|
|
|
@ -161,8 +161,8 @@ test "for copies its payload" {
|
|||
|
||||
test "for on slice with allowzero ptr" {
|
||||
const S = struct {
|
||||
fn doTheTest(slice: []u8) void {
|
||||
var ptr = @ptrCast([*]allowzero u8, slice.ptr)[0..slice.len];
|
||||
fn doTheTest(slice: []const u8) void {
|
||||
var ptr = @ptrCast([*]const allowzero u8, slice.ptr)[0..slice.len];
|
||||
for (ptr) |x, i| expect(x == i + 1);
|
||||
for (ptr) |*x, i| expect(x.* == i + 1);
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ test "pointer sentinel with enums" {
|
|||
};
|
||||
|
||||
fn doTheTest() void {
|
||||
var ptr: [*:.sentinel]Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
|
||||
var ptr: [*:.sentinel]const Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
|
||||
expect(ptr[4] == .sentinel); // TODO this should be comptime expect, see #3731
|
||||
}
|
||||
};
|
||||
|
@ -264,7 +264,7 @@ test "pointer sentinel with enums" {
|
|||
test "pointer sentinel with optional element" {
|
||||
const S = struct {
|
||||
fn doTheTest() void {
|
||||
var ptr: [*:null]?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
|
||||
var ptr: [*:null]const ?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
|
||||
expect(ptr[4] == null); // TODO this should be comptime expect, see #3731
|
||||
}
|
||||
};
|
||||
|
@ -276,7 +276,7 @@ test "pointer sentinel with +inf" {
|
|||
const S = struct {
|
||||
fn doTheTest() void {
|
||||
const inf = std.math.inf_f32;
|
||||
var ptr: [*:inf]f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
|
||||
var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
|
||||
expect(ptr[4] == inf); // TODO this should be comptime expect, see #3731
|
||||
}
|
||||
};
|
||||
|
|
|
@ -218,9 +218,9 @@ test "slice syntax resulting in pointer-to-array" {
|
|||
}
|
||||
|
||||
fn testPointer0() void {
|
||||
var pointer: [*]u0 = &[1]u0{0};
|
||||
var pointer: [*]const u0 = &[1]u0{0};
|
||||
var slice = pointer[0..1];
|
||||
comptime expect(@TypeOf(slice) == *[1]u0);
|
||||
comptime expect(@TypeOf(slice) == *const [1]u0);
|
||||
expect(slice[0] == 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue