Skip to content

Commit 9c34e07

Browse files
committed
update usage of std.testing in compiler_rt
1 parent 5c603a5 commit 9c34e07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2259
-2259
lines changed

lib/std/special/c.zig

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ test "strcpy" {
6666

6767
s1[0] = 0;
6868
_ = strcpy(&s1, "foobarbaz");
69-
std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
69+
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
7070
}
7171

7272
fn strncpy(dest: [*:0]u8, src: [*:0]const u8, n: usize) callconv(.C) [*:0]u8 {
@@ -86,7 +86,7 @@ test "strncpy" {
8686

8787
s1[0] = 0;
8888
_ = strncpy(&s1, "foobarbaz", @sizeOf(@TypeOf(s1)));
89-
std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
89+
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
9090
}
9191

9292
fn strcat(dest: [*:0]u8, src: [*:0]const u8) callconv(.C) [*:0]u8 {
@@ -109,7 +109,7 @@ test "strcat" {
109109
_ = strcat(&s1, "foo");
110110
_ = strcat(&s1, "bar");
111111
_ = strcat(&s1, "baz");
112-
std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
112+
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
113113
}
114114

115115
fn strncat(dest: [*:0]u8, src: [*:0]const u8, avail: usize) callconv(.C) [*:0]u8 {
@@ -132,7 +132,7 @@ test "strncat" {
132132
_ = strncat(&s1, "foo1111", 3);
133133
_ = strncat(&s1, "bar1111", 3);
134134
_ = strncat(&s1, "baz1111", 3);
135-
std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
135+
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.spanZ(&s1));
136136
}
137137

138138
fn strcmp(s1: [*:0]const u8, s2: [*:0]const u8) callconv(.C) c_int {
@@ -871,13 +871,13 @@ test "fmod, fmodf" {
871871
try std.testing.expect(isNan(generic_fmod(T, 0.0, 0.0)));
872872
try std.testing.expect(isNan(generic_fmod(T, 1.0, 0.0)));
873873

874-
std.testing.expectEqual(@as(T, 0.0), generic_fmod(T, 0.0, 2.0));
875-
std.testing.expectEqual(@as(T, -0.0), generic_fmod(T, -0.0, 2.0));
874+
try std.testing.expectEqual(@as(T, 0.0), generic_fmod(T, 0.0, 2.0));
875+
try std.testing.expectEqual(@as(T, -0.0), generic_fmod(T, -0.0, 2.0));
876876

877-
std.testing.expectEqual(@as(T, -2.0), generic_fmod(T, -32.0, 10.0));
878-
std.testing.expectEqual(@as(T, -2.0), generic_fmod(T, -32.0, -10.0));
879-
std.testing.expectEqual(@as(T, 2.0), generic_fmod(T, 32.0, 10.0));
880-
std.testing.expectEqual(@as(T, 2.0), generic_fmod(T, 32.0, -10.0));
877+
try std.testing.expectEqual(@as(T, -2.0), generic_fmod(T, -32.0, 10.0));
878+
try std.testing.expectEqual(@as(T, -2.0), generic_fmod(T, -32.0, -10.0));
879+
try std.testing.expectEqual(@as(T, 2.0), generic_fmod(T, 32.0, 10.0));
880+
try std.testing.expectEqual(@as(T, 2.0), generic_fmod(T, 32.0, -10.0));
881881
}
882882
}
883883

@@ -902,11 +902,11 @@ test "fmin, fminf" {
902902
const nan_val = math.nan(T);
903903

904904
try std.testing.expect(isNan(generic_fmin(T, nan_val, nan_val)));
905-
std.testing.expectEqual(@as(T, 1.0), generic_fmin(T, nan_val, 1.0));
906-
std.testing.expectEqual(@as(T, 1.0), generic_fmin(T, 1.0, nan_val));
905+
try std.testing.expectEqual(@as(T, 1.0), generic_fmin(T, nan_val, 1.0));
906+
try std.testing.expectEqual(@as(T, 1.0), generic_fmin(T, 1.0, nan_val));
907907

908-
std.testing.expectEqual(@as(T, 1.0), generic_fmin(T, 1.0, 10.0));
909-
std.testing.expectEqual(@as(T, -1.0), generic_fmin(T, 1.0, -1.0));
908+
try std.testing.expectEqual(@as(T, 1.0), generic_fmin(T, 1.0, 10.0));
909+
try std.testing.expectEqual(@as(T, -1.0), generic_fmin(T, 1.0, -1.0));
910910
}
911911
}
912912

@@ -931,11 +931,11 @@ test "fmax, fmaxf" {
931931
const nan_val = math.nan(T);
932932

933933
try std.testing.expect(isNan(generic_fmax(T, nan_val, nan_val)));
934-
std.testing.expectEqual(@as(T, 1.0), generic_fmax(T, nan_val, 1.0));
935-
std.testing.expectEqual(@as(T, 1.0), generic_fmax(T, 1.0, nan_val));
934+
try std.testing.expectEqual(@as(T, 1.0), generic_fmax(T, nan_val, 1.0));
935+
try std.testing.expectEqual(@as(T, 1.0), generic_fmax(T, 1.0, nan_val));
936936

937-
std.testing.expectEqual(@as(T, 10.0), generic_fmax(T, 1.0, 10.0));
938-
std.testing.expectEqual(@as(T, 1.0), generic_fmax(T, 1.0, -1.0));
937+
try std.testing.expectEqual(@as(T, 10.0), generic_fmax(T, 1.0, 10.0));
938+
try std.testing.expectEqual(@as(T, 1.0), generic_fmax(T, 1.0, -1.0));
939939
}
940940
}
941941

@@ -1090,7 +1090,7 @@ test "sqrt" {
10901090
// Note that @sqrt will either generate the sqrt opcode (if supported by the
10911091
// target ISA) or a call to `sqrtf` otherwise.
10921092
for (V) |val|
1093-
std.testing.expectEqual(@sqrt(val), sqrt(val));
1093+
try std.testing.expectEqual(@sqrt(val), sqrt(val));
10941094
}
10951095

10961096
test "sqrt special" {
@@ -1195,7 +1195,7 @@ test "sqrtf" {
11951195
// Note that @sqrt will either generate the sqrt opcode (if supported by the
11961196
// target ISA) or a call to `sqrtf` otherwise.
11971197
for (V) |val|
1198-
std.testing.expectEqual(@sqrt(val), sqrtf(val));
1198+
try std.testing.expectEqual(@sqrt(val), sqrtf(val));
11991199
}
12001200

12011201
test "sqrtf special" {

lib/std/special/compiler_rt/addXf3_test.zig

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const inf128 = @bitCast(f128, @as(u128, 0x7fff000000000000) << 64);
1313

1414
const __addtf3 = @import("addXf3.zig").__addtf3;
1515

16-
fn test__addtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {
16+
fn test__addtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) !void {
1717
const x = __addtf3(a, b);
1818

1919
const rep = @bitCast(u128, x);
@@ -32,28 +32,28 @@ fn test__addtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {
3232
}
3333
}
3434

35-
@panic("__addtf3 test failure");
35+
return error.TestFailed;
3636
}
3737

3838
test "addtf3" {
39-
test__addtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
39+
try test__addtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
4040

4141
// NaN + any = NaN
42-
test__addtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
42+
try test__addtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
4343

4444
// inf + inf = inf
45-
test__addtf3(inf128, inf128, 0x7fff000000000000, 0x0);
45+
try test__addtf3(inf128, inf128, 0x7fff000000000000, 0x0);
4646

4747
// inf + any = inf
48-
test__addtf3(inf128, 0x1.2335653452436234723489432abcdefp+5, 0x7fff000000000000, 0x0);
48+
try test__addtf3(inf128, 0x1.2335653452436234723489432abcdefp+5, 0x7fff000000000000, 0x0);
4949

5050
// any + any
51-
test__addtf3(0x1.23456734245345543849abcdefp+5, 0x1.edcba52449872455634654321fp-1, 0x40042afc95c8b579, 0x61e58dd6c51eb77c);
51+
try test__addtf3(0x1.23456734245345543849abcdefp+5, 0x1.edcba52449872455634654321fp-1, 0x40042afc95c8b579, 0x61e58dd6c51eb77c);
5252
}
5353

5454
const __subtf3 = @import("addXf3.zig").__subtf3;
5555

56-
fn test__subtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {
56+
fn test__subtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) !void {
5757
const x = __subtf3(a, b);
5858

5959
const rep = @bitCast(u128, x);
@@ -72,19 +72,19 @@ fn test__subtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) void {
7272
}
7373
}
7474

75-
@panic("__subtf3 test failure");
75+
return error.TestFailed;
7676
}
7777

7878
test "subtf3" {
7979
// qNaN - any = qNaN
80-
test__subtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
80+
try test__subtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
8181

8282
// NaN + any = NaN
83-
test__subtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
83+
try test__subtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
8484

8585
// inf - any = inf
86-
test__subtf3(inf128, 0x1.23456789abcdefp+5, 0x7fff000000000000, 0x0);
86+
try test__subtf3(inf128, 0x1.23456789abcdefp+5, 0x7fff000000000000, 0x0);
8787

8888
// any + any
89-
test__subtf3(0x1.234567829a3bcdef5678ade36734p+5, 0x1.ee9d7c52354a6936ab8d7654321fp-1, 0x40041b8af1915166, 0xa44a7bca780a166c);
89+
try test__subtf3(0x1.234567829a3bcdef5678ade36734p+5, 0x1.ee9d7c52354a6936ab8d7654321fp-1, 0x40041b8af1915166, 0xa44a7bca780a166c);
9090
}

lib/std/special/compiler_rt/ashldi3_test.zig

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@
66
const __ashldi3 = @import("shift.zig").__ashldi3;
77
const testing = @import("std").testing;
88

9-
fn test__ashldi3(a: i64, b: i32, expected: u64) void {
9+
fn test__ashldi3(a: i64, b: i32, expected: u64) !void {
1010
const x = __ashldi3(a, b);
11-
testing.expectEqual(@bitCast(i64, expected), x);
11+
try testing.expectEqual(@bitCast(i64, expected), x);
1212
}
1313

1414
test "ashldi3" {
15-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 0, 0x123456789ABCDEF);
16-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 1, 0x2468ACF13579BDE);
17-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 2, 0x48D159E26AF37BC);
18-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 3, 0x91A2B3C4D5E6F78);
19-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 4, 0x123456789ABCDEF0);
15+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 0, 0x123456789ABCDEF);
16+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 1, 0x2468ACF13579BDE);
17+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 2, 0x48D159E26AF37BC);
18+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 3, 0x91A2B3C4D5E6F78);
19+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 4, 0x123456789ABCDEF0);
2020

21-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 28, 0x789ABCDEF0000000);
22-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 29, 0xF13579BDE0000000);
23-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 30, 0xE26AF37BC0000000);
24-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 31, 0xC4D5E6F780000000);
21+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 28, 0x789ABCDEF0000000);
22+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 29, 0xF13579BDE0000000);
23+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 30, 0xE26AF37BC0000000);
24+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 31, 0xC4D5E6F780000000);
2525

26-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 32, 0x89ABCDEF00000000);
26+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 32, 0x89ABCDEF00000000);
2727

28-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 33, 0x13579BDE00000000);
29-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 34, 0x26AF37BC00000000);
30-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 35, 0x4D5E6F7800000000);
31-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 36, 0x9ABCDEF000000000);
28+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 33, 0x13579BDE00000000);
29+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 34, 0x26AF37BC00000000);
30+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 35, 0x4D5E6F7800000000);
31+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 36, 0x9ABCDEF000000000);
3232

33-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 60, 0xF000000000000000);
34-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 61, 0xE000000000000000);
35-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 62, 0xC000000000000000);
36-
test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 63, 0x8000000000000000);
33+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 60, 0xF000000000000000);
34+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 61, 0xE000000000000000);
35+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 62, 0xC000000000000000);
36+
try test__ashldi3(@bitCast(i64, @as(u64, 0x0123456789ABCDEF)), 63, 0x8000000000000000);
3737
}

0 commit comments

Comments
 (0)