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" {...@@ -736,7 +736,7 @@ test "WasmPageAllocator internals" {
736 if (comptime std.Target.current.isWasm()) {736 if (comptime std.Target.current.isWasm()) {
737 const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size;737 const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size;
738 const initial = try page_allocator.alloc(u8, mem.page_size);738 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
741 var inplace = try page_allocator.realloc(initial, 1);741 var inplace = try page_allocator.realloc(initial, 1);
742 testing.expectEqual(initial.ptr, inplace.ptr);742 testing.expectEqual(initial.ptr, inplace.ptr);
lib/std/heap/logging_allocator.zig+1-1
...@@ -93,7 +93,7 @@ test "LoggingAllocator" {...@@ -93,7 +93,7 @@ test "LoggingAllocator" {
9393
94 var a = try allocator.alloc(u8, 10);94 var a = try allocator.alloc(u8, 10);
95 a = allocator.shrink(a, 5);95 a = allocator.shrink(a, 5);
96 std.debug.assert(a.len == 5);96 std.testing.expect(a.len == 5);
97 std.testing.expectError(error.OutOfMemory, allocator.resize(a, 20));97 std.testing.expectError(error.OutOfMemory, allocator.resize(a, 20));
98 allocator.free(a);98 allocator.free(a);
9999
lib/std/io/test.zig+1-5
...@@ -40,11 +40,7 @@ test "write a file, read it, then delete it" {...@@ -40,11 +40,7 @@ test "write a file, read it, then delete it" {
4040
41 {41 {
42 // Make sure the exclusive flag is honored.42 // Make sure the exclusive flag is honored.
43 if (tmp.dir.createFile(tmp_file_name, .{ .exclusive = true })) |file| {43 expectError(File.OpenError.PathAlreadyExists, tmp.dir.createFile(tmp_file_name, .{ .exclusive = true }));
44 unreachable;
45 } else |err| {
46 std.debug.assert(err == File.OpenError.PathAlreadyExists);
47 }
48 }44 }
4945
50 {46 {
lib/std/math/exp.zig+17-18
...@@ -11,8 +11,7 @@...@@ -11,8 +11,7 @@
1111
12const std = @import("../std.zig");12const std = @import("../std.zig");
13const math = std.math;13const math = std.math;
14const assert = std.debug.assert;14const expect = std.testing.expect;
15const builtin = @import("builtin");
1615
17/// Returns e raised to the power of x (e^x).16/// Returns e raised to the power of x (e^x).
18///17///
...@@ -188,36 +187,36 @@ fn exp64(x_: f64) f64 {...@@ -188,36 +187,36 @@ fn exp64(x_: f64) f64 {
188}187}
189188
190test "math.exp" {189test "math.exp" {
191 assert(exp(@as(f32, 0.0)) == exp32(0.0));190 expect(exp(@as(f32, 0.0)) == exp32(0.0));
192 assert(exp(@as(f64, 0.0)) == exp64(0.0));191 expect(exp(@as(f64, 0.0)) == exp64(0.0));
193}192}
194193
195test "math.exp32" {194test "math.exp32" {
196 const epsilon = 0.000001;195 const epsilon = 0.000001;
197196
198 assert(exp32(0.0) == 1.0);197 expect(exp32(0.0) == 1.0);
199 assert(math.approxEqAbs(f32, exp32(0.0), 1.0, epsilon));198 expect(math.approxEqAbs(f32, exp32(0.0), 1.0, epsilon));
200 assert(math.approxEqAbs(f32, exp32(0.2), 1.221403, epsilon));199 expect(math.approxEqAbs(f32, exp32(0.2), 1.221403, epsilon));
201 assert(math.approxEqAbs(f32, exp32(0.8923), 2.440737, epsilon));200 expect(math.approxEqAbs(f32, exp32(0.8923), 2.440737, epsilon));
202 assert(math.approxEqAbs(f32, exp32(1.5), 4.481689, epsilon));201 expect(math.approxEqAbs(f32, exp32(1.5), 4.481689, epsilon));
203}202}
204203
205test "math.exp64" {204test "math.exp64" {
206 const epsilon = 0.000001;205 const epsilon = 0.000001;
207206
208 assert(exp64(0.0) == 1.0);207 expect(exp64(0.0) == 1.0);
209 assert(math.approxEqAbs(f64, exp64(0.0), 1.0, epsilon));208 expect(math.approxEqAbs(f64, exp64(0.0), 1.0, epsilon));
210 assert(math.approxEqAbs(f64, exp64(0.2), 1.221403, epsilon));209 expect(math.approxEqAbs(f64, exp64(0.2), 1.221403, epsilon));
211 assert(math.approxEqAbs(f64, exp64(0.8923), 2.440737, epsilon));210 expect(math.approxEqAbs(f64, exp64(0.8923), 2.440737, epsilon));
212 assert(math.approxEqAbs(f64, exp64(1.5), 4.481689, epsilon));211 expect(math.approxEqAbs(f64, exp64(1.5), 4.481689, epsilon));
213}212}
214213
215test "math.exp32.special" {214test "math.exp32.special" {
216 assert(math.isPositiveInf(exp32(math.inf(f32))));215 expect(math.isPositiveInf(exp32(math.inf(f32))));
217 assert(math.isNan(exp32(math.nan(f32))));216 expect(math.isNan(exp32(math.nan(f32))));
218}217}
219218
220test "math.exp64.special" {219test "math.exp64.special" {
221 assert(math.isPositiveInf(exp64(math.inf(f64))));220 expect(math.isPositiveInf(exp64(math.inf(f64))));
222 assert(math.isNan(exp64(math.nan(f64))));221 expect(math.isNan(exp64(math.nan(f64))));
223}222}
lib/std/rand.zig+1-1
...@@ -1152,7 +1152,7 @@ test "CSPRNG" {...@@ -1152,7 +1152,7 @@ test "CSPRNG" {
1152 const a = csprng.random.int(u64);1152 const a = csprng.random.int(u64);
1153 const b = csprng.random.int(u64);1153 const b = csprng.random.int(u64);
1154 const c = csprng.random.int(u64);1154 const c = csprng.random.int(u64);
1155 assert(a ^ b ^ c != 0);1155 expect(a ^ b ^ c != 0);
1156}1156}
11571157
1158test "" {1158test "" {
src/libc_installation.zig-2
...@@ -14,8 +14,6 @@ const log = std.log.scoped(.libc_installation);...@@ -14,8 +14,6 @@ const log = std.log.scoped(.libc_installation);
1414
15usingnamespace @import("windows_sdk.zig");15usingnamespace @import("windows_sdk.zig");
1616
17// TODO https://github.com/ziglang/zig/issues/6345
18
19/// See the render function implementation for documentation of the fields.17/// See the render function implementation for documentation of the fields.
20pub const LibCInstallation = struct {18pub const LibCInstallation = struct {
21 include_dir: ?[]const u8 = null,19 include_dir: ?[]const u8 = null,
test/stage1/behavior/bugs/421.zig+2-2
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1const assert = @import("std").debug.assert;1const expect = @import("std").testing.expect;
22
3test "bitCast to array" {3test "bitCast to array" {
4 comptime testBitCastArray();4 comptime testBitCastArray();
...@@ -6,7 +6,7 @@ test "bitCast to array" {...@@ -6,7 +6,7 @@ test "bitCast to array" {
6}6}
77
8fn testBitCastArray() void {8fn testBitCastArray() void {
9 assert(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);9 expect(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
10}10}
1111
12fn extractOne64(a: u128) u64 {12fn extractOne64(a: u128) u64 {
test/standalone/use_alias/main.zig+2-2
...@@ -1,10 +1,10 @@...@@ -1,10 +1,10 @@
1const c = @import("c.zig");1const c = @import("c.zig");
2const assert = @import("std").debug.assert;2const expect = @import("std").testing.expect;
33
4test "symbol exists" {4test "symbol exists" {
5 var foo = c.Foo{5 var foo = c.Foo{
6 .a = 1,6 .a = 1,
7 .b = 1,7 .b = 1,
8 };8 };
9 assert(foo.a + foo.b == 2);9 expect(foo.a + foo.b == 2);
10}10}