authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-21 13:56:38+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-06-21 13:56:38+03:00
logd980c6a38dc133f509032eb7337e720089369a77
tree36c0a814a5861c97839e16b6766a130925a1338f
parentca9862578903a93089e6aae71bb8641b580bc4f6
parentd0d5052b398b81d8907ea7c16ba38cd14d1c8d04
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #11899 from Vexu/stage2

Stage2: fixes for std tests

8 files changed, 8 insertions(+), 16 deletions(-)

lib/std/crypto/argon2.zig-2
...@@ -897,7 +897,6 @@ test "kdf" {...@@ -897,7 +897,6 @@ test "kdf" {
897}897}
898898
899test "phc format hasher" {899test "phc format hasher" {
900 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
901 const allocator = std.testing.allocator;900 const allocator = std.testing.allocator;
902 const password = "testpass";901 const password = "testpass";
903902
...@@ -913,7 +912,6 @@ test "phc format hasher" {...@@ -913,7 +912,6 @@ test "phc format hasher" {
913}912}
914913
915test "password hash and password verify" {914test "password hash and password verify" {
916 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
917 const allocator = std.testing.allocator;915 const allocator = std.testing.allocator;
918 const password = "testpass";916 const password = "testpass";
919917
lib/std/crypto/bcrypt.zig-1
...@@ -802,7 +802,6 @@ test "bcrypt crypt format" {...@@ -802,7 +802,6 @@ test "bcrypt crypt format" {
802}802}
803803
804test "bcrypt phc format" {804test "bcrypt phc format" {
805 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
806 const hash_options = HashOptions{805 const hash_options = HashOptions{
807 .params = .{ .rounds_log = 5 },806 .params = .{ .rounds_log = 5 },
808 .encoding = .phc,807 .encoding = .phc,
lib/std/crypto/phc_encoding.zig+2-3
...@@ -41,7 +41,7 @@ pub fn BinValue(comptime max_len: usize) type {...@@ -41,7 +41,7 @@ pub fn BinValue(comptime max_len: usize) type {
41 }41 }
4242
43 /// Return the slice containing the actual value.43 /// Return the slice containing the actual value.
44 pub fn constSlice(self: Self) []const u8 {44 pub fn constSlice(self: *const Self) []const u8 {
45 return self.buf[0..self.len];45 return self.buf[0..self.len];
46 }46 }
4747
...@@ -52,7 +52,7 @@ pub fn BinValue(comptime max_len: usize) type {...@@ -52,7 +52,7 @@ pub fn BinValue(comptime max_len: usize) type {
52 self.len = len;52 self.len = len;
53 }53 }
5454
55 fn toB64(self: Self, buf: []u8) ![]const u8 {55 fn toB64(self: *const Self, buf: []u8) ![]const u8 {
56 const value = self.constSlice();56 const value = self.constSlice();
57 const len = B64Encoder.calcSize(value.len);57 const len = B64Encoder.calcSize(value.len);
58 if (len > buf.len) return Error.NoSpaceLeft;58 if (len > buf.len) return Error.NoSpaceLeft;
...@@ -260,7 +260,6 @@ fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } {...@@ -260,7 +260,6 @@ fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } {
260}260}
261261
262test "phc format - encoding/decoding" {262test "phc format - encoding/decoding" {
263 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
264 const Input = struct {263 const Input = struct {
265 str: []const u8,264 str: []const u8,
266 HashResult: type,265 HashResult: type,
lib/std/crypto/scrypt.zig+2-3
...@@ -248,7 +248,7 @@ const crypt_format = struct {...@@ -248,7 +248,7 @@ const crypt_format = struct {
248 }248 }
249249
250 /// Return the slice containing the actual value.250 /// Return the slice containing the actual value.
251 pub fn constSlice(self: Self) []const u8 {251 pub fn constSlice(self: *const Self) []const u8 {
252 return self.buf[0..self.len];252 return self.buf[0..self.len];
253 }253 }
254254
...@@ -259,7 +259,7 @@ const crypt_format = struct {...@@ -259,7 +259,7 @@ const crypt_format = struct {
259 self.len = len;259 self.len = len;
260 }260 }
261261
262 fn toB64(self: Self, buf: []u8) ![]const u8 {262 fn toB64(self: *const Self, buf: []u8) ![]const u8 {
263 const value = self.constSlice();263 const value = self.constSlice();
264 const len = Codec.encodedLen(value.len);264 const len = Codec.encodedLen(value.len);
265 if (len > buf.len) return EncodingError.NoSpaceLeft;265 if (len > buf.len) return EncodingError.NoSpaceLeft;
...@@ -683,7 +683,6 @@ test "unix-scrypt" {...@@ -683,7 +683,6 @@ test "unix-scrypt" {
683}683}
684684
685test "crypt format" {685test "crypt format" {
686 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
687 const str = "$7$C6..../....SodiumChloride$kBGj9fHznVYFQMEn/qDCfrDevf9YDtcDdKvEqHJLV8D";686 const str = "$7$C6..../....SodiumChloride$kBGj9fHznVYFQMEn/qDCfrDevf9YDtcDdKvEqHJLV8D";
688 const params = try crypt_format.deserialize(crypt_format.HashResult(32), str);687 const params = try crypt_format.deserialize(crypt_format.HashResult(32), str);
689 var buf: [str.len]u8 = undefined;688 var buf: [str.len]u8 = undefined;
lib/std/fmt.zig+3-3
...@@ -2117,18 +2117,18 @@ test "escape non-printable" {...@@ -2117,18 +2117,18 @@ test "escape non-printable" {
2117}2117}
21182118
2119test "pointer" {2119test "pointer" {
2120 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
2120 {2121 {
2121 const value = @intToPtr(*align(1) i32, 0xdeadbeef);2122 const value = @intToPtr(*align(1) i32, 0xdeadbeef);
2122 try expectFmt("pointer: i32@deadbeef\n", "pointer: {}\n", .{value});2123 try expectFmt("pointer: i32@deadbeef\n", "pointer: {}\n", .{value});
2123 try expectFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value});2124 try expectFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value});
2124 }2125 }
2125 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
2126 {2126 {
2127 const value = @intToPtr(fn () void, 0xdeadbeef);2127 const value = @intToPtr(*const fn () void, 0xdeadbeef);
2128 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});2128 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
2129 }2129 }
2130 {2130 {
2131 const value = @intToPtr(fn () void, 0xdeadbeef);2131 const value = @intToPtr(*const fn () void, 0xdeadbeef);
2132 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});2132 try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
2133 }2133 }
2134}2134}
lib/std/mem.zig-1
...@@ -2080,7 +2080,6 @@ fn testReadIntImpl() !void {...@@ -2080,7 +2080,6 @@ fn testReadIntImpl() !void {
2080}2080}
20812081
2082test "writeIntSlice" {2082test "writeIntSlice" {
2083 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
2084 try testWriteIntImpl();2083 try testWriteIntImpl();
2085 comptime try testWriteIntImpl();2084 comptime try testWriteIntImpl();
2086}2085}
src/codegen/c.zig-3
...@@ -225,9 +225,6 @@ fn formatIdent(...@@ -225,9 +225,6 @@ fn formatIdent(
225}225}
226226
227pub fn fmtIdent(ident: []const u8) std.fmt.Formatter(formatIdent) {227pub fn fmtIdent(ident: []const u8) std.fmt.Formatter(formatIdent) {
228 if (builtin.zig_backend != .stage1) {
229 @panic("TODO");
230 }
231 return .{ .data = ident };228 return .{ .data = ident };
232}229}
233230
src/value.zig+1
...@@ -2414,6 +2414,7 @@ pub const Value = extern union {...@@ -2414,6 +2414,7 @@ pub const Value = extern union {
2414 return false;2414 return false;
2415 },2415 },
2416 .@"union" => return val.cast(Payload.Union).?.data.val.canMutateComptimeVarState(),2416 .@"union" => return val.cast(Payload.Union).?.data.val.canMutateComptimeVarState(),
2417 .slice => return val.castTag(.slice).?.data.ptr.canMutateComptimeVarState(),
2417 else => return false,2418 else => return false,
2418 }2419 }
2419 }2420 }