zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d877eb0e8d1b6327446c72a2db28b9a7c92c35bf (tree)
parent d3a57b96a9bff608f9488c5d0c3c19100997373d
Author: data-man <datamanrb@gmail.com>
Date:   Wed, 16 Dec 2020 07:38:36 +0500

Fix typo in math.order

Diffstat:
Mlib/std/math.zig | 25++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/std/math.zig b/lib/std/math.zig @@ -1169,7 +1169,7 @@ pub const Order = enum { return switch (self) { .lt => .gt, .eq => .eq, - .gt => .gt, + .gt => .lt, }; } @@ -1266,6 +1266,29 @@ test "compare between signed and unsigned" { testing.expect(compare(@as(u8, 1), .eq, @as(u8, 1))); } +test "order" { + testing.expect(order(0, 0) == .eq); + testing.expect(order(1, 0) == .gt); + testing.expect(order(-1, 0) == .lt); +} + +test "order.invert" { + testing.expect(Order.invert(order(0, 0)) == .eq); + testing.expect(Order.invert(order(1, 0)) == .lt); + testing.expect(Order.invert(order(-1, 0)) == .gt); +} + +test "order.compare" { + testing.expect(order(-1, 0).compare(.lt)); + testing.expect(order(-1, 0).compare(.lte)); + testing.expect(order(0, 0).compare(.lte)); + testing.expect(order(0, 0).compare(.eq)); + testing.expect(order(0, 0).compare(.gte)); + testing.expect(order(1, 0).compare(.gte)); + testing.expect(order(1, 0).compare(.gt)); + testing.expect(order(1, 0).compare(.neq)); +} + test "math.comptime" { comptime const v = sin(@as(f32, 1)) + ln(@as(f32, 5)); testing.expect(v == sin(@as(f32, 1)) + ln(@as(f32, 5)));