| ... | @@ -1169,7 +1169,7 @@ pub const Order = enum { | ... | @@ -1169,7 +1169,7 @@ pub const Order = enum { |
| 1169 | return switch (self) { | 1169 | return switch (self) { |
| 1170 | .lt => .gt, | 1170 | .lt => .gt, |
| 1171 | .eq => .eq, | 1171 | .eq => .eq, |
| 1172 | .gt => .gt, | 1172 | .gt => .lt, |
| 1173 | }; | 1173 | }; |
| 1174 | } | 1174 | } |
| 1175 | | 1175 | |
| ... | @@ -1266,6 +1266,29 @@ test "compare between signed and unsigned" { | ... | @@ -1266,6 +1266,29 @@ test "compare between signed and unsigned" { |
| 1266 | testing.expect(compare(@as(u8, 1), .eq, @as(u8, 1))); | 1266 | testing.expect(compare(@as(u8, 1), .eq, @as(u8, 1))); |
| 1267 | } | 1267 | } |
| 1268 | | 1268 | |
| | 1269 | test "order" { |
| | 1270 | testing.expect(order(0, 0) == .eq); |
| | 1271 | testing.expect(order(1, 0) == .gt); |
| | 1272 | testing.expect(order(-1, 0) == .lt); |
| | 1273 | } |
| | 1274 | |
| | 1275 | test "order.invert" { |
| | 1276 | testing.expect(Order.invert(order(0, 0)) == .eq); |
| | 1277 | testing.expect(Order.invert(order(1, 0)) == .lt); |
| | 1278 | testing.expect(Order.invert(order(-1, 0)) == .gt); |
| | 1279 | } |
| | 1280 | |
| | 1281 | test "order.compare" { |
| | 1282 | testing.expect(order(-1, 0).compare(.lt)); |
| | 1283 | testing.expect(order(-1, 0).compare(.lte)); |
| | 1284 | testing.expect(order(0, 0).compare(.lte)); |
| | 1285 | testing.expect(order(0, 0).compare(.eq)); |
| | 1286 | testing.expect(order(0, 0).compare(.gte)); |
| | 1287 | testing.expect(order(1, 0).compare(.gte)); |
| | 1288 | testing.expect(order(1, 0).compare(.gt)); |
| | 1289 | testing.expect(order(1, 0).compare(.neq)); |
| | 1290 | } |
| | 1291 | |
| 1269 | test "math.comptime" { | 1292 | test "math.comptime" { |
| 1270 | comptime const v = sin(@as(f32, 1)) + ln(@as(f32, 5)); | 1293 | comptime const v = sin(@as(f32, 1)) + ln(@as(f32, 5)); |
| 1271 | testing.expect(v == sin(@as(f32, 1)) + ln(@as(f32, 5))); | 1294 | testing.expect(v == sin(@as(f32, 1)) + ln(@as(f32, 5))); |