authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-07 19:14:07+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-07 21:27:07+03:00
log413577c881963559f7f357bfd90f4ade6d6de20d
tree10ff3de8d476b129e72f7f6641a937eb26c8592e
parent6de9eea7bce4023ae150fb5b4d417d66b9bf13fb

std: adjust for stage2 semantics


7 files changed, 20 insertions(+), 10 deletions(-)

lib/std/io/bit_reader.zig+3-7
......@@ -87,13 +87,9 @@ pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type {
8787 //copy bytes until we have enough bits, then leave the rest in bit_buffer
8888 while (out_bits.* < bits) {
8989 const n = bits - out_bits.*;
90 const next_byte = self.forward_reader.readByte() catch |err| {
91 if (err == error.EndOfStream) {
92 return @intCast(U, out_buffer);
93 }
94 //@BUG: See #1810. Not sure if the bug is that I have to do this for some
95 // streams, or that I don't for streams with emtpy errorsets.
96 return @errSetCast(Error, err);
90 const next_byte = self.forward_reader.readByte() catch |err| switch (err) {
91 error.EndOfStream => return @intCast(U, out_buffer),
92 else => |e| return e,
9793 };
9894
9995 switch (endian) {
lib/std/io/stream_source.zig+1
......@@ -114,6 +114,7 @@ test "StreamSource (mutable buffer)" {
114114}
115115
116116test "StreamSource (const buffer)" {
117 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
117118 const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51);
118119 var source = StreamSource{ .const_buffer = std.io.fixedBufferStream(&buffer) };
119120
lib/std/math/big/rational.zig+2
......@@ -573,6 +573,7 @@ test "big.rational setFloatString" {
573573}
574574
575575test "big.rational toFloat" {
576 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
576577 var a = try Rational.init(testing.allocator);
577578 defer a.deinit();
578579
......@@ -586,6 +587,7 @@ test "big.rational toFloat" {
586587}
587588
588589test "big.rational set/to Float round-trip" {
590 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
589591 var a = try Rational.init(testing.allocator);
590592 defer a.deinit();
591593 var prng = std.rand.DefaultPrng.init(0x5EED);
lib/std/net.zig+8-3
......@@ -1342,7 +1342,8 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
13421342 };
13431343 defer file.close();
13441344
1345 const stream = std.io.bufferedReader(file.reader()).reader();
1345 var buf_reader = std.io.bufferedReader(file.reader());
1346 const stream = buf_reader.reader();
13461347 var line_buf: [512]u8 = undefined;
13471348 while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) {
13481349 error.StreamTooLong => blk: {
......@@ -1353,7 +1354,10 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
13531354 },
13541355 else => |e| return e,
13551356 }) |line| {
1356 const no_comment_line = mem.split(u8, line, "#").next().?;
1357 const no_comment_line = no_comment_line: {
1358 var split = mem.split(u8, line, "#");
1359 break :no_comment_line split.next().?;
1360 };
13571361 var line_it = mem.tokenize(u8, no_comment_line, " \t");
13581362
13591363 const token = line_it.next() orelse continue;
......@@ -1363,7 +1367,8 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
13631367 const name = colon_it.next().?;
13641368 const value_txt = colon_it.next() orelse continue;
13651369 const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) {
1366 error.Overflow => 255,
1370 // TODO https://github.com/ziglang/zig/issues/11812
1371 error.Overflow => @as(u8, 255),
13671372 error.InvalidCharacter => continue,
13681373 };
13691374 if (mem.eql(u8, name, "ndots")) {
lib/std/net/test.zig+4
......@@ -5,6 +5,7 @@ const mem = std.mem;
55const testing = std.testing;
66
77test "parse and render IPv6 addresses" {
8 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
89 if (builtin.os.tag == .wasi) return error.SkipZigTest;
910
1011 var buffer: [100]u8 = undefined;
......@@ -67,6 +68,7 @@ test "invalid but parseable IPv6 scope ids" {
6768}
6869
6970test "parse and render IPv4 addresses" {
71 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
7072 if (builtin.os.tag == .wasi) return error.SkipZigTest;
7173
7274 var buffer: [18]u8 = undefined;
......@@ -91,6 +93,7 @@ test "parse and render IPv4 addresses" {
9193}
9294
9395test "parse and render UNIX addresses" {
96 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
9497 if (builtin.os.tag == .wasi) return error.SkipZigTest;
9598 if (!net.has_unix_sockets) return error.SkipZigTest;
9699
......@@ -104,6 +107,7 @@ test "parse and render UNIX addresses" {
104107}
105108
106109test "resolve DNS" {
110 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
107111 if (builtin.os.tag == .wasi) return error.SkipZigTest;
108112
109113 if (builtin.os.tag == .windows) {
lib/std/priority_queue.zig+1
......@@ -399,6 +399,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" {
399399}
400400
401401test "std.PriorityQueue: fromOwnedSlice" {
402 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
402403 const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };
403404 const heap_items = try testing.allocator.dupe(u32, items[0..]);
404405 var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {});
lib/std/simd.zig+1
......@@ -160,6 +160,7 @@ pub fn extract(
160160}
161161
162162test "vector patterns" {
163 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
163164 const base = @Vector(4, u32){ 10, 20, 30, 40 };
164165 const other_base = @Vector(4, u32){ 55, 66, 77, 88 };
165166