authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-05-05 21:29:16+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-05-08 15:15:30+03:00
log42a95197f32b46ee7b504282ab345209cb43c247
tree46e44b0dde19d9aa27c27dacf7ed6a3634d62d29
parent0a38f61d58018ce856ce058efb655ff0199228d2

update usage of std.testing in stage2


13 files changed, 139 insertions(+), 139 deletions(-)

src/Cache.zig+18-18
...@@ -727,7 +727,7 @@ test "cache file and then recall it" {...@@ -727,7 +727,7 @@ test "cache file and then recall it" {
727 _ = try ch.addFile(temp_file, null);727 _ = try ch.addFile(temp_file, null);
728728
729 // There should be nothing in the cache729 // There should be nothing in the cache
730 testing.expectEqual(false, try ch.hit());730 try testing.expectEqual(false, try ch.hit());
731731
732 digest1 = ch.final();732 digest1 = ch.final();
733 try ch.writeManifest();733 try ch.writeManifest();
...@@ -742,13 +742,13 @@ test "cache file and then recall it" {...@@ -742,13 +742,13 @@ test "cache file and then recall it" {
742 _ = try ch.addFile(temp_file, null);742 _ = try ch.addFile(temp_file, null);
743743
744 // Cache hit! We just "built" the same file744 // Cache hit! We just "built" the same file
745 testing.expect(try ch.hit());745 try testing.expect(try ch.hit());
746 digest2 = ch.final();746 digest2 = ch.final();
747747
748 try ch.writeManifest();748 try ch.writeManifest();
749 }749 }
750750
751 testing.expectEqual(digest1, digest2);751 try testing.expectEqual(digest1, digest2);
752 }752 }
753753
754 try cwd.deleteTree(temp_manifest_dir);754 try cwd.deleteTree(temp_manifest_dir);
...@@ -760,11 +760,11 @@ test "give problematic timestamp" {...@@ -760,11 +760,11 @@ test "give problematic timestamp" {
760 // to make it problematic, we make it only accurate to the second760 // to make it problematic, we make it only accurate to the second
761 fs_clock = @divTrunc(fs_clock, std.time.ns_per_s);761 fs_clock = @divTrunc(fs_clock, std.time.ns_per_s);
762 fs_clock *= std.time.ns_per_s;762 fs_clock *= std.time.ns_per_s;
763 testing.expect(isProblematicTimestamp(fs_clock));763 try testing.expect(isProblematicTimestamp(fs_clock));
764}764}
765765
766test "give nonproblematic timestamp" {766test "give nonproblematic timestamp" {
767 testing.expect(!isProblematicTimestamp(std.time.nanoTimestamp() - std.time.ns_per_s));767 try testing.expect(!isProblematicTimestamp(std.time.nanoTimestamp() - std.time.ns_per_s));
768}768}
769769
770test "check that changing a file makes cache fail" {770test "check that changing a file makes cache fail" {
...@@ -807,9 +807,9 @@ test "check that changing a file makes cache fail" {...@@ -807,9 +807,9 @@ test "check that changing a file makes cache fail" {
807 const temp_file_idx = try ch.addFile(temp_file, 100);807 const temp_file_idx = try ch.addFile(temp_file, 100);
808808
809 // There should be nothing in the cache809 // There should be nothing in the cache
810 testing.expectEqual(false, try ch.hit());810 try testing.expectEqual(false, try ch.hit());
811811
812 testing.expect(mem.eql(u8, original_temp_file_contents, ch.files.items[temp_file_idx].contents.?));812 try testing.expect(mem.eql(u8, original_temp_file_contents, ch.files.items[temp_file_idx].contents.?));
813813
814 digest1 = ch.final();814 digest1 = ch.final();
815815
...@@ -826,17 +826,17 @@ test "check that changing a file makes cache fail" {...@@ -826,17 +826,17 @@ test "check that changing a file makes cache fail" {
826 const temp_file_idx = try ch.addFile(temp_file, 100);826 const temp_file_idx = try ch.addFile(temp_file, 100);
827827
828 // A file that we depend on has been updated, so the cache should not contain an entry for it828 // A file that we depend on has been updated, so the cache should not contain an entry for it
829 testing.expectEqual(false, try ch.hit());829 try testing.expectEqual(false, try ch.hit());
830830
831 // The cache system does not keep the contents of re-hashed input files.831 // The cache system does not keep the contents of re-hashed input files.
832 testing.expect(ch.files.items[temp_file_idx].contents == null);832 try testing.expect(ch.files.items[temp_file_idx].contents == null);
833833
834 digest2 = ch.final();834 digest2 = ch.final();
835835
836 try ch.writeManifest();836 try ch.writeManifest();
837 }837 }
838838
839 testing.expect(!mem.eql(u8, digest1[0..], digest2[0..]));839 try testing.expect(!mem.eql(u8, digest1[0..], digest2[0..]));
840 }840 }
841841
842 try cwd.deleteTree(temp_manifest_dir);842 try cwd.deleteTree(temp_manifest_dir);
...@@ -868,7 +868,7 @@ test "no file inputs" {...@@ -868,7 +868,7 @@ test "no file inputs" {
868 ch.hash.addBytes("1234");868 ch.hash.addBytes("1234");
869869
870 // There should be nothing in the cache870 // There should be nothing in the cache
871 testing.expectEqual(false, try ch.hit());871 try testing.expectEqual(false, try ch.hit());
872872
873 digest1 = ch.final();873 digest1 = ch.final();
874874
...@@ -880,12 +880,12 @@ test "no file inputs" {...@@ -880,12 +880,12 @@ test "no file inputs" {
880880
881 ch.hash.addBytes("1234");881 ch.hash.addBytes("1234");
882882
883 testing.expect(try ch.hit());883 try testing.expect(try ch.hit());
884 digest2 = ch.final();884 digest2 = ch.final();
885 try ch.writeManifest();885 try ch.writeManifest();
886 }886 }
887887
888 testing.expectEqual(digest1, digest2);888 try testing.expectEqual(digest1, digest2);
889}889}
890890
891test "Manifest with files added after initial hash work" {891test "Manifest with files added after initial hash work" {
...@@ -926,7 +926,7 @@ test "Manifest with files added after initial hash work" {...@@ -926,7 +926,7 @@ test "Manifest with files added after initial hash work" {
926 _ = try ch.addFile(temp_file1, null);926 _ = try ch.addFile(temp_file1, null);
927927
928 // There should be nothing in the cache928 // There should be nothing in the cache
929 testing.expectEqual(false, try ch.hit());929 try testing.expectEqual(false, try ch.hit());
930930
931 _ = try ch.addFilePost(temp_file2);931 _ = try ch.addFilePost(temp_file2);
932932
...@@ -940,12 +940,12 @@ test "Manifest with files added after initial hash work" {...@@ -940,12 +940,12 @@ test "Manifest with files added after initial hash work" {
940 ch.hash.addBytes("1234");940 ch.hash.addBytes("1234");
941 _ = try ch.addFile(temp_file1, null);941 _ = try ch.addFile(temp_file1, null);
942942
943 testing.expect(try ch.hit());943 try testing.expect(try ch.hit());
944 digest2 = ch.final();944 digest2 = ch.final();
945945
946 try ch.writeManifest();946 try ch.writeManifest();
947 }947 }
948 testing.expect(mem.eql(u8, &digest1, &digest2));948 try testing.expect(mem.eql(u8, &digest1, &digest2));
949949
950 // Modify the file added after initial hash950 // Modify the file added after initial hash
951 const ts2 = std.time.nanoTimestamp();951 const ts2 = std.time.nanoTimestamp();
...@@ -963,7 +963,7 @@ test "Manifest with files added after initial hash work" {...@@ -963,7 +963,7 @@ test "Manifest with files added after initial hash work" {
963 _ = try ch.addFile(temp_file1, null);963 _ = try ch.addFile(temp_file1, null);
964964
965 // A file that we depend on has been updated, so the cache should not contain an entry for it965 // A file that we depend on has been updated, so the cache should not contain an entry for it
966 testing.expectEqual(false, try ch.hit());966 try testing.expectEqual(false, try ch.hit());
967967
968 _ = try ch.addFilePost(temp_file2);968 _ = try ch.addFilePost(temp_file2);
969969
...@@ -972,7 +972,7 @@ test "Manifest with files added after initial hash work" {...@@ -972,7 +972,7 @@ test "Manifest with files added after initial hash work" {
972 try ch.writeManifest();972 try ch.writeManifest();
973 }973 }
974974
975 testing.expect(!mem.eql(u8, &digest1, &digest3));975 try testing.expect(!mem.eql(u8, &digest1, &digest3));
976 }976 }
977977
978 try cwd.deleteTree(temp_manifest_dir);978 try cwd.deleteTree(temp_manifest_dir);
src/Compilation.zig+8-8
...@@ -2852,14 +2852,14 @@ pub fn classifyFileExt(filename: []const u8) FileExt {...@@ -2852,14 +2852,14 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
2852}2852}
28532853
2854test "classifyFileExt" {2854test "classifyFileExt" {
2855 std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));2855 try std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
2856 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));2856 try std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
2857 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));2857 try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
2858 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));2858 try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
2859 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));2859 try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
2860 std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));2860 try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
2861 std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));2861 try std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
2862 std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));2862 try std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
2863}2863}
28642864
2865fn haveFramePointer(comp: *const Compilation) bool {2865fn haveFramePointer(comp: *const Compilation) bool {
src/DepTokenizer.zig+2-2
...@@ -918,7 +918,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {...@@ -918,7 +918,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
918 }918 }
919919
920 if (std.mem.eql(u8, expect, buffer.items)) {920 if (std.mem.eql(u8, expect, buffer.items)) {
921 testing.expect(true);921 try testing.expect(true);
922 return;922 return;
923 }923 }
924924
...@@ -930,7 +930,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {...@@ -930,7 +930,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
930 try printSection(out, ">>>> got", buffer.items);930 try printSection(out, ">>>> got", buffer.items);
931 try printRuler(out);931 try printRuler(out);
932932
933 testing.expect(false);933 try testing.expect(false);
934}934}
935935
936fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {936fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {
src/codegen/aarch64.zig+34-34
...@@ -67,27 +67,27 @@ pub const c_abi_int_param_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6,...@@ -67,27 +67,27 @@ pub const c_abi_int_param_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6,
67pub const c_abi_int_return_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6, .x7 };67pub const c_abi_int_return_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6, .x7 };
6868
69test "Register.id" {69test "Register.id" {
70 testing.expectEqual(@as(u5, 0), Register.x0.id());70 try testing.expectEqual(@as(u5, 0), Register.x0.id());
71 testing.expectEqual(@as(u5, 0), Register.w0.id());71 try testing.expectEqual(@as(u5, 0), Register.w0.id());
7272
73 testing.expectEqual(@as(u5, 31), Register.xzr.id());73 try testing.expectEqual(@as(u5, 31), Register.xzr.id());
74 testing.expectEqual(@as(u5, 31), Register.wzr.id());74 try testing.expectEqual(@as(u5, 31), Register.wzr.id());
7575
76 testing.expectEqual(@as(u5, 31), Register.sp.id());76 try testing.expectEqual(@as(u5, 31), Register.sp.id());
77 testing.expectEqual(@as(u5, 31), Register.sp.id());77 try testing.expectEqual(@as(u5, 31), Register.sp.id());
78}78}
7979
80test "Register.size" {80test "Register.size" {
81 testing.expectEqual(@as(u7, 64), Register.x19.size());81 try testing.expectEqual(@as(u7, 64), Register.x19.size());
82 testing.expectEqual(@as(u7, 32), Register.w3.size());82 try testing.expectEqual(@as(u7, 32), Register.w3.size());
83}83}
8484
85test "Register.to64/to32" {85test "Register.to64/to32" {
86 testing.expectEqual(Register.x0, Register.w0.to64());86 try testing.expectEqual(Register.x0, Register.w0.to64());
87 testing.expectEqual(Register.x0, Register.x0.to64());87 try testing.expectEqual(Register.x0, Register.x0.to64());
8888
89 testing.expectEqual(Register.w3, Register.w3.to32());89 try testing.expectEqual(Register.w3, Register.w3.to32());
90 testing.expectEqual(Register.w3, Register.x3.to32());90 try testing.expectEqual(Register.w3, Register.x3.to32());
91}91}
9292
93// zig fmt: off93// zig fmt: off
...@@ -169,33 +169,33 @@ pub const FloatingPointRegister = enum(u8) {...@@ -169,33 +169,33 @@ pub const FloatingPointRegister = enum(u8) {
169// zig fmt: on169// zig fmt: on
170170
171test "FloatingPointRegister.id" {171test "FloatingPointRegister.id" {
172 testing.expectEqual(@as(u5, 0), FloatingPointRegister.b0.id());172 try testing.expectEqual(@as(u5, 0), FloatingPointRegister.b0.id());
173 testing.expectEqual(@as(u5, 0), FloatingPointRegister.h0.id());173 try testing.expectEqual(@as(u5, 0), FloatingPointRegister.h0.id());
174 testing.expectEqual(@as(u5, 0), FloatingPointRegister.s0.id());174 try testing.expectEqual(@as(u5, 0), FloatingPointRegister.s0.id());
175 testing.expectEqual(@as(u5, 0), FloatingPointRegister.d0.id());175 try testing.expectEqual(@as(u5, 0), FloatingPointRegister.d0.id());
176 testing.expectEqual(@as(u5, 0), FloatingPointRegister.q0.id());176 try testing.expectEqual(@as(u5, 0), FloatingPointRegister.q0.id());
177177
178 testing.expectEqual(@as(u5, 2), FloatingPointRegister.q2.id());178 try testing.expectEqual(@as(u5, 2), FloatingPointRegister.q2.id());
179 testing.expectEqual(@as(u5, 31), FloatingPointRegister.d31.id());179 try testing.expectEqual(@as(u5, 31), FloatingPointRegister.d31.id());
180}180}
181181
182test "FloatingPointRegister.size" {182test "FloatingPointRegister.size" {
183 testing.expectEqual(@as(u8, 128), FloatingPointRegister.q1.size());183 try testing.expectEqual(@as(u8, 128), FloatingPointRegister.q1.size());
184 testing.expectEqual(@as(u8, 64), FloatingPointRegister.d2.size());184 try testing.expectEqual(@as(u8, 64), FloatingPointRegister.d2.size());
185 testing.expectEqual(@as(u8, 32), FloatingPointRegister.s3.size());185 try testing.expectEqual(@as(u8, 32), FloatingPointRegister.s3.size());
186 testing.expectEqual(@as(u8, 16), FloatingPointRegister.h4.size());186 try testing.expectEqual(@as(u8, 16), FloatingPointRegister.h4.size());
187 testing.expectEqual(@as(u8, 8), FloatingPointRegister.b5.size());187 try testing.expectEqual(@as(u8, 8), FloatingPointRegister.b5.size());
188}188}
189189
190test "FloatingPointRegister.toX" {190test "FloatingPointRegister.toX" {
191 testing.expectEqual(FloatingPointRegister.q1, FloatingPointRegister.q1.to128());191 try testing.expectEqual(FloatingPointRegister.q1, FloatingPointRegister.q1.to128());
192 testing.expectEqual(FloatingPointRegister.q2, FloatingPointRegister.b2.to128());192 try testing.expectEqual(FloatingPointRegister.q2, FloatingPointRegister.b2.to128());
193 testing.expectEqual(FloatingPointRegister.q3, FloatingPointRegister.h3.to128());193 try testing.expectEqual(FloatingPointRegister.q3, FloatingPointRegister.h3.to128());
194194
195 testing.expectEqual(FloatingPointRegister.d0, FloatingPointRegister.q0.to64());195 try testing.expectEqual(FloatingPointRegister.d0, FloatingPointRegister.q0.to64());
196 testing.expectEqual(FloatingPointRegister.s1, FloatingPointRegister.d1.to32());196 try testing.expectEqual(FloatingPointRegister.s1, FloatingPointRegister.d1.to32());
197 testing.expectEqual(FloatingPointRegister.h2, FloatingPointRegister.s2.to16());197 try testing.expectEqual(FloatingPointRegister.h2, FloatingPointRegister.s2.to16());
198 testing.expectEqual(FloatingPointRegister.b3, FloatingPointRegister.h3.to8());198 try testing.expectEqual(FloatingPointRegister.b3, FloatingPointRegister.h3.to8());
199}199}
200200
201/// Represents an instruction in the AArch64 instruction set201/// Represents an instruction in the AArch64 instruction set
...@@ -1225,6 +1225,6 @@ test "serialize instructions" {...@@ -1225,6 +1225,6 @@ test "serialize instructions" {
12251225
1226 for (testcases) |case| {1226 for (testcases) |case| {
1227 const actual = case.inst.toU32();1227 const actual = case.inst.toU32();
1228 testing.expectEqual(case.expected, actual);1228 try testing.expectEqual(case.expected, actual);
1229 }1229 }
1230}1230}
src/codegen/arm.zig+12-12
...@@ -88,19 +88,19 @@ pub const Condition = enum(u4) {...@@ -88,19 +88,19 @@ pub const Condition = enum(u4) {
88};88};
8989
90test "condition from CompareOperator" {90test "condition from CompareOperator" {
91 testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorSigned(.eq));91 try testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorSigned(.eq));
92 testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorUnsigned(.eq));92 try testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorUnsigned(.eq));
9393
94 testing.expectEqual(@as(Condition, .gt), Condition.fromCompareOperatorSigned(.gt));94 try testing.expectEqual(@as(Condition, .gt), Condition.fromCompareOperatorSigned(.gt));
95 testing.expectEqual(@as(Condition, .hi), Condition.fromCompareOperatorUnsigned(.gt));95 try testing.expectEqual(@as(Condition, .hi), Condition.fromCompareOperatorUnsigned(.gt));
9696
97 testing.expectEqual(@as(Condition, .le), Condition.fromCompareOperatorSigned(.lte));97 try testing.expectEqual(@as(Condition, .le), Condition.fromCompareOperatorSigned(.lte));
98 testing.expectEqual(@as(Condition, .ls), Condition.fromCompareOperatorUnsigned(.lte));98 try testing.expectEqual(@as(Condition, .ls), Condition.fromCompareOperatorUnsigned(.lte));
99}99}
100100
101test "negate condition" {101test "negate condition" {
102 testing.expectEqual(@as(Condition, .eq), Condition.ne.negate());102 try testing.expectEqual(@as(Condition, .eq), Condition.ne.negate());
103 testing.expectEqual(@as(Condition, .ne), Condition.eq.negate());103 try testing.expectEqual(@as(Condition, .ne), Condition.eq.negate());
104}104}
105105
106/// Represents a register in the ARM instruction set architecture106/// Represents a register in the ARM instruction set architecture
...@@ -175,8 +175,8 @@ pub const Register = enum(u5) {...@@ -175,8 +175,8 @@ pub const Register = enum(u5) {
175};175};
176176
177test "Register.id" {177test "Register.id" {
178 testing.expectEqual(@as(u4, 15), Register.r15.id());178 try testing.expectEqual(@as(u4, 15), Register.r15.id());
179 testing.expectEqual(@as(u4, 15), Register.pc.id());179 try testing.expectEqual(@as(u4, 15), Register.pc.id());
180}180}
181181
182/// Program status registers containing flags, mode bits and other182/// Program status registers containing flags, mode bits and other
...@@ -1225,7 +1225,7 @@ test "serialize instructions" {...@@ -1225,7 +1225,7 @@ test "serialize instructions" {
12251225
1226 for (testcases) |case| {1226 for (testcases) |case| {
1227 const actual = case.inst.toU32();1227 const actual = case.inst.toU32();
1228 testing.expectEqual(case.expected, actual);1228 try testing.expectEqual(case.expected, actual);
1229 }1229 }
1230}1230}
12311231
...@@ -1265,6 +1265,6 @@ test "aliases" {...@@ -1265,6 +1265,6 @@ test "aliases" {
1265 };1265 };
12661266
1267 for (testcases) |case| {1267 for (testcases) |case| {
1268 testing.expectEqual(case.expected.toU32(), case.actual.toU32());1268 try testing.expectEqual(case.expected.toU32(), case.actual.toU32());
1269 }1269 }
1270}1270}
src/codegen/riscv64.zig+1-1
...@@ -465,6 +465,6 @@ test "serialize instructions" {...@@ -465,6 +465,6 @@ test "serialize instructions" {
465465
466 for (testcases) |case| {466 for (testcases) |case| {
467 const actual = case.inst.toU32();467 const actual = case.inst.toU32();
468 testing.expectEqual(case.expected, actual);468 try testing.expectEqual(case.expected, actual);
469 }469 }
470}470}
src/codegen/wasm.zig+5-5
...@@ -463,11 +463,11 @@ test "Wasm - buildOpcode" {...@@ -463,11 +463,11 @@ test "Wasm - buildOpcode" {
463 const i64_extend32_s = buildOpcode(.{ .op = .extend, .valtype1 = .i64, .width = 32, .signedness = .signed });463 const i64_extend32_s = buildOpcode(.{ .op = .extend, .valtype1 = .i64, .width = 32, .signedness = .signed });
464 const f64_reinterpret_i64 = buildOpcode(.{ .op = .reinterpret, .valtype1 = .f64, .valtype2 = .i64 });464 const f64_reinterpret_i64 = buildOpcode(.{ .op = .reinterpret, .valtype1 = .f64, .valtype2 = .i64 });
465465
466 testing.expectEqual(@as(wasm.Opcode, .i32_const), i32_const);466 try testing.expectEqual(@as(wasm.Opcode, .i32_const), i32_const);
467 testing.expectEqual(@as(wasm.Opcode, .end), end);467 try testing.expectEqual(@as(wasm.Opcode, .end), end);
468 testing.expectEqual(@as(wasm.Opcode, .local_get), local_get);468 try testing.expectEqual(@as(wasm.Opcode, .local_get), local_get);
469 testing.expectEqual(@as(wasm.Opcode, .i64_extend32_s), i64_extend32_s);469 try testing.expectEqual(@as(wasm.Opcode, .i64_extend32_s), i64_extend32_s);
470 testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64);470 try testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64);
471}471}
472472
473pub const Result = union(enum) {473pub const Result = union(enum) {
src/link/MachO/CodeSignature.zig+1-1
...@@ -182,7 +182,7 @@ test "CodeSignature header" {...@@ -182,7 +182,7 @@ test "CodeSignature header" {
182 try code_sig.writeHeader(stream.writer());182 try code_sig.writeHeader(stream.writer());
183183
184 const expected = &[_]u8{ 0xfa, 0xde, 0x0c, 0xc0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0 };184 const expected = &[_]u8{ 0xfa, 0xde, 0x0c, 0xc0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0 };
185 testing.expect(mem.eql(u8, expected, &buffer));185 try testing.expect(mem.eql(u8, expected, &buffer));
186}186}
187187
188pub fn calcCodeSignaturePaddingSize(id: []const u8, file_size: u64, page_size: u16) u32 {188pub fn calcCodeSignaturePaddingSize(id: []const u8, file_size: u64, page_size: u16) u32 {
src/link/MachO/Trie.zig+26-26
...@@ -404,15 +404,15 @@ test "Trie node count" {...@@ -404,15 +404,15 @@ test "Trie node count" {
404 var trie = Trie.init(gpa);404 var trie = Trie.init(gpa);
405 defer trie.deinit();405 defer trie.deinit();
406406
407 testing.expectEqual(trie.node_count, 0);407 try testing.expectEqual(trie.node_count, 0);
408 testing.expect(trie.root == null);408 try testing.expect(trie.root == null);
409409
410 try trie.put(.{410 try trie.put(.{
411 .name = "_main",411 .name = "_main",
412 .vmaddr_offset = 0,412 .vmaddr_offset = 0,
413 .export_flags = 0,413 .export_flags = 0,
414 });414 });
415 testing.expectEqual(trie.node_count, 2);415 try testing.expectEqual(trie.node_count, 2);
416416
417 // Inserting the same node shouldn't update the trie.417 // Inserting the same node shouldn't update the trie.
418 try trie.put(.{418 try trie.put(.{
...@@ -420,14 +420,14 @@ test "Trie node count" {...@@ -420,14 +420,14 @@ test "Trie node count" {
420 .vmaddr_offset = 0,420 .vmaddr_offset = 0,
421 .export_flags = 0,421 .export_flags = 0,
422 });422 });
423 testing.expectEqual(trie.node_count, 2);423 try testing.expectEqual(trie.node_count, 2);
424424
425 try trie.put(.{425 try trie.put(.{
426 .name = "__mh_execute_header",426 .name = "__mh_execute_header",
427 .vmaddr_offset = 0x1000,427 .vmaddr_offset = 0x1000,
428 .export_flags = 0,428 .export_flags = 0,
429 });429 });
430 testing.expectEqual(trie.node_count, 4);430 try testing.expectEqual(trie.node_count, 4);
431431
432 // Inserting the same node shouldn't update the trie.432 // Inserting the same node shouldn't update the trie.
433 try trie.put(.{433 try trie.put(.{
...@@ -435,13 +435,13 @@ test "Trie node count" {...@@ -435,13 +435,13 @@ test "Trie node count" {
435 .vmaddr_offset = 0x1000,435 .vmaddr_offset = 0x1000,
436 .export_flags = 0,436 .export_flags = 0,
437 });437 });
438 testing.expectEqual(trie.node_count, 4);438 try testing.expectEqual(trie.node_count, 4);
439 try trie.put(.{439 try trie.put(.{
440 .name = "_main",440 .name = "_main",
441 .vmaddr_offset = 0,441 .vmaddr_offset = 0,
442 .export_flags = 0,442 .export_flags = 0,
443 });443 });
444 testing.expectEqual(trie.node_count, 4);444 try testing.expectEqual(trie.node_count, 4);
445}445}
446446
447test "Trie basic" {447test "Trie basic" {
...@@ -455,8 +455,8 @@ test "Trie basic" {...@@ -455,8 +455,8 @@ test "Trie basic" {
455 .vmaddr_offset = 0,455 .vmaddr_offset = 0,
456 .export_flags = 0,456 .export_flags = 0,
457 });457 });
458 testing.expect(trie.root.?.edges.items.len == 1);458 try testing.expect(trie.root.?.edges.items.len == 1);
459 testing.expect(mem.eql(u8, trie.root.?.edges.items[0].label, "_st"));459 try testing.expect(mem.eql(u8, trie.root.?.edges.items[0].label, "_st"));
460460
461 {461 {
462 // root --- _st ---> node --- art ---> node462 // root --- _st ---> node --- art ---> node
...@@ -465,12 +465,12 @@ test "Trie basic" {...@@ -465,12 +465,12 @@ test "Trie basic" {
465 .vmaddr_offset = 0,465 .vmaddr_offset = 0,
466 .export_flags = 0,466 .export_flags = 0,
467 });467 });
468 testing.expect(trie.root.?.edges.items.len == 1);468 try testing.expect(trie.root.?.edges.items.len == 1);
469469
470 const nextEdge = &trie.root.?.edges.items[0];470 const nextEdge = &trie.root.?.edges.items[0];
471 testing.expect(mem.eql(u8, nextEdge.label, "_st"));471 try testing.expect(mem.eql(u8, nextEdge.label, "_st"));
472 testing.expect(nextEdge.to.edges.items.len == 1);472 try testing.expect(nextEdge.to.edges.items.len == 1);
473 testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "art"));473 try testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "art"));
474 }474 }
475 {475 {
476 // root --- _ ---> node --- st ---> node --- art ---> node476 // root --- _ ---> node --- st ---> node --- art ---> node
...@@ -481,16 +481,16 @@ test "Trie basic" {...@@ -481,16 +481,16 @@ test "Trie basic" {
481 .vmaddr_offset = 0,481 .vmaddr_offset = 0,
482 .export_flags = 0,482 .export_flags = 0,
483 });483 });
484 testing.expect(trie.root.?.edges.items.len == 1);484 try testing.expect(trie.root.?.edges.items.len == 1);
485485
486 const nextEdge = &trie.root.?.edges.items[0];486 const nextEdge = &trie.root.?.edges.items[0];
487 testing.expect(mem.eql(u8, nextEdge.label, "_"));487 try testing.expect(mem.eql(u8, nextEdge.label, "_"));
488 testing.expect(nextEdge.to.edges.items.len == 2);488 try testing.expect(nextEdge.to.edges.items.len == 2);
489 testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "st"));489 try testing.expect(mem.eql(u8, nextEdge.to.edges.items[0].label, "st"));
490 testing.expect(mem.eql(u8, nextEdge.to.edges.items[1].label, "main"));490 try testing.expect(mem.eql(u8, nextEdge.to.edges.items[1].label, "main"));
491491
492 const nextNextEdge = &nextEdge.to.edges.items[0];492 const nextNextEdge = &nextEdge.to.edges.items[0];
493 testing.expect(mem.eql(u8, nextNextEdge.to.edges.items[0].label, "art"));493 try testing.expect(mem.eql(u8, nextNextEdge.to.edges.items[0].label, "art"));
494 }494 }
495}495}
496496
...@@ -529,15 +529,15 @@ test "write Trie to a byte stream" {...@@ -529,15 +529,15 @@ test "write Trie to a byte stream" {
529 var stream = std.io.fixedBufferStream(buffer);529 var stream = std.io.fixedBufferStream(buffer);
530 {530 {
531 const nwritten = try trie.write(stream.writer());531 const nwritten = try trie.write(stream.writer());
532 testing.expect(nwritten == trie.size);532 try testing.expect(nwritten == trie.size);
533 testing.expect(mem.eql(u8, buffer, &exp_buffer));533 try testing.expect(mem.eql(u8, buffer, &exp_buffer));
534 }534 }
535 {535 {
536 // Writing finalized trie again should yield the same result.536 // Writing finalized trie again should yield the same result.
537 try stream.seekTo(0);537 try stream.seekTo(0);
538 const nwritten = try trie.write(stream.writer());538 const nwritten = try trie.write(stream.writer());
539 testing.expect(nwritten == trie.size);539 try testing.expect(nwritten == trie.size);
540 testing.expect(mem.eql(u8, buffer, &exp_buffer));540 try testing.expect(mem.eql(u8, buffer, &exp_buffer));
541 }541 }
542}542}
543543
...@@ -560,7 +560,7 @@ test "parse Trie from byte stream" {...@@ -560,7 +560,7 @@ test "parse Trie from byte stream" {
560 defer trie.deinit();560 defer trie.deinit();
561 const nread = try trie.read(in_stream.reader());561 const nread = try trie.read(in_stream.reader());
562562
563 testing.expect(nread == in_buffer.len);563 try testing.expect(nread == in_buffer.len);
564564
565 try trie.finalize();565 try trie.finalize();
566566
...@@ -569,6 +569,6 @@ test "parse Trie from byte stream" {...@@ -569,6 +569,6 @@ test "parse Trie from byte stream" {
569 var out_stream = std.io.fixedBufferStream(out_buffer);569 var out_stream = std.io.fixedBufferStream(out_buffer);
570 const nwritten = try trie.write(out_stream.writer());570 const nwritten = try trie.write(out_stream.writer());
571571
572 testing.expect(nwritten == trie.size);572 try testing.expect(nwritten == trie.size);
573 testing.expect(mem.eql(u8, &in_buffer, out_buffer));573 try testing.expect(mem.eql(u8, &in_buffer, out_buffer));
574}574}
src/link/MachO/commands.zig+2-2
...@@ -286,13 +286,13 @@ fn testRead(allocator: *Allocator, buffer: []const u8, expected: anytype) !void...@@ -286,13 +286,13 @@ fn testRead(allocator: *Allocator, buffer: []const u8, expected: anytype) !void
286 var stream = io.fixedBufferStream(buffer);286 var stream = io.fixedBufferStream(buffer);
287 var given = try LoadCommand.read(allocator, stream.reader());287 var given = try LoadCommand.read(allocator, stream.reader());
288 defer given.deinit(allocator);288 defer given.deinit(allocator);
289 testing.expect(expected.eql(given));289 try testing.expect(expected.eql(given));
290}290}
291291
292fn testWrite(buffer: []u8, cmd: LoadCommand, expected: []const u8) !void {292fn testWrite(buffer: []u8, cmd: LoadCommand, expected: []const u8) !void {
293 var stream = io.fixedBufferStream(buffer);293 var stream = io.fixedBufferStream(buffer);
294 try cmd.write(stream.writer());294 try cmd.write(stream.writer());
295 testing.expect(mem.eql(u8, expected, buffer[0..expected.len]));295 try testing.expect(mem.eql(u8, expected, buffer[0..expected.len]));
296}296}
297297
298test "read-write segment command" {298test "read-write segment command" {
src/register_manager.zig+24-24
...@@ -267,21 +267,21 @@ test "tryAllocReg: no spilling" {...@@ -267,21 +267,21 @@ test "tryAllocReg: no spilling" {
267 .src = .unneeded,267 .src = .unneeded,
268 };268 };
269269
270 std.testing.expect(!function.register_manager.isRegAllocated(.r2));270 try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
271 std.testing.expect(!function.register_manager.isRegAllocated(.r3));271 try std.testing.expect(!function.register_manager.isRegAllocated(.r3));
272272
273 std.testing.expectEqual(@as(?MockRegister, .r2), function.register_manager.tryAllocReg(&mock_instruction));273 try std.testing.expectEqual(@as(?MockRegister, .r2), function.register_manager.tryAllocReg(&mock_instruction));
274 std.testing.expectEqual(@as(?MockRegister, .r3), function.register_manager.tryAllocReg(&mock_instruction));274 try std.testing.expectEqual(@as(?MockRegister, .r3), function.register_manager.tryAllocReg(&mock_instruction));
275 std.testing.expectEqual(@as(?MockRegister, null), function.register_manager.tryAllocReg(&mock_instruction));275 try std.testing.expectEqual(@as(?MockRegister, null), function.register_manager.tryAllocReg(&mock_instruction));
276276
277 std.testing.expect(function.register_manager.isRegAllocated(.r2));277 try std.testing.expect(function.register_manager.isRegAllocated(.r2));
278 std.testing.expect(function.register_manager.isRegAllocated(.r3));278 try std.testing.expect(function.register_manager.isRegAllocated(.r3));
279279
280 function.register_manager.freeReg(.r2);280 function.register_manager.freeReg(.r2);
281 function.register_manager.freeReg(.r3);281 function.register_manager.freeReg(.r3);
282282
283 std.testing.expect(function.register_manager.isRegAllocated(.r2));283 try std.testing.expect(function.register_manager.isRegAllocated(.r2));
284 std.testing.expect(function.register_manager.isRegAllocated(.r3));284 try std.testing.expect(function.register_manager.isRegAllocated(.r3));
285}285}
286286
287test "allocReg: spilling" {287test "allocReg: spilling" {
...@@ -298,20 +298,20 @@ test "allocReg: spilling" {...@@ -298,20 +298,20 @@ test "allocReg: spilling" {
298 .src = .unneeded,298 .src = .unneeded,
299 };299 };
300300
301 std.testing.expect(!function.register_manager.isRegAllocated(.r2));301 try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
302 std.testing.expect(!function.register_manager.isRegAllocated(.r3));302 try std.testing.expect(!function.register_manager.isRegAllocated(.r3));
303303
304 std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));304 try std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));
305 std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));305 try std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));
306306
307 // Spill a register307 // Spill a register
308 std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));308 try std.testing.expectEqual(@as(?MockRegister, .r2), try function.register_manager.allocReg(&mock_instruction));
309 std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);309 try std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);
310310
311 // No spilling necessary311 // No spilling necessary
312 function.register_manager.freeReg(.r3);312 function.register_manager.freeReg(.r3);
313 std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));313 try std.testing.expectEqual(@as(?MockRegister, .r3), try function.register_manager.allocReg(&mock_instruction));
314 std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);314 try std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r2}, function.spilled.items);
315}315}
316316
317test "getReg" {317test "getReg" {
...@@ -328,18 +328,18 @@ test "getReg" {...@@ -328,18 +328,18 @@ test "getReg" {
328 .src = .unneeded,328 .src = .unneeded,
329 };329 };
330330
331 std.testing.expect(!function.register_manager.isRegAllocated(.r2));331 try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
332 std.testing.expect(!function.register_manager.isRegAllocated(.r3));332 try std.testing.expect(!function.register_manager.isRegAllocated(.r3));
333333
334 try function.register_manager.getReg(.r3, &mock_instruction);334 try function.register_manager.getReg(.r3, &mock_instruction);
335335
336 std.testing.expect(!function.register_manager.isRegAllocated(.r2));336 try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
337 std.testing.expect(function.register_manager.isRegAllocated(.r3));337 try std.testing.expect(function.register_manager.isRegAllocated(.r3));
338338
339 // Spill r3339 // Spill r3
340 try function.register_manager.getReg(.r3, &mock_instruction);340 try function.register_manager.getReg(.r3, &mock_instruction);
341341
342 std.testing.expect(!function.register_manager.isRegAllocated(.r2));342 try std.testing.expect(!function.register_manager.isRegAllocated(.r2));
343 std.testing.expect(function.register_manager.isRegAllocated(.r3));343 try std.testing.expect(function.register_manager.isRegAllocated(.r3));
344 std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r3}, function.spilled.items);344 try std.testing.expectEqualSlices(MockRegister, &[_]MockRegister{.r3}, function.spilled.items);
345}345}
src/test.zig+3-3
...@@ -705,14 +705,14 @@ pub const TestContext = struct {...@@ -705,14 +705,14 @@ pub const TestContext = struct {
705 defer file.close();705 defer file.close();
706 const out = try file.reader().readAllAlloc(arena, 5 * 1024 * 1024);706 const out = try file.reader().readAllAlloc(arena, 5 * 1024 * 1024);
707707
708 std.testing.expectEqualStrings(expected_output, out);708 try std.testing.expectEqualStrings(expected_output, out);
709 },709 },
710 .CompareObjectFile => |expected_output| {710 .CompareObjectFile => |expected_output| {
711 var file = try tmp.dir.openFile(bin_name, .{ .read = true });711 var file = try tmp.dir.openFile(bin_name, .{ .read = true });
712 defer file.close();712 defer file.close();
713 const out = try file.reader().readAllAlloc(arena, 5 * 1024 * 1024);713 const out = try file.reader().readAllAlloc(arena, 5 * 1024 * 1024);
714714
715 std.testing.expectEqualStrings(expected_output, out);715 try std.testing.expectEqualStrings(expected_output, out);
716 },716 },
717 .Error => |case_error_list| {717 .Error => |case_error_list| {
718 var test_node = update_node.start("assert", 0);718 var test_node = update_node.start("assert", 0);
...@@ -939,7 +939,7 @@ pub const TestContext = struct {...@@ -939,7 +939,7 @@ pub const TestContext = struct {
939 return error.ZigTestFailed;939 return error.ZigTestFailed;
940 },940 },
941 }941 }
942 std.testing.expectEqualStrings(expected_stdout, exec_result.stdout);942 try std.testing.expectEqualStrings(expected_stdout, exec_result.stdout);
943 // We allow stderr to have garbage in it because wasmtime prints a943 // We allow stderr to have garbage in it because wasmtime prints a
944 // warning about --invoke even though we don't pass it.944 // warning about --invoke even though we don't pass it.
945 //std.testing.expectEqualStrings("", exec_result.stderr);945 //std.testing.expectEqualStrings("", exec_result.stderr);
src/value.zig+3-3
...@@ -1456,19 +1456,19 @@ test "hash same value different representation" {...@@ -1456,19 +1456,19 @@ test "hash same value different representation" {
1456 .data = 0,1456 .data = 0,
1457 };1457 };
1458 const zero_2 = Value.initPayload(&payload_1.base);1458 const zero_2 = Value.initPayload(&payload_1.base);
1459 std.testing.expectEqual(zero_1.hash(), zero_2.hash());1459 try std.testing.expectEqual(zero_1.hash(), zero_2.hash());
14601460
1461 var payload_2 = Value.Payload.I64{1461 var payload_2 = Value.Payload.I64{
1462 .base = .{ .tag = .int_i64 },1462 .base = .{ .tag = .int_i64 },
1463 .data = 0,1463 .data = 0,
1464 };1464 };
1465 const zero_3 = Value.initPayload(&payload_2.base);1465 const zero_3 = Value.initPayload(&payload_2.base);
1466 std.testing.expectEqual(zero_2.hash(), zero_3.hash());1466 try std.testing.expectEqual(zero_2.hash(), zero_3.hash());
14671467
1468 var payload_3 = Value.Payload.BigInt{1468 var payload_3 = Value.Payload.BigInt{
1469 .base = .{ .tag = .int_big_negative },1469 .base = .{ .tag = .int_big_negative },
1470 .data = &[_]std.math.big.Limb{0},1470 .data = &[_]std.math.big.Limb{0},
1471 };1471 };
1472 const zero_4 = Value.initPayload(&payload_3.base);1472 const zero_4 = Value.initPayload(&payload_3.base);
1473 std.testing.expectEqual(zero_3.hash(), zero_4.hash());1473 try std.testing.expectEqual(zero_3.hash(), zero_4.hash());
1474}1474}