authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-11-07 11:34:51+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-11-07 11:34:51+02:00
log5430642fa0254795fbe9bb390d86baa7411676af
treec41215e7e8cb1cc3e9feeb5eb6a0f786cbb304ce
parent67ea47babdb891b7775b68683b232aa3c97ea012
parentc9fa57541bdf7c41b1bb914a9ce10a09013392a4
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #7008 from xackus/minor-fixes

change debug.assert to testing.expect in tests

8 files changed, 25 insertions(+), 32 deletions(-)

lib/std/heap.zig+1-1
......@@ -736,7 +736,7 @@ test "WasmPageAllocator internals" {
736736 if (comptime std.Target.current.isWasm()) {
737737 const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size;
738738 const initial = try page_allocator.alloc(u8, mem.page_size);
739 std.debug.assert(@ptrToInt(initial.ptr) < conventional_memsize); // If this isn't conventional, the rest of these tests don't make sense. Also we have a serious memory leak in the test suite.
739 testing.expect(@ptrToInt(initial.ptr) < conventional_memsize); // If this isn't conventional, the rest of these tests don't make sense. Also we have a serious memory leak in the test suite.
740740
741741 var inplace = try page_allocator.realloc(initial, 1);
742742 testing.expectEqual(initial.ptr, inplace.ptr);
lib/std/heap/logging_allocator.zig+1-1
......@@ -93,7 +93,7 @@ test "LoggingAllocator" {
9393
9494 var a = try allocator.alloc(u8, 10);
9595 a = allocator.shrink(a, 5);
96 std.debug.assert(a.len == 5);
96 std.testing.expect(a.len == 5);
9797 std.testing.expectError(error.OutOfMemory, allocator.resize(a, 20));
9898 allocator.free(a);
9999
lib/std/io/test.zig+1-5
......@@ -40,11 +40,7 @@ test "write a file, read it, then delete it" {
4040
4141 {
4242 // Make sure the exclusive flag is honored.
43 if (tmp.dir.createFile(tmp_file_name, .{ .exclusive = true })) |file| {
44 unreachable;
45 } else |err| {
46 std.debug.assert(err == File.OpenError.PathAlreadyExists);
47 }
43 expectError(File.OpenError.PathAlreadyExists, tmp.dir.createFile(tmp_file_name, .{ .exclusive = true }));
4844 }
4945
5046 {
lib/std/math/exp.zig+17-18
......@@ -11,8 +11,7 @@
1111
1212const std = @import("../std.zig");
1313const math = std.math;
14const assert = std.debug.assert;
15const builtin = @import("builtin");
14const expect = std.testing.expect;
1615
1716/// Returns e raised to the power of x (e^x).
1817///
......@@ -188,36 +187,36 @@ fn exp64(x_: f64) f64 {
188187}
189188
190189test "math.exp" {
191 assert(exp(@as(f32, 0.0)) == exp32(0.0));
192 assert(exp(@as(f64, 0.0)) == exp64(0.0));
190 expect(exp(@as(f32, 0.0)) == exp32(0.0));
191 expect(exp(@as(f64, 0.0)) == exp64(0.0));
193192}
194193
195194test "math.exp32" {
196195 const epsilon = 0.000001;
197196
198 assert(exp32(0.0) == 1.0);
199 assert(math.approxEqAbs(f32, exp32(0.0), 1.0, epsilon));
200 assert(math.approxEqAbs(f32, exp32(0.2), 1.221403, epsilon));
201 assert(math.approxEqAbs(f32, exp32(0.8923), 2.440737, epsilon));
202 assert(math.approxEqAbs(f32, exp32(1.5), 4.481689, epsilon));
197 expect(exp32(0.0) == 1.0);
198 expect(math.approxEqAbs(f32, exp32(0.0), 1.0, epsilon));
199 expect(math.approxEqAbs(f32, exp32(0.2), 1.221403, epsilon));
200 expect(math.approxEqAbs(f32, exp32(0.8923), 2.440737, epsilon));
201 expect(math.approxEqAbs(f32, exp32(1.5), 4.481689, epsilon));
203202}
204203
205204test "math.exp64" {
206205 const epsilon = 0.000001;
207206
208 assert(exp64(0.0) == 1.0);
209 assert(math.approxEqAbs(f64, exp64(0.0), 1.0, epsilon));
210 assert(math.approxEqAbs(f64, exp64(0.2), 1.221403, epsilon));
211 assert(math.approxEqAbs(f64, exp64(0.8923), 2.440737, epsilon));
212 assert(math.approxEqAbs(f64, exp64(1.5), 4.481689, epsilon));
207 expect(exp64(0.0) == 1.0);
208 expect(math.approxEqAbs(f64, exp64(0.0), 1.0, epsilon));
209 expect(math.approxEqAbs(f64, exp64(0.2), 1.221403, epsilon));
210 expect(math.approxEqAbs(f64, exp64(0.8923), 2.440737, epsilon));
211 expect(math.approxEqAbs(f64, exp64(1.5), 4.481689, epsilon));
213212}
214213
215214test "math.exp32.special" {
216 assert(math.isPositiveInf(exp32(math.inf(f32))));
217 assert(math.isNan(exp32(math.nan(f32))));
215 expect(math.isPositiveInf(exp32(math.inf(f32))));
216 expect(math.isNan(exp32(math.nan(f32))));
218217}
219218
220219test "math.exp64.special" {
221 assert(math.isPositiveInf(exp64(math.inf(f64))));
222 assert(math.isNan(exp64(math.nan(f64))));
220 expect(math.isPositiveInf(exp64(math.inf(f64))));
221 expect(math.isNan(exp64(math.nan(f64))));
223222}
lib/std/rand.zig+1-1
......@@ -1152,7 +1152,7 @@ test "CSPRNG" {
11521152 const a = csprng.random.int(u64);
11531153 const b = csprng.random.int(u64);
11541154 const c = csprng.random.int(u64);
1155 assert(a ^ b ^ c != 0);
1155 expect(a ^ b ^ c != 0);
11561156}
11571157
11581158test "" {
src/libc_installation.zig-2
......@@ -14,8 +14,6 @@ const log = std.log.scoped(.libc_installation);
1414
1515usingnamespace @import("windows_sdk.zig");
1616
17// TODO https://github.com/ziglang/zig/issues/6345
18
1917/// See the render function implementation for documentation of the fields.
2018pub const LibCInstallation = struct {
2119 include_dir: ?[]const u8 = null,
test/stage1/behavior/bugs/421.zig+2-2
......@@ -1,4 +1,4 @@
1const assert = @import("std").debug.assert;
1const expect = @import("std").testing.expect;
22
33test "bitCast to array" {
44 comptime testBitCastArray();
......@@ -6,7 +6,7 @@ test "bitCast to array" {
66}
77
88fn testBitCastArray() void {
9 assert(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
9 expect(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
1010}
1111
1212fn extractOne64(a: u128) u64 {
test/standalone/use_alias/main.zig+2-2
......@@ -1,10 +1,10 @@
11const c = @import("c.zig");
2const assert = @import("std").debug.assert;
2const expect = @import("std").testing.expect;
33
44test "symbol exists" {
55 var foo = c.Foo{
66 .a = 1,
77 .b = 1,
88 };
9 assert(foo.a + foo.b == 2);
9 expect(foo.a + foo.b == 2);
1010}