Skip to content

Commit b77a9bd

Browse files
committed
update usage of std.testing in stage2
1 parent 0454de1 commit b77a9bd

File tree

13 files changed

+139
-139
lines changed

13 files changed

+139
-139
lines changed

src/Cache.zig

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ test "cache file and then recall it" {
727727
_ = try ch.addFile(temp_file, null);
728728

729729
// There should be nothing in the cache
730-
testing.expectEqual(false, try ch.hit());
730+
try testing.expectEqual(false, try ch.hit());
731731

732732
digest1 = ch.final();
733733
try ch.writeManifest();
@@ -742,13 +742,13 @@ test "cache file and then recall it" {
742742
_ = try ch.addFile(temp_file, null);
743743

744744
// Cache hit! We just "built" the same file
745-
testing.expect(try ch.hit());
745+
try testing.expect(try ch.hit());
746746
digest2 = ch.final();
747747

748748
try ch.writeManifest();
749749
}
750750

751-
testing.expectEqual(digest1, digest2);
751+
try testing.expectEqual(digest1, digest2);
752752
}
753753

754754
try cwd.deleteTree(temp_manifest_dir);
@@ -760,11 +760,11 @@ test "give problematic timestamp" {
760760
// to make it problematic, we make it only accurate to the second
761761
fs_clock = @divTrunc(fs_clock, std.time.ns_per_s);
762762
fs_clock *= std.time.ns_per_s;
763-
testing.expect(isProblematicTimestamp(fs_clock));
763+
try testing.expect(isProblematicTimestamp(fs_clock));
764764
}
765765

766766
test "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));
768768
}
769769

770770
test "check that changing a file makes cache fail" {
@@ -807,9 +807,9 @@ test "check that changing a file makes cache fail" {
807807
const temp_file_idx = try ch.addFile(temp_file, 100);
808808

809809
// 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

814814
digest1 = ch.final();
815815

@@ -826,17 +826,17 @@ test "check that changing a file makes cache fail" {
826826
const temp_file_idx = try ch.addFile(temp_file, 100);
827827

828828
// 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

831831
// 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

834834
digest2 = ch.final();
835835

836836
try ch.writeManifest();
837837
}
838838

839-
testing.expect(!mem.eql(u8, digest1[0..], digest2[0..]));
839+
try testing.expect(!mem.eql(u8, digest1[0..], digest2[0..]));
840840
}
841841

842842
try cwd.deleteTree(temp_manifest_dir);
@@ -868,7 +868,7 @@ test "no file inputs" {
868868
ch.hash.addBytes("1234");
869869

870870
// There should be nothing in the cache
871-
testing.expectEqual(false, try ch.hit());
871+
try testing.expectEqual(false, try ch.hit());
872872

873873
digest1 = ch.final();
874874

@@ -880,12 +880,12 @@ test "no file inputs" {
880880

881881
ch.hash.addBytes("1234");
882882

883-
testing.expect(try ch.hit());
883+
try testing.expect(try ch.hit());
884884
digest2 = ch.final();
885885
try ch.writeManifest();
886886
}
887887

888-
testing.expectEqual(digest1, digest2);
888+
try testing.expectEqual(digest1, digest2);
889889
}
890890

891891
test "Manifest with files added after initial hash work" {
@@ -926,7 +926,7 @@ test "Manifest with files added after initial hash work" {
926926
_ = try ch.addFile(temp_file1, null);
927927

928928
// There should be nothing in the cache
929-
testing.expectEqual(false, try ch.hit());
929+
try testing.expectEqual(false, try ch.hit());
930930

931931
_ = try ch.addFilePost(temp_file2);
932932

@@ -940,12 +940,12 @@ test "Manifest with files added after initial hash work" {
940940
ch.hash.addBytes("1234");
941941
_ = try ch.addFile(temp_file1, null);
942942

943-
testing.expect(try ch.hit());
943+
try testing.expect(try ch.hit());
944944
digest2 = ch.final();
945945

946946
try ch.writeManifest();
947947
}
948-
testing.expect(mem.eql(u8, &digest1, &digest2));
948+
try testing.expect(mem.eql(u8, &digest1, &digest2));
949949

950950
// Modify the file added after initial hash
951951
const ts2 = std.time.nanoTimestamp();
@@ -963,7 +963,7 @@ test "Manifest with files added after initial hash work" {
963963
_ = try ch.addFile(temp_file1, null);
964964

965965
// 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

968968
_ = try ch.addFilePost(temp_file2);
969969

@@ -972,7 +972,7 @@ test "Manifest with files added after initial hash work" {
972972
try ch.writeManifest();
973973
}
974974

975-
testing.expect(!mem.eql(u8, &digest1, &digest3));
975+
try testing.expect(!mem.eql(u8, &digest1, &digest3));
976976
}
977977

978978
try cwd.deleteTree(temp_manifest_dir);

src/Compilation.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,14 +2853,14 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
28532853
}
28542854

28552855
test "classifyFileExt" {
2856-
std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
2857-
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
2858-
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
2859-
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
2860-
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
2861-
std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
2862-
std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
2863-
std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
2856+
try std.testing.expectEqual(FileExt.cpp, classifyFileExt("foo.cc"));
2857+
try std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.nim"));
2858+
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so"));
2859+
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1"));
2860+
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2"));
2861+
try std.testing.expectEqual(FileExt.shared_library, classifyFileExt("foo.so.1.2.3"));
2862+
try std.testing.expectEqual(FileExt.unknown, classifyFileExt("foo.so.1.2.3~"));
2863+
try std.testing.expectEqual(FileExt.zig, classifyFileExt("foo.zig"));
28642864
}
28652865

28662866
fn haveFramePointer(comp: *const Compilation) bool {

src/DepTokenizer.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
918918
}
919919

920920
if (std.mem.eql(u8, expect, buffer.items)) {
921-
testing.expect(true);
921+
try testing.expect(true);
922922
return;
923923
}
924924

@@ -930,7 +930,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
930930
try printSection(out, ">>>> got", buffer.items);
931931
try printRuler(out);
932932

933-
testing.expect(false);
933+
try testing.expect(false);
934934
}
935935

936936
fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {

src/codegen/aarch64.zig

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,27 @@ pub const c_abi_int_param_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6,
6767
pub const c_abi_int_return_regs = [_]Register{ .x0, .x1, .x2, .x3, .x4, .x5, .x6, .x7 };
6868

6969
test "Register.id" {
70-
testing.expectEqual(@as(u5, 0), Register.x0.id());
71-
testing.expectEqual(@as(u5, 0), Register.w0.id());
70+
try testing.expectEqual(@as(u5, 0), Register.x0.id());
71+
try testing.expectEqual(@as(u5, 0), Register.w0.id());
7272

73-
testing.expectEqual(@as(u5, 31), Register.xzr.id());
74-
testing.expectEqual(@as(u5, 31), Register.wzr.id());
73+
try testing.expectEqual(@as(u5, 31), Register.xzr.id());
74+
try testing.expectEqual(@as(u5, 31), Register.wzr.id());
7575

76-
testing.expectEqual(@as(u5, 31), Register.sp.id());
77-
testing.expectEqual(@as(u5, 31), Register.sp.id());
76+
try testing.expectEqual(@as(u5, 31), Register.sp.id());
77+
try testing.expectEqual(@as(u5, 31), Register.sp.id());
7878
}
7979

8080
test "Register.size" {
81-
testing.expectEqual(@as(u7, 64), Register.x19.size());
82-
testing.expectEqual(@as(u7, 32), Register.w3.size());
81+
try testing.expectEqual(@as(u7, 64), Register.x19.size());
82+
try testing.expectEqual(@as(u7, 32), Register.w3.size());
8383
}
8484

8585
test "Register.to64/to32" {
86-
testing.expectEqual(Register.x0, Register.w0.to64());
87-
testing.expectEqual(Register.x0, Register.x0.to64());
86+
try testing.expectEqual(Register.x0, Register.w0.to64());
87+
try testing.expectEqual(Register.x0, Register.x0.to64());
8888

89-
testing.expectEqual(Register.w3, Register.w3.to32());
90-
testing.expectEqual(Register.w3, Register.x3.to32());
89+
try testing.expectEqual(Register.w3, Register.w3.to32());
90+
try testing.expectEqual(Register.w3, Register.x3.to32());
9191
}
9292

9393
// zig fmt: off
@@ -169,33 +169,33 @@ pub const FloatingPointRegister = enum(u8) {
169169
// zig fmt: on
170170

171171
test "FloatingPointRegister.id" {
172-
testing.expectEqual(@as(u5, 0), FloatingPointRegister.b0.id());
173-
testing.expectEqual(@as(u5, 0), FloatingPointRegister.h0.id());
174-
testing.expectEqual(@as(u5, 0), FloatingPointRegister.s0.id());
175-
testing.expectEqual(@as(u5, 0), FloatingPointRegister.d0.id());
176-
testing.expectEqual(@as(u5, 0), FloatingPointRegister.q0.id());
177-
178-
testing.expectEqual(@as(u5, 2), FloatingPointRegister.q2.id());
179-
testing.expectEqual(@as(u5, 31), FloatingPointRegister.d31.id());
172+
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.b0.id());
173+
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.h0.id());
174+
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.s0.id());
175+
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.d0.id());
176+
try testing.expectEqual(@as(u5, 0), FloatingPointRegister.q0.id());
177+
178+
try testing.expectEqual(@as(u5, 2), FloatingPointRegister.q2.id());
179+
try testing.expectEqual(@as(u5, 31), FloatingPointRegister.d31.id());
180180
}
181181

182182
test "FloatingPointRegister.size" {
183-
testing.expectEqual(@as(u8, 128), FloatingPointRegister.q1.size());
184-
testing.expectEqual(@as(u8, 64), FloatingPointRegister.d2.size());
185-
testing.expectEqual(@as(u8, 32), FloatingPointRegister.s3.size());
186-
testing.expectEqual(@as(u8, 16), FloatingPointRegister.h4.size());
187-
testing.expectEqual(@as(u8, 8), FloatingPointRegister.b5.size());
183+
try testing.expectEqual(@as(u8, 128), FloatingPointRegister.q1.size());
184+
try testing.expectEqual(@as(u8, 64), FloatingPointRegister.d2.size());
185+
try testing.expectEqual(@as(u8, 32), FloatingPointRegister.s3.size());
186+
try testing.expectEqual(@as(u8, 16), FloatingPointRegister.h4.size());
187+
try testing.expectEqual(@as(u8, 8), FloatingPointRegister.b5.size());
188188
}
189189

190190
test "FloatingPointRegister.toX" {
191-
testing.expectEqual(FloatingPointRegister.q1, FloatingPointRegister.q1.to128());
192-
testing.expectEqual(FloatingPointRegister.q2, FloatingPointRegister.b2.to128());
193-
testing.expectEqual(FloatingPointRegister.q3, FloatingPointRegister.h3.to128());
194-
195-
testing.expectEqual(FloatingPointRegister.d0, FloatingPointRegister.q0.to64());
196-
testing.expectEqual(FloatingPointRegister.s1, FloatingPointRegister.d1.to32());
197-
testing.expectEqual(FloatingPointRegister.h2, FloatingPointRegister.s2.to16());
198-
testing.expectEqual(FloatingPointRegister.b3, FloatingPointRegister.h3.to8());
191+
try testing.expectEqual(FloatingPointRegister.q1, FloatingPointRegister.q1.to128());
192+
try testing.expectEqual(FloatingPointRegister.q2, FloatingPointRegister.b2.to128());
193+
try testing.expectEqual(FloatingPointRegister.q3, FloatingPointRegister.h3.to128());
194+
195+
try testing.expectEqual(FloatingPointRegister.d0, FloatingPointRegister.q0.to64());
196+
try testing.expectEqual(FloatingPointRegister.s1, FloatingPointRegister.d1.to32());
197+
try testing.expectEqual(FloatingPointRegister.h2, FloatingPointRegister.s2.to16());
198+
try testing.expectEqual(FloatingPointRegister.b3, FloatingPointRegister.h3.to8());
199199
}
200200

201201
/// Represents an instruction in the AArch64 instruction set
@@ -1225,6 +1225,6 @@ test "serialize instructions" {
12251225

12261226
for (testcases) |case| {
12271227
const actual = case.inst.toU32();
1228-
testing.expectEqual(case.expected, actual);
1228+
try testing.expectEqual(case.expected, actual);
12291229
}
12301230
}

src/codegen/arm.zig

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ pub const Condition = enum(u4) {
8888
};
8989

9090
test "condition from CompareOperator" {
91-
testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorSigned(.eq));
92-
testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorUnsigned(.eq));
91+
try testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorSigned(.eq));
92+
try testing.expectEqual(@as(Condition, .eq), Condition.fromCompareOperatorUnsigned(.eq));
9393

94-
testing.expectEqual(@as(Condition, .gt), Condition.fromCompareOperatorSigned(.gt));
95-
testing.expectEqual(@as(Condition, .hi), Condition.fromCompareOperatorUnsigned(.gt));
94+
try testing.expectEqual(@as(Condition, .gt), Condition.fromCompareOperatorSigned(.gt));
95+
try testing.expectEqual(@as(Condition, .hi), Condition.fromCompareOperatorUnsigned(.gt));
9696

97-
testing.expectEqual(@as(Condition, .le), Condition.fromCompareOperatorSigned(.lte));
98-
testing.expectEqual(@as(Condition, .ls), Condition.fromCompareOperatorUnsigned(.lte));
97+
try testing.expectEqual(@as(Condition, .le), Condition.fromCompareOperatorSigned(.lte));
98+
try testing.expectEqual(@as(Condition, .ls), Condition.fromCompareOperatorUnsigned(.lte));
9999
}
100100

101101
test "negate condition" {
102-
testing.expectEqual(@as(Condition, .eq), Condition.ne.negate());
103-
testing.expectEqual(@as(Condition, .ne), Condition.eq.negate());
102+
try testing.expectEqual(@as(Condition, .eq), Condition.ne.negate());
103+
try testing.expectEqual(@as(Condition, .ne), Condition.eq.negate());
104104
}
105105

106106
/// Represents a register in the ARM instruction set architecture
@@ -175,8 +175,8 @@ pub const Register = enum(u5) {
175175
};
176176

177177
test "Register.id" {
178-
testing.expectEqual(@as(u4, 15), Register.r15.id());
179-
testing.expectEqual(@as(u4, 15), Register.pc.id());
178+
try testing.expectEqual(@as(u4, 15), Register.r15.id());
179+
try testing.expectEqual(@as(u4, 15), Register.pc.id());
180180
}
181181

182182
/// Program status registers containing flags, mode bits and other
@@ -1225,7 +1225,7 @@ test "serialize instructions" {
12251225

12261226
for (testcases) |case| {
12271227
const actual = case.inst.toU32();
1228-
testing.expectEqual(case.expected, actual);
1228+
try testing.expectEqual(case.expected, actual);
12291229
}
12301230
}
12311231

@@ -1265,6 +1265,6 @@ test "aliases" {
12651265
};
12661266

12671267
for (testcases) |case| {
1268-
testing.expectEqual(case.expected.toU32(), case.actual.toU32());
1268+
try testing.expectEqual(case.expected.toU32(), case.actual.toU32());
12691269
}
12701270
}

src/codegen/riscv64.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,6 @@ test "serialize instructions" {
465465

466466
for (testcases) |case| {
467467
const actual = case.inst.toU32();
468-
testing.expectEqual(case.expected, actual);
468+
try testing.expectEqual(case.expected, actual);
469469
}
470470
}

src/codegen/wasm.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,11 @@ test "Wasm - buildOpcode" {
463463
const i64_extend32_s = buildOpcode(.{ .op = .extend, .valtype1 = .i64, .width = 32, .signedness = .signed });
464464
const f64_reinterpret_i64 = buildOpcode(.{ .op = .reinterpret, .valtype1 = .f64, .valtype2 = .i64 });
465465

466-
testing.expectEqual(@as(wasm.Opcode, .i32_const), i32_const);
467-
testing.expectEqual(@as(wasm.Opcode, .end), end);
468-
testing.expectEqual(@as(wasm.Opcode, .local_get), local_get);
469-
testing.expectEqual(@as(wasm.Opcode, .i64_extend32_s), i64_extend32_s);
470-
testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64);
466+
try testing.expectEqual(@as(wasm.Opcode, .i32_const), i32_const);
467+
try testing.expectEqual(@as(wasm.Opcode, .end), end);
468+
try testing.expectEqual(@as(wasm.Opcode, .local_get), local_get);
469+
try testing.expectEqual(@as(wasm.Opcode, .i64_extend32_s), i64_extend32_s);
470+
try testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64);
471471
}
472472

473473
pub const Result = union(enum) {

src/link/MachO/CodeSignature.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test "CodeSignature header" {
182182
try code_sig.writeHeader(stream.writer());
183183

184184
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));
186186
}
187187

188188
pub fn calcCodeSignaturePaddingSize(id: []const u8, file_size: u64, page_size: u16) u32 {

0 commit comments

Comments
 (0)