Merge pull request #11837 from Vexu/stage2
Fix (nearly) all stage2 crashes when testing stdlib
This commit is contained in:
@@ -1330,6 +1330,7 @@ fn testStaticBitSet(comptime Set: type) !void {
|
||||
}
|
||||
|
||||
test "IntegerBitSet" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
try testStaticBitSet(IntegerBitSet(0));
|
||||
try testStaticBitSet(IntegerBitSet(1));
|
||||
try testStaticBitSet(IntegerBitSet(2));
|
||||
@@ -1341,6 +1342,7 @@ test "IntegerBitSet" {
|
||||
}
|
||||
|
||||
test "ArrayBitSet" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
if (@import("builtin").cpu.arch == .aarch64) {
|
||||
// https://github.com/ziglang/zig/issues/9879
|
||||
return error.SkipZigTest;
|
||||
@@ -1355,6 +1357,7 @@ test "ArrayBitSet" {
|
||||
}
|
||||
|
||||
test "DynamicBitSetUnmanaged" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const allocator = std.testing.allocator;
|
||||
var a = try DynamicBitSetUnmanaged.initEmpty(allocator, 300);
|
||||
try testing.expectEqual(@as(usize, 0), a.count());
|
||||
@@ -1395,6 +1398,7 @@ test "DynamicBitSetUnmanaged" {
|
||||
}
|
||||
|
||||
test "DynamicBitSet" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const allocator = std.testing.allocator;
|
||||
var a = try DynamicBitSet.initEmpty(allocator, 300);
|
||||
try testing.expectEqual(@as(usize, 0), a.count());
|
||||
|
||||
@@ -5,7 +5,6 @@ pub const gzip = @import("compress/gzip.zig");
|
||||
pub const zlib = @import("compress/zlib.zig");
|
||||
|
||||
test {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
|
||||
_ = deflate;
|
||||
_ = gzip;
|
||||
_ = zlib;
|
||||
|
||||
@@ -254,7 +254,10 @@ pub fn Compressor(comptime WriterType: anytype) type {
|
||||
|
||||
// Inner writer wrapped in a HuffmanBitWriter
|
||||
hm_bw: hm_bw.HuffmanBitWriter(WriterType) = undefined,
|
||||
bulk_hasher: fn ([]u8, []u32) u32,
|
||||
bulk_hasher: if (@import("builtin").zig_backend == .stage1)
|
||||
fn ([]u8, []u32) u32
|
||||
else
|
||||
*const fn ([]u8, []u32) u32,
|
||||
|
||||
sync: bool, // requesting flush
|
||||
best_speed_enc: *fast.DeflateFast, // Encoder for best_speed
|
||||
|
||||
@@ -122,11 +122,8 @@ fn testToFromWithLevelAndLimit(level: deflate.Compression, input: []const u8, li
|
||||
try expect(compressed.items.len <= limit);
|
||||
}
|
||||
|
||||
var decomp = try decompressor(
|
||||
testing.allocator,
|
||||
io.fixedBufferStream(compressed.items).reader(),
|
||||
null,
|
||||
);
|
||||
var fib = io.fixedBufferStream(compressed.items);
|
||||
var decomp = try decompressor(testing.allocator, fib.reader(), null);
|
||||
defer decomp.deinit();
|
||||
|
||||
var decompressed = try testing.allocator.alloc(u8, input.len);
|
||||
@@ -136,7 +133,9 @@ fn testToFromWithLevelAndLimit(level: deflate.Compression, input: []const u8, li
|
||||
try expect(read == input.len);
|
||||
try expect(mem.eql(u8, input, decompressed));
|
||||
|
||||
try testSync(level, input);
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
try testSync(level, input);
|
||||
}
|
||||
}
|
||||
|
||||
fn testToFromWithLimit(input: []const u8, limit: [11]u32) !void {
|
||||
@@ -475,21 +474,16 @@ test "inflate reset" {
|
||||
try comp.close();
|
||||
}
|
||||
|
||||
var decomp = try decompressor(
|
||||
testing.allocator,
|
||||
io.fixedBufferStream(compressed_strings[0].items).reader(),
|
||||
null,
|
||||
);
|
||||
var fib = io.fixedBufferStream(compressed_strings[0].items);
|
||||
var decomp = try decompressor(testing.allocator, fib.reader(), null);
|
||||
defer decomp.deinit();
|
||||
|
||||
var decompressed_0: []u8 = try decomp.reader()
|
||||
.readAllAlloc(testing.allocator, math.maxInt(usize));
|
||||
defer testing.allocator.free(decompressed_0);
|
||||
|
||||
try decomp.reset(
|
||||
io.fixedBufferStream(compressed_strings[1].items).reader(),
|
||||
null,
|
||||
);
|
||||
fib = io.fixedBufferStream(compressed_strings[1].items);
|
||||
try decomp.reset(fib.reader(), null);
|
||||
|
||||
var decompressed_1: []u8 = try decomp.reader()
|
||||
.readAllAlloc(testing.allocator, math.maxInt(usize));
|
||||
@@ -530,21 +524,16 @@ test "inflate reset dictionary" {
|
||||
try comp.close();
|
||||
}
|
||||
|
||||
var decomp = try decompressor(
|
||||
testing.allocator,
|
||||
io.fixedBufferStream(compressed_strings[0].items).reader(),
|
||||
dict,
|
||||
);
|
||||
var fib = io.fixedBufferStream(compressed_strings[0].items);
|
||||
var decomp = try decompressor(testing.allocator, fib.reader(), dict);
|
||||
defer decomp.deinit();
|
||||
|
||||
var decompressed_0: []u8 = try decomp.reader()
|
||||
.readAllAlloc(testing.allocator, math.maxInt(usize));
|
||||
defer testing.allocator.free(decompressed_0);
|
||||
|
||||
try decomp.reset(
|
||||
io.fixedBufferStream(compressed_strings[1].items).reader(),
|
||||
dict,
|
||||
);
|
||||
fib = io.fixedBufferStream(compressed_strings[1].items);
|
||||
try decomp.reset(fib.reader(), dict);
|
||||
|
||||
var decompressed_1: []u8 = try decomp.reader()
|
||||
.readAllAlloc(testing.allocator, math.maxInt(usize));
|
||||
|
||||
@@ -334,7 +334,10 @@ pub fn Decompressor(comptime ReaderType: type) type {
|
||||
|
||||
// Next step in the decompression,
|
||||
// and decompression state.
|
||||
step: fn (*Self) Error!void,
|
||||
step: if (@import("builtin").zig_backend == .stage1)
|
||||
fn (*Self) Error!void
|
||||
else
|
||||
*const fn (*Self) Error!void,
|
||||
step_state: DecompressorState,
|
||||
final: bool,
|
||||
err: ?Error,
|
||||
@@ -479,7 +482,13 @@ pub fn Decompressor(comptime ReaderType: type) type {
|
||||
}
|
||||
|
||||
pub fn close(self: *Self) ?Error {
|
||||
if (self.err == Error.EndOfStreamWithNoError) {
|
||||
if (@import("builtin").zig_backend == .stage1) {
|
||||
if (self.err == Error.EndOfStreamWithNoError) {
|
||||
return null;
|
||||
}
|
||||
return self.err;
|
||||
}
|
||||
if (self.err == @as(?Error, error.EndOfStreamWithNoError)) {
|
||||
return null;
|
||||
}
|
||||
return self.err;
|
||||
@@ -920,7 +929,8 @@ test "truncated input" {
|
||||
};
|
||||
|
||||
for (tests) |t| {
|
||||
var r = io.fixedBufferStream(t.input).reader();
|
||||
var fib = io.fixedBufferStream(t.input);
|
||||
const r = fib.reader();
|
||||
var z = try decompressor(testing.allocator, r, null);
|
||||
defer z.deinit();
|
||||
var zr = z.reader();
|
||||
@@ -959,7 +969,8 @@ test "Go non-regression test for 9842" {
|
||||
};
|
||||
|
||||
for (tests) |t| {
|
||||
const reader = std.io.fixedBufferStream(t.input).reader();
|
||||
var fib = std.io.fixedBufferStream(t.input);
|
||||
const reader = fib.reader();
|
||||
var decomp = try decompressor(testing.allocator, reader, null);
|
||||
defer decomp.deinit();
|
||||
|
||||
@@ -1017,7 +1028,8 @@ test "inflate A Tale of Two Cities (1859) intro" {
|
||||
\\
|
||||
;
|
||||
|
||||
const reader = std.io.fixedBufferStream(&compressed).reader();
|
||||
var fib = std.io.fixedBufferStream(&compressed);
|
||||
const reader = fib.reader();
|
||||
var decomp = try decompressor(testing.allocator, reader, null);
|
||||
defer decomp.deinit();
|
||||
|
||||
@@ -1082,7 +1094,8 @@ test "fuzzing" {
|
||||
|
||||
fn decompress(input: []const u8) !void {
|
||||
const allocator = testing.allocator;
|
||||
const reader = std.io.fixedBufferStream(input).reader();
|
||||
var fib = std.io.fixedBufferStream(input);
|
||||
const reader = fib.reader();
|
||||
var decomp = try decompressor(allocator, reader, null);
|
||||
defer decomp.deinit();
|
||||
var output = try decomp.reader().readAllAlloc(allocator, math.maxInt(usize));
|
||||
|
||||
@@ -78,11 +78,8 @@ test "best speed" {
|
||||
var decompressed = try testing.allocator.alloc(u8, want.items.len);
|
||||
defer testing.allocator.free(decompressed);
|
||||
|
||||
var decomp = try inflate.decompressor(
|
||||
testing.allocator,
|
||||
io.fixedBufferStream(compressed.items).reader(),
|
||||
null,
|
||||
);
|
||||
var fib = io.fixedBufferStream(compressed.items);
|
||||
var decomp = try inflate.decompressor(testing.allocator, fib.reader(), null);
|
||||
defer decomp.deinit();
|
||||
|
||||
var read = try decomp.reader().readAll(decompressed);
|
||||
@@ -122,13 +119,13 @@ test "best speed max match offset" {
|
||||
// zeros1 is between 0 and 30 zeros.
|
||||
// The difference between the two abc's will be offset, which
|
||||
// is max_match_offset plus or minus a small adjustment.
|
||||
var src_len: usize = @intCast(usize, offset + abc.len + @intCast(i32, extra));
|
||||
var src_len: usize = @intCast(usize, offset + @as(i32, abc.len) + @intCast(i32, extra));
|
||||
var src = try testing.allocator.alloc(u8, src_len);
|
||||
defer testing.allocator.free(src);
|
||||
|
||||
mem.copy(u8, src, abc);
|
||||
if (!do_match_before) {
|
||||
var src_offset: usize = @intCast(usize, offset - xyz.len);
|
||||
var src_offset: usize = @intCast(usize, offset - @as(i32, xyz.len));
|
||||
mem.copy(u8, src[src_offset..], xyz);
|
||||
}
|
||||
var src_offset: usize = @intCast(usize, offset);
|
||||
@@ -149,11 +146,8 @@ test "best speed max match offset" {
|
||||
var decompressed = try testing.allocator.alloc(u8, src.len);
|
||||
defer testing.allocator.free(decompressed);
|
||||
|
||||
var decomp = try inflate.decompressor(
|
||||
testing.allocator,
|
||||
io.fixedBufferStream(compressed.items).reader(),
|
||||
null,
|
||||
);
|
||||
var fib = io.fixedBufferStream(compressed.items);
|
||||
var decomp = try inflate.decompressor(testing.allocator, fib.reader(), null);
|
||||
defer decomp.deinit();
|
||||
var read = try decomp.reader().readAll(decompressed);
|
||||
_ = decomp.close();
|
||||
|
||||
@@ -897,6 +897,7 @@ test "kdf" {
|
||||
}
|
||||
|
||||
test "phc format hasher" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const allocator = std.testing.allocator;
|
||||
const password = "testpass";
|
||||
|
||||
@@ -912,6 +913,7 @@ test "phc format hasher" {
|
||||
}
|
||||
|
||||
test "password hash and password verify" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const allocator = std.testing.allocator;
|
||||
const password = "testpass";
|
||||
|
||||
|
||||
@@ -802,6 +802,7 @@ test "bcrypt crypt format" {
|
||||
}
|
||||
|
||||
test "bcrypt phc format" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const hash_options = HashOptions{
|
||||
.params = .{ .rounds_log = 5 },
|
||||
.encoding = .phc,
|
||||
|
||||
@@ -260,6 +260,7 @@ fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } {
|
||||
}
|
||||
|
||||
test "phc format - encoding/decoding" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const Input = struct {
|
||||
str: []const u8,
|
||||
HashResult: type,
|
||||
|
||||
@@ -683,6 +683,7 @@ test "unix-scrypt" {
|
||||
}
|
||||
|
||||
test "crypt format" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const str = "$7$C6..../....SodiumChloride$kBGj9fHznVYFQMEn/qDCfrDevf9YDtcDdKvEqHJLV8D";
|
||||
const params = try crypt_format.deserialize(crypt_format.HashResult(32), str);
|
||||
var buf: [str.len]u8 = undefined;
|
||||
|
||||
@@ -2111,7 +2111,6 @@ test "slice" {
|
||||
}
|
||||
|
||||
test "escape non-printable" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
try expectFmt("abc", "{s}", .{fmtSliceEscapeLower("abc")});
|
||||
try expectFmt("ab\\xffc", "{s}", .{fmtSliceEscapeLower("ab\xffc")});
|
||||
try expectFmt("ab\\xFFc", "{s}", .{fmtSliceEscapeUpper("ab\xffc")});
|
||||
@@ -2148,7 +2147,6 @@ test "cstr" {
|
||||
}
|
||||
|
||||
test "filesize" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeDec(42)});
|
||||
try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeBin(42)});
|
||||
try expectFmt("file size: 63MB\n", "file size: {}\n", .{fmtIntSizeDec(63 * 1000 * 1000)});
|
||||
@@ -2192,18 +2190,22 @@ test "enum" {
|
||||
}
|
||||
|
||||
test "non-exhaustive enum" {
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// stage1 fails to return fully qualified namespaces.
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const Enum = enum(u16) {
|
||||
One = 0x000f,
|
||||
Two = 0xbeef,
|
||||
_,
|
||||
};
|
||||
try expectFmt("enum: Enum.One\n", "enum: {}\n", .{Enum.One});
|
||||
try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{Enum.Two});
|
||||
try expectFmt("enum: Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)});
|
||||
try expectFmt("enum: Enum.One\n", "enum: {x}\n", .{Enum.One});
|
||||
try expectFmt("enum: Enum.Two\n", "enum: {x}\n", .{Enum.Two});
|
||||
try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two});
|
||||
try expectFmt("enum: Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)});
|
||||
try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {}\n", .{Enum.One});
|
||||
try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {}\n", .{Enum.Two});
|
||||
try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)});
|
||||
try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.One\n", "enum: {x}\n", .{Enum.One});
|
||||
try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {x}\n", .{Enum.Two});
|
||||
try expectFmt("enum: fmt.test.non-exhaustive enum.Enum.Two\n", "enum: {X}\n", .{Enum.Two});
|
||||
try expectFmt("enum: fmt.test.non-exhaustive enum.Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)});
|
||||
}
|
||||
|
||||
test "float.scientific" {
|
||||
@@ -2223,6 +2225,7 @@ test "float.scientific.precision" {
|
||||
}
|
||||
|
||||
test "float.special" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
try expectFmt("f64: nan", "f64: {}", .{math.nan_f64});
|
||||
// negative nan is not defined by IEE 754,
|
||||
// and ARM thus normalizes it to positive nan
|
||||
@@ -2234,6 +2237,7 @@ test "float.special" {
|
||||
}
|
||||
|
||||
test "float.hexadecimal.special" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
try expectFmt("f64: nan", "f64: {x}", .{math.nan_f64});
|
||||
// negative nan is not defined by IEE 754,
|
||||
// and ARM thus normalizes it to positive nan
|
||||
@@ -2359,6 +2363,10 @@ test "custom" {
|
||||
}
|
||||
|
||||
test "struct" {
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// stage1 fails to return fully qualified namespaces.
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const S = struct {
|
||||
a: u32,
|
||||
b: anyerror,
|
||||
@@ -2369,7 +2377,7 @@ test "struct" {
|
||||
.b = error.Unused,
|
||||
};
|
||||
|
||||
try expectFmt("S{ .a = 456, .b = error.Unused }", "{}", .{inst});
|
||||
try expectFmt("fmt.test.struct.S{ .a = 456, .b = error.Unused }", "{}", .{inst});
|
||||
// Tuples
|
||||
try expectFmt("{ }", "{}", .{.{}});
|
||||
try expectFmt("{ -1 }", "{}", .{.{-1}});
|
||||
@@ -2377,6 +2385,10 @@ test "struct" {
|
||||
}
|
||||
|
||||
test "union" {
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// stage1 fails to return fully qualified namespaces.
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const TU = union(enum) {
|
||||
float: f32,
|
||||
int: u32,
|
||||
@@ -2396,17 +2408,21 @@ test "union" {
|
||||
const uu_inst = UU{ .int = 456 };
|
||||
const eu_inst = EU{ .float = 321.123 };
|
||||
|
||||
try expectFmt("TU{ .int = 123 }", "{}", .{tu_inst});
|
||||
try expectFmt("fmt.test.union.TU{ .int = 123 }", "{}", .{tu_inst});
|
||||
|
||||
var buf: [100]u8 = undefined;
|
||||
const uu_result = try bufPrint(buf[0..], "{}", .{uu_inst});
|
||||
try std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@"));
|
||||
try std.testing.expect(mem.eql(u8, uu_result[0..18], "fmt.test.union.UU@"));
|
||||
|
||||
const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst});
|
||||
try std.testing.expect(mem.eql(u8, eu_result[0..3], "EU@"));
|
||||
try std.testing.expect(mem.eql(u8, eu_result[0..18], "fmt.test.union.EU@"));
|
||||
}
|
||||
|
||||
test "enum" {
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// stage1 fails to return fully qualified namespaces.
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const E = enum {
|
||||
One,
|
||||
Two,
|
||||
@@ -2415,10 +2431,14 @@ test "enum" {
|
||||
|
||||
const inst = E.Two;
|
||||
|
||||
try expectFmt("E.Two", "{}", .{inst});
|
||||
try expectFmt("fmt.test.enum.E.Two", "{}", .{inst});
|
||||
}
|
||||
|
||||
test "struct.self-referential" {
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// stage1 fails to return fully qualified namespaces.
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const S = struct {
|
||||
const SelfType = @This();
|
||||
a: ?*SelfType,
|
||||
@@ -2429,10 +2449,14 @@ test "struct.self-referential" {
|
||||
};
|
||||
inst.a = &inst;
|
||||
|
||||
try expectFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", .{inst});
|
||||
try expectFmt("fmt.test.struct.self-referential.S{ .a = fmt.test.struct.self-referential.S{ .a = fmt.test.struct.self-referential.S{ .a = fmt.test.struct.self-referential.S{ ... } } } }", "{}", .{inst});
|
||||
}
|
||||
|
||||
test "struct.zero-size" {
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// stage1 fails to return fully qualified namespaces.
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const A = struct {
|
||||
fn foo() void {}
|
||||
};
|
||||
@@ -2444,11 +2468,10 @@ test "struct.zero-size" {
|
||||
const a = A{};
|
||||
const b = B{ .a = a, .c = 0 };
|
||||
|
||||
try expectFmt("B{ .a = A{ }, .c = 0 }", "{}", .{b});
|
||||
try expectFmt("fmt.test.struct.zero-size.B{ .a = fmt.test.struct.zero-size.A{ }, .c = 0 }", "{}", .{b});
|
||||
}
|
||||
|
||||
test "bytes.hex" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
const some_bytes = "\xCA\xFE\xBA\xBE";
|
||||
try expectFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{fmtSliceHexLower(some_bytes)});
|
||||
try expectFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{fmtSliceHexUpper(some_bytes)});
|
||||
@@ -2480,7 +2503,6 @@ pub fn hexToBytes(out: []u8, input: []const u8) ![]u8 {
|
||||
}
|
||||
|
||||
test "hexToBytes" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
var buf: [32]u8 = undefined;
|
||||
try expectFmt("90" ** 32, "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "90" ** 32))});
|
||||
try expectFmt("ABCD", "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "ABCD"))});
|
||||
@@ -2512,6 +2534,10 @@ test "formatFloatValue with comptime_float" {
|
||||
}
|
||||
|
||||
test "formatType max_depth" {
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// stage1 fails to return fully qualified namespaces.
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const Vec2 = struct {
|
||||
const SelfType = @This();
|
||||
x: f32,
|
||||
@@ -2562,19 +2588,19 @@ test "formatType max_depth" {
|
||||
var buf: [1000]u8 = undefined;
|
||||
var fbs = std.io.fixedBufferStream(&buf);
|
||||
try formatType(inst, "", FormatOptions{}, fbs.writer(), 0);
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ ... }"));
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ ... }"));
|
||||
|
||||
fbs.reset();
|
||||
try formatType(inst, "", FormatOptions{}, fbs.writer(), 1);
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }"));
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ ... }, .tu = fmt.test.formatType max_depth.TU{ ... }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }"));
|
||||
|
||||
fbs.reset();
|
||||
try formatType(inst, "", FormatOptions{}, fbs.writer(), 2);
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }"));
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ ... }, .tu = fmt.test.formatType max_depth.TU{ ... }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }, .tu = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ ... } }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }"));
|
||||
|
||||
fbs.reset();
|
||||
try formatType(inst, "", FormatOptions{}, fbs.writer(), 3);
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "S{ .a = S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ .ptr = TU{ ... } } }, .e = E.Two, .vec = (10.200,2.220) }"));
|
||||
try std.testing.expect(mem.eql(u8, fbs.getWritten(), "fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ .a = fmt.test.formatType max_depth.S{ ... }, .tu = fmt.test.formatType max_depth.TU{ ... }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }, .tu = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ ... } }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }, .tu = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ .ptr = fmt.test.formatType max_depth.TU{ ... } } }, .e = fmt.test.formatType max_depth.E.Two, .vec = (10.200,2.220) }"));
|
||||
}
|
||||
|
||||
test "positional" {
|
||||
|
||||
@@ -114,7 +114,6 @@ test "StreamSource (mutable buffer)" {
|
||||
}
|
||||
|
||||
test "StreamSource (const buffer)" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
|
||||
const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51);
|
||||
var source = StreamSource{ .const_buffer = std.io.fixedBufferStream(&buffer) };
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude)
|
||||
}
|
||||
|
||||
test "math.copysign" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
|
||||
try expect(copysign(@as(T, 1.0), @as(T, 1.0)) == 1.0);
|
||||
try expect(copysign(@as(T, 2.0), @as(T, -2.0)) == -2.0);
|
||||
|
||||
@@ -10,6 +10,7 @@ pub fn signbit(x: anytype) bool {
|
||||
}
|
||||
|
||||
test "math.signbit" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
|
||||
try expect(!signbit(@as(T, 0.0)));
|
||||
try expect(!signbit(@as(T, 1.0)));
|
||||
|
||||
@@ -2080,6 +2080,7 @@ fn testReadIntImpl() !void {
|
||||
}
|
||||
|
||||
test "writeIntSlice" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
try testWriteIntImpl();
|
||||
comptime try testWriteIntImpl();
|
||||
}
|
||||
|
||||
@@ -286,6 +286,7 @@ const PQlt = PriorityQueue(u32, void, lessThan);
|
||||
const PQgt = PriorityQueue(u32, void, greaterThan);
|
||||
|
||||
test "std.PriorityQueue: add and remove min heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -304,6 +305,7 @@ test "std.PriorityQueue: add and remove min heap" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: add and remove same min heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -353,6 +355,7 @@ test "std.PriorityQueue: peek" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: sift up with odd indices" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };
|
||||
@@ -367,6 +370,7 @@ test "std.PriorityQueue: sift up with odd indices" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: addSlice" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };
|
||||
@@ -412,6 +416,7 @@ test "std.PriorityQueue: fromOwnedSlice" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: add and remove max heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQgt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -430,6 +435,7 @@ test "std.PriorityQueue: add and remove max heap" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: add and remove same max heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQgt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -470,6 +476,7 @@ test "std.PriorityQueue: iterator" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: remove at index" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -505,6 +512,7 @@ test "std.PriorityQueue: iterator while empty" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: shrinkAndFree" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -528,6 +536,7 @@ test "std.PriorityQueue: shrinkAndFree" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: update min heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -543,6 +552,7 @@ test "std.PriorityQueue: update min heap" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: update same min heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -559,6 +569,7 @@ test "std.PriorityQueue: update same min heap" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: update max heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQgt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -574,6 +585,7 @@ test "std.PriorityQueue: update max heap" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: update same max heap" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQgt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -590,6 +602,7 @@ test "std.PriorityQueue: update same max heap" {
|
||||
}
|
||||
|
||||
test "std.PriorityQueue: siftUp in remove" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
var queue = PQlt.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
@@ -610,6 +623,7 @@ fn contextLessThan(context: []const u32, a: usize, b: usize) Order {
|
||||
const CPQlt = PriorityQueue(usize, []const u32, contextLessThan);
|
||||
|
||||
test "std.PriorityQueue: add and remove min heap with contextful comparator" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const context = [_]u32{ 5, 3, 4, 2, 2, 8, 0 };
|
||||
|
||||
var queue = CPQlt.init(testing.allocator, context[0..]);
|
||||
|
||||
@@ -214,6 +214,7 @@ pub const Tz = struct {
|
||||
};
|
||||
|
||||
test "slim" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const data = @embedFile("tz/asia_tokyo.tzif");
|
||||
var in_stream = std.io.fixedBufferStream(data);
|
||||
|
||||
@@ -227,6 +228,7 @@ test "slim" {
|
||||
}
|
||||
|
||||
test "fat" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
const data = @embedFile("tz/antarctica_davis.tzif");
|
||||
var in_stream = std.io.fixedBufferStream(data);
|
||||
|
||||
@@ -239,6 +241,7 @@ test "fat" {
|
||||
}
|
||||
|
||||
test "legacy" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
// Taken from Slackware 8.0, from 2001
|
||||
const data = @embedFile("tz/europe_vatican.tzif");
|
||||
var in_stream = std.io.fixedBufferStream(data);
|
||||
|
||||
@@ -804,7 +804,6 @@ pub fn fmtUtf16le(utf16le: []const u16) std.fmt.Formatter(formatUtf16le) {
|
||||
}
|
||||
|
||||
test "fmtUtf16le" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
|
||||
const expectFmt = std.testing.expectFmt;
|
||||
try expectFmt("", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral(""))});
|
||||
try expectFmt("foo", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral("foo"))});
|
||||
|
||||
@@ -13,7 +13,6 @@ pub const net = struct {
|
||||
};
|
||||
|
||||
test {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
|
||||
inline for (.{ os, net }) |module| {
|
||||
std.testing.refAllDecls(module);
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ pub const Reactor = struct {
|
||||
};
|
||||
|
||||
test "reactor/linux: drive async tcp client/listener pair" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
|
||||
if (native_os.tag != .linux) return error.SkipZigTest;
|
||||
|
||||
const ip = std.x.net.ip;
|
||||
|
||||
@@ -381,7 +381,7 @@ pub const IPv6 = extern struct {
|
||||
});
|
||||
}
|
||||
|
||||
const zero_span = span: {
|
||||
const zero_span: struct { from: usize, to: usize } = span: {
|
||||
var i: usize = 0;
|
||||
while (i < self.octets.len) : (i += 2) {
|
||||
if (self.octets[i] == 0 and self.octets[i + 1] == 0) break;
|
||||
|
||||
Reference in New Issue
Block a user