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 {...@@ -87,13 +87,9 @@ pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type {
87 //copy bytes until we have enough bits, then leave the rest in bit_buffer87 //copy bytes until we have enough bits, then leave the rest in bit_buffer
88 while (out_bits.* < bits) {88 while (out_bits.* < bits) {
89 const n = bits - out_bits.*;89 const n = bits - out_bits.*;
90 const next_byte = self.forward_reader.readByte() catch |err| {90 const next_byte = self.forward_reader.readByte() catch |err| switch (err) {
91 if (err == error.EndOfStream) {91 error.EndOfStream => return @intCast(U, out_buffer),
92 return @intCast(U, out_buffer);92 else => |e| return e,
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);
97 };93 };
9894
99 switch (endian) {95 switch (endian) {
lib/std/io/stream_source.zig+1
...@@ -114,6 +114,7 @@ test "StreamSource (mutable buffer)" {...@@ -114,6 +114,7 @@ test "StreamSource (mutable buffer)" {
114}114}
115115
116test "StreamSource (const buffer)" {116test "StreamSource (const buffer)" {
117 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
117 const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51);118 const buffer: [64]u8 = "Hello, World!".* ++ ([1]u8{0xAA} ** 51);
118 var source = StreamSource{ .const_buffer = std.io.fixedBufferStream(&buffer) };119 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" {...@@ -573,6 +573,7 @@ test "big.rational setFloatString" {
573}573}
574574
575test "big.rational toFloat" {575test "big.rational toFloat" {
576 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
576 var a = try Rational.init(testing.allocator);577 var a = try Rational.init(testing.allocator);
577 defer a.deinit();578 defer a.deinit();
578579
...@@ -586,6 +587,7 @@ test "big.rational toFloat" {...@@ -586,6 +587,7 @@ test "big.rational toFloat" {
586}587}
587588
588test "big.rational set/to Float round-trip" {589test "big.rational set/to Float round-trip" {
590 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
589 var a = try Rational.init(testing.allocator);591 var a = try Rational.init(testing.allocator);
590 defer a.deinit();592 defer a.deinit();
591 var prng = std.rand.DefaultPrng.init(0x5EED);593 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 {...@@ -1342,7 +1342,8 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
1342 };1342 };
1343 defer file.close();1343 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();
1346 var line_buf: [512]u8 = undefined;1347 var line_buf: [512]u8 = undefined;
1347 while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) {1348 while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) {
1348 error.StreamTooLong => blk: {1349 error.StreamTooLong => blk: {
...@@ -1353,7 +1354,10 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {...@@ -1353,7 +1354,10 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
1353 },1354 },
1354 else => |e| return e,1355 else => |e| return e,
1355 }) |line| {1356 }) |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 };
1357 var line_it = mem.tokenize(u8, no_comment_line, " \t");1361 var line_it = mem.tokenize(u8, no_comment_line, " \t");
13581362
1359 const token = line_it.next() orelse continue;1363 const token = line_it.next() orelse continue;
...@@ -1363,7 +1367,8 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {...@@ -1363,7 +1367,8 @@ fn getResolvConf(allocator: mem.Allocator, rc: *ResolvConf) !void {
1363 const name = colon_it.next().?;1367 const name = colon_it.next().?;
1364 const value_txt = colon_it.next() orelse continue;1368 const value_txt = colon_it.next() orelse continue;
1365 const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) {1369 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),
1367 error.InvalidCharacter => continue,1372 error.InvalidCharacter => continue,
1368 };1373 };
1369 if (mem.eql(u8, name, "ndots")) {1374 if (mem.eql(u8, name, "ndots")) {
lib/std/net/test.zig+4
...@@ -5,6 +5,7 @@ const mem = std.mem;...@@ -5,6 +5,7 @@ const mem = std.mem;
5const testing = std.testing;5const testing = std.testing;
66
7test "parse and render IPv6 addresses" {7test "parse and render IPv6 addresses" {
8 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
8 if (builtin.os.tag == .wasi) return error.SkipZigTest;9 if (builtin.os.tag == .wasi) return error.SkipZigTest;
910
10 var buffer: [100]u8 = undefined;11 var buffer: [100]u8 = undefined;
...@@ -67,6 +68,7 @@ test "invalid but parseable IPv6 scope ids" {...@@ -67,6 +68,7 @@ test "invalid but parseable IPv6 scope ids" {
67}68}
6869
69test "parse and render IPv4 addresses" {70test "parse and render IPv4 addresses" {
71 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
70 if (builtin.os.tag == .wasi) return error.SkipZigTest;72 if (builtin.os.tag == .wasi) return error.SkipZigTest;
7173
72 var buffer: [18]u8 = undefined;74 var buffer: [18]u8 = undefined;
...@@ -91,6 +93,7 @@ test "parse and render IPv4 addresses" {...@@ -91,6 +93,7 @@ test "parse and render IPv4 addresses" {
91}93}
9294
93test "parse and render UNIX addresses" {95test "parse and render UNIX addresses" {
96 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
94 if (builtin.os.tag == .wasi) return error.SkipZigTest;97 if (builtin.os.tag == .wasi) return error.SkipZigTest;
95 if (!net.has_unix_sockets) return error.SkipZigTest;98 if (!net.has_unix_sockets) return error.SkipZigTest;
9699
...@@ -104,6 +107,7 @@ test "parse and render UNIX addresses" {...@@ -104,6 +107,7 @@ test "parse and render UNIX addresses" {
104}107}
105108
106test "resolve DNS" {109test "resolve DNS" {
110 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
107 if (builtin.os.tag == .wasi) return error.SkipZigTest;111 if (builtin.os.tag == .wasi) return error.SkipZigTest;
108112
109 if (builtin.os.tag == .windows) {113 if (builtin.os.tag == .windows) {
lib/std/priority_queue.zig+1
...@@ -399,6 +399,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" {...@@ -399,6 +399,7 @@ test "std.PriorityQueue: fromOwnedSlice trivial case 1" {
399}399}
400400
401test "std.PriorityQueue: fromOwnedSlice" {401test "std.PriorityQueue: fromOwnedSlice" {
402 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
402 const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };403 const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 };
403 const heap_items = try testing.allocator.dupe(u32, items[0..]);404 const heap_items = try testing.allocator.dupe(u32, items[0..]);
404 var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {});405 var queue = PQlt.fromOwnedSlice(testing.allocator, heap_items[0..], {});
lib/std/simd.zig+1
...@@ -160,6 +160,7 @@ pub fn extract(...@@ -160,6 +160,7 @@ pub fn extract(
160}160}
161161
162test "vector patterns" {162test "vector patterns" {
163 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
163 const base = @Vector(4, u32){ 10, 20, 30, 40 };164 const base = @Vector(4, u32){ 10, 20, 30, 40 };
164 const other_base = @Vector(4, u32){ 55, 66, 77, 88 };165 const other_base = @Vector(4, u32){ 55, 66, 77, 88 };
165166