Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/std/heap.zig
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ test "WasmPageAllocator internals" {
if (comptime std.Target.current.isWasm()) {
const conventional_memsize = WasmPageAllocator.conventional.totalPages() * mem.page_size;
const initial = try page_allocator.alloc(u8, mem.page_size);
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.
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.

var inplace = try page_allocator.realloc(initial, 1);
testing.expectEqual(initial.ptr, inplace.ptr);
Expand Down
2 changes: 1 addition & 1 deletion lib/std/heap/logging_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test "LoggingAllocator" {

var a = try allocator.alloc(u8, 10);
a = allocator.shrink(a, 5);
std.debug.assert(a.len == 5);
std.testing.expect(a.len == 5);
std.testing.expectError(error.OutOfMemory, allocator.resize(a, 20));
allocator.free(a);

Expand Down
6 changes: 1 addition & 5 deletions lib/std/io/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ test "write a file, read it, then delete it" {

{
// Make sure the exclusive flag is honored.
if (tmp.dir.createFile(tmp_file_name, .{ .exclusive = true })) |file| {
unreachable;
} else |err| {
std.debug.assert(err == File.OpenError.PathAlreadyExists);
}
expectError(File.OpenError.PathAlreadyExists, tmp.dir.createFile(tmp_file_name, .{ .exclusive = true }));
}

{
Expand Down
35 changes: 17 additions & 18 deletions lib/std/math/exp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

const std = @import("../std.zig");
const math = std.math;
const assert = std.debug.assert;
const builtin = @import("builtin");
const expect = std.testing.expect;

/// Returns e raised to the power of x (e^x).
///
Expand Down Expand Up @@ -188,36 +187,36 @@ fn exp64(x_: f64) f64 {
}

test "math.exp" {
assert(exp(@as(f32, 0.0)) == exp32(0.0));
assert(exp(@as(f64, 0.0)) == exp64(0.0));
expect(exp(@as(f32, 0.0)) == exp32(0.0));
expect(exp(@as(f64, 0.0)) == exp64(0.0));
}

test "math.exp32" {
const epsilon = 0.000001;

assert(exp32(0.0) == 1.0);
assert(math.approxEqAbs(f32, exp32(0.0), 1.0, epsilon));
assert(math.approxEqAbs(f32, exp32(0.2), 1.221403, epsilon));
assert(math.approxEqAbs(f32, exp32(0.8923), 2.440737, epsilon));
assert(math.approxEqAbs(f32, exp32(1.5), 4.481689, epsilon));
expect(exp32(0.0) == 1.0);
expect(math.approxEqAbs(f32, exp32(0.0), 1.0, epsilon));
expect(math.approxEqAbs(f32, exp32(0.2), 1.221403, epsilon));
expect(math.approxEqAbs(f32, exp32(0.8923), 2.440737, epsilon));
expect(math.approxEqAbs(f32, exp32(1.5), 4.481689, epsilon));
}

test "math.exp64" {
const epsilon = 0.000001;

assert(exp64(0.0) == 1.0);
assert(math.approxEqAbs(f64, exp64(0.0), 1.0, epsilon));
assert(math.approxEqAbs(f64, exp64(0.2), 1.221403, epsilon));
assert(math.approxEqAbs(f64, exp64(0.8923), 2.440737, epsilon));
assert(math.approxEqAbs(f64, exp64(1.5), 4.481689, epsilon));
expect(exp64(0.0) == 1.0);
expect(math.approxEqAbs(f64, exp64(0.0), 1.0, epsilon));
expect(math.approxEqAbs(f64, exp64(0.2), 1.221403, epsilon));
expect(math.approxEqAbs(f64, exp64(0.8923), 2.440737, epsilon));
expect(math.approxEqAbs(f64, exp64(1.5), 4.481689, epsilon));
}

test "math.exp32.special" {
assert(math.isPositiveInf(exp32(math.inf(f32))));
assert(math.isNan(exp32(math.nan(f32))));
expect(math.isPositiveInf(exp32(math.inf(f32))));
expect(math.isNan(exp32(math.nan(f32))));
}

test "math.exp64.special" {
assert(math.isPositiveInf(exp64(math.inf(f64))));
assert(math.isNan(exp64(math.nan(f64))));
expect(math.isPositiveInf(exp64(math.inf(f64))));
expect(math.isNan(exp64(math.nan(f64))));
}
2 changes: 1 addition & 1 deletion lib/std/rand.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ test "CSPRNG" {
const a = csprng.random.int(u64);
const b = csprng.random.int(u64);
const c = csprng.random.int(u64);
assert(a ^ b ^ c != 0);
expect(a ^ b ^ c != 0);
}

test "" {
Expand Down
2 changes: 0 additions & 2 deletions src/libc_installation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const log = std.log.scoped(.libc_installation);

usingnamespace @import("windows_sdk.zig");

// TODO https://github.com/ziglang/zig/issues/6345

/// See the render function implementation for documentation of the fields.
pub const LibCInstallation = struct {
include_dir: ?[]const u8 = null,
Expand Down
4 changes: 2 additions & 2 deletions test/stage1/behavior/bugs/421.zig
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const assert = @import("std").debug.assert;
const expect = @import("std").testing.expect;

test "bitCast to array" {
comptime testBitCastArray();
testBitCastArray();
}

fn testBitCastArray() void {
assert(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
expect(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
}

fn extractOne64(a: u128) u64 {
Expand Down
4 changes: 2 additions & 2 deletions test/standalone/use_alias/main.zig
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const c = @import("c.zig");
const assert = @import("std").debug.assert;
const expect = @import("std").testing.expect;

test "symbol exists" {
var foo = c.Foo{
.a = 1,
.b = 1,
};
assert(foo.a + foo.b == 2);
expect(foo.a + foo.b == 2);
}