diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-06-07 20:07:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-07 20:07:28 -0400 |
| commit | 6ff7b437ff34e9a416a041c0c0ff8a65bae8daf5 (patch) | |
| tree | e8be8a2b2a1fa6524bead911f3607941d005d8ee /lib/std | |
| parent | 3cb387338234620e00645417565dc234dc5105c2 (diff) | |
| parent | 413577c881963559f7f357bfd90f4ade6d6de20d (diff) | |
| download | zig-6ff7b437ff34e9a416a041c0c0ff8a65bae8daf5.tar.gz zig-6ff7b437ff34e9a416a041c0c0ff8a65bae8daf5.zip | |
Merge pull request #11813 from Vexu/stage2
`zig2 build test-std` finale
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/io/bit_reader.zig | 10 | ||||
| -rw-r--r-- | lib/std/io/stream_source.zig | 1 | ||||
| -rw-r--r-- | lib/std/math/big/rational.zig | 2 | ||||
| -rw-r--r-- | lib/std/net.zig | 11 | ||||
| -rw-r--r-- | lib/std/net/test.zig | 4 | ||||
| -rw-r--r-- | lib/std/priority_queue.zig | 1 | ||||
| -rw-r--r-- | lib/std/simd.zig | 1 |
7 files changed, 20 insertions, 10 deletions
diff --git a/lib/std/io/bit_reader.zig b/lib/std/io/bit_reader.zig index aebb189942..15262f67a2 100644 --- a/lib/std/io/bit_reader.zig +++ b/lib/std/io/bit_reader.zig @@ -87,13 +87,9 @@ pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type { //copy bytes until we have enough bits, then leave the rest in bit_buffer while (out_bits.* < bits) { const n = bits - out_bits.*; - const next_byte = self.forward_reader.readByte() catch |err| { - if (err == error.EndOfStream) { - return @intCast(U, out_buffer); - } - //@BUG: See #1810. Not sure if the bug is that I have to do this for some - // streams, or that I don't for streams with emtpy errorsets. - return @errSetCast(Error, err); + const next_byte = self.forward_reader.readByte() catch |err| switch (err) { + error.EndOfStream => return @intCast(U, out_buffer), + else => |e| return e, }; switch (endian) { diff --git a/lib/std/io/stream_source.zig b/lib/std/io/stream_source.zig index ce5256028c..2345a97855 100644 --- a/lib/std/io/stream_source.zig +++ b/lib/std/io/stream_source.zig @@ -114,6 +114,7 @@ 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) }; diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index de6804ca01..e83b017335 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -573,6 +573,7 @@ test "big.rational setFloatString" { } test "big.rational toFloat" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; var a = try Rational.init(testing.allocator); defer a.deinit(); @@ -586,6 +587,7 @@ test "big.rational toFloat" { } test "big.rational set/to Float round-trip" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; var a = try Rational.init(testing.allocator); defer a.deinit(); var prng = std.rand.DefaultPrng.init(0x5EED); diff --git a/lib/std/net.zig b/lib/std/net.zig index 2bd3e6cfb1..235ad8496a 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1342,7 +1342,8 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void { }; defer file.close(); - const stream = std.io.bufferedReader(file.reader()).reader(); + var buf_reader = std.io.bufferedReader(file.reader()); + const stream = buf_reader.reader(); var line_buf: [512]u8 = undefined; while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) { error.StreamTooLong => blk: { @@ -1353,7 +1354,10 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void { }, else => |e| return e, }) |line| { - const no_comment_line = mem.split(u8, line, "#").next().?; + const no_comment_line = no_comment_line: { + var split = mem.split(u8, line, "#"); + break :no_comment_line split.next().?; + }; var line_it = mem.tokenize(u8, no_comment_line, " \t"); const token = line_it.next() orelse continue; @@ -1363,7 +1367,8 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void { const name = colon_it.next().?; const value_txt = colon_it.next() orelse continue; const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) { - error.Overflow => 255, + // TODO https://github.com/ziglang/zig/issues/11812 + error.Overflow => @as(u8, 255), error.InvalidCharacter => continue, }; if (mem.eql(u8, name, "ndots")) { diff --git a/lib/std/net/test.zig b/lib/std/net/test.zig index f2946777bd..710eb91376 100644 --- a/lib/std/net/test.zig +++ b/lib/std/net/test.zig @@ -5,6 +5,7 @@ const mem = std.mem; const testing = std.testing; test "parse and render IPv6 addresses" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest; var buffer: [100]u8 = undefined; @@ -67,6 +68,7 @@ test "invalid but parseable IPv6 scope ids" { } test "parse and render IPv4 addresses" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest; var buffer: [18]u8 = undefined; @@ -91,6 +93,7 @@ test "parse and render IPv4 addresses" { } test "parse and render UNIX addresses" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest; if (!net.has_unix_sockets) return error.SkipZigTest; @@ -104,6 +107,7 @@ test "parse and render UNIX addresses" { } test "resolve DNS" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest; if (builtin.os.tag == .windows) { diff --git a/lib/std/priority_queue.zig b/lib/std/priority_queue.zig index ebc13a9974..51671bca78 100644 --- a/lib/std/priority_queue.zig +++ b/lib/std/priority_queue.zig @@ -399,6 +399,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" { } test "std.PriorityQueue: fromOwnedSlice" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; const heap_items = try testing.allocator.dupe(u32, items[0..]); var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {}); diff --git a/lib/std/simd.zig b/lib/std/simd.zig index a30622aef6..a7ce0ab3fd 100644 --- a/lib/std/simd.zig +++ b/lib/std/simd.zig @@ -160,6 +160,7 @@ pub fn extract( } test "vector patterns" { + if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; const base = @Vector(4, u32){ 10, 20, 30, 40 }; const other_base = @Vector(4, u32){ 55, 66, 77, 88 }; |
