Skip to content

Commit

Permalink
Fix typo in math.order
Browse files Browse the repository at this point in the history
  • Loading branch information
data-man authored and Vexu committed Dec 16, 2020
1 parent d3a57b9 commit d877eb0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lib/std/math.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ pub const Order = enum {
return switch (self) {
.lt => .gt,
.eq => .eq,
.gt => .gt,
.gt => .lt,
};
}

Expand Down Expand Up @@ -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)));
Expand Down

0 comments on commit d877eb0

Please sign in to comment.