aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2022-12-02 20:35:13 -0800
committerGravatar GitHub <noreply@github.com> 2022-12-02 20:35:13 -0800
commit9cc03cd71a2e42b489b8b0c837cdb0d1b1d3fa0b (patch)
tree822f2753f22f0587e21530d0ca4fbdba9e7e187c
parentd9f9fc975beb9d5d8fe83f6ed2a084c36846522b (diff)
downloadbun-9cc03cd71a2e42b489b8b0c837cdb0d1b1d3fa0b.tar.gz
bun-9cc03cd71a2e42b489b8b0c837cdb0d1b1d3fa0b.tar.zst
bun-9cc03cd71a2e42b489b8b0c837cdb0d1b1d3fa0b.zip
matchers for less than and greater than (#1573)
* toBeGreaterThan with tests * toBeGreaterThanOrEqual and tests * toBeLessThan and toBeLessThanOrEqual with tests * expect types * switch expressions
-rw-r--r--packages/bun-types/bun-test.d.ts4
-rw-r--r--src/bun.js/bindings/bindings.cpp46
-rw-r--r--src/bun.js/bindings/bindings.zig17
-rw-r--r--src/bun.js/bindings/headers.h3
-rw-r--r--src/bun.js/bindings/headers.zig1
-rw-r--r--src/bun.js/test/jest.zig256
-rw-r--r--test/bun.js/test-test.test.ts449
7 files changed, 770 insertions, 6 deletions
diff --git a/packages/bun-types/bun-test.d.ts b/packages/bun-types/bun-test.d.ts
index 62d6bef3e..c651b0a21 100644
--- a/packages/bun-types/bun-test.d.ts
+++ b/packages/bun-types/bun-test.d.ts
@@ -45,6 +45,10 @@ declare module "bun:test" {
toBeUndefined(): void;
toBeNaN(): void;
toBeNull(): void;
+ toBeGreaterThan(value: number | bigint): void;
+ toBeGreaterThanOrEqual(value: number | bigint): void;
+ toBeLessThan(value: number | bigint): void;
+ toBeLessThanOrEqual(value: number | bigint): void;
}
}
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 24edae6c4..68abf7882 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -2354,6 +2354,52 @@ int64_t JSC__JSValue__toInt64(JSC__JSValue val)
return _val.asAnyInt();
}
+uint8_t JSC__JSValue__asBigIntCompare(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, JSC__JSValue JSValue1)
+{
+ JSValue v1 = JSValue::decode(JSValue0);
+ JSValue v2 = JSValue::decode(JSValue1);
+ ASSERT(v1.isHeapBigInt() || v1.isBigInt32());
+
+#if USE(BIGINT32)
+ if (v1.isBigInt32()) {
+ int32_t v1Int = v1.bigInt32AsInt32();
+ if (v2.isHeapBigInt()) {
+ return static_cast<uint8_t>(JSBigInt::compare(v1Int, v2.asHeapBigInt()));
+ } else if (v2.isBigInt32()) {
+ return static_cast<uint8_t>(JSBigInt::compare(v1Int, v2.bigInt32AsInt32()));
+ }
+
+ double v2Double = v2.asNumber();
+ if (v1Int == v2Double) {
+ return static_cast<uint8_t>(JSBigInt::ComparisonResult::Equal);
+ }
+ if (v1Int < v2Double) {
+ return static_cast<uint8_t>(JSBigInt::ComparisonResult::LessThan);
+ }
+
+ return static_cast<uint8_t>(JSBigInt::ComparisonResult::GreaterThan);
+ }
+#endif
+
+ if (v1.isHeapBigInt()) {
+ JSBigInt* v1BigInt = v1.asHeapBigInt();
+ if (v2.isHeapBigInt()) {
+ return static_cast<uint8_t>(JSBigInt::compare(v1BigInt, v2.asHeapBigInt()));
+ }
+
+#if USE(BIGINT32)
+ if (v2.isBigInt32()) {
+ return static_cast<uint8_t>(JSBigInt::compare(v1BigInt, v2.toInt32(globalObject)));
+ }
+#endif
+
+ return static_cast<uint8_t>(JSBigInt::compareToDouble(v1BigInt, v2.asNumber()));
+ }
+
+ ASSERT_NOT_REACHED();
+ return static_cast<uint8_t>(JSBigInt::ComparisonResult::Undefined);
+}
+
JSC__JSValue JSC__JSValue__fromInt64NoTruncate(JSC__JSGlobalObject* globalObject, int64_t val)
{
return JSC::JSValue::encode(JSC::JSValue(JSC::JSBigInt::createFrom(globalObject, val)));
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index f20a65243..6976694ea 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -2672,6 +2672,21 @@ pub const JSValue = enum(JSValueReprInt) {
return cppFn("toInt64", .{this});
}
+ pub const ComparisonResult = enum(u8) {
+ equal,
+ undefined_result,
+ greater_than,
+ less_than,
+ invalid_comparison,
+ };
+
+ pub fn asBigIntCompare(this: JSValue, global: *JSGlobalObject, other: JSValue) ComparisonResult {
+ if (!this.isBigInt() or (!other.isBigInt() and !other.isNumber())) {
+ return .invalid_comparison;
+ }
+ return cppFn("asBigIntCompare", .{ this, global, other });
+ }
+
pub inline fn isUndefined(this: JSValue) bool {
return @enumToInt(this) == 0xa;
}
@@ -3175,7 +3190,7 @@ pub const JSValue = enum(JSValueReprInt) {
return this.asNullableVoid().?;
}
- pub const Extern = [_][]const u8{ "forEachProperty", "coerceToInt32", "fastGet_", "getStaticProperty", "createUninitializedUint8Array", "fromInt64NoTruncate", "fromUInt64NoTruncate", "toUInt64NoTruncate", "asPromise", "toInt64", "_then", "put", "makeWithNameAndPrototype", "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable", "toBooleanSlow", "deepEquals", "strictDeepEquals", "getIfPropertyExistsFromPath" };
+ pub const Extern = [_][]const u8{ "forEachProperty", "coerceToInt32", "fastGet_", "getStaticProperty", "createUninitializedUint8Array", "fromInt64NoTruncate", "fromUInt64NoTruncate", "toUInt64NoTruncate", "asPromise", "toInt64", "_then", "put", "makeWithNameAndPrototype", "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable", "toBooleanSlow", "deepEquals", "strictDeepEquals", "getIfPropertyExistsFromPath", "asBigIntCompare" };
};
extern "c" fn Microtask__run(*Microtask, *JSGlobalObject) void;
diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h
index 675d6df44..a5aa965ef 100644
--- a/src/bun.js/bindings/headers.h
+++ b/src/bun.js/bindings/headers.h
@@ -1,5 +1,5 @@
// clang-format off
-//-- AUTOGENERATED FILE -- 1669793662
+//-- AUTOGENERATED FILE -- 1669974046
#pragma once
#include <stddef.h>
@@ -243,6 +243,7 @@ CPP_DECL JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0);
CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__JSValue (* ArgFn3)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1), JSC__JSValue (* ArgFn4)(JSC__JSGlobalObject* arg0, JSC__CallFrame* arg1));
CPP_DECL bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, Bun__ArrayBuffer* arg2);
+CPP_DECL unsigned char JSC__JSValue__asBigIntCompare(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
CPP_DECL JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0);
CPP_DECL JSC__JSInternalPromise* JSC__JSValue__asInternalPromise(JSC__JSValue JSValue0);
CPP_DECL double JSC__JSValue__asNumber(JSC__JSValue JSValue0);
diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig
index 808fa4fbc..3446a7f55 100644
--- a/src/bun.js/bindings/headers.zig
+++ b/src/bun.js/bindings/headers.zig
@@ -168,6 +168,7 @@ pub extern fn JSC__JSGlobalObject__startRemoteInspector(arg0: ?*JSC__JSGlobalObj
pub extern fn JSC__JSGlobalObject__vm(arg0: ?*JSC__JSGlobalObject) [*c]JSC__VM;
pub extern fn JSC__JSValue___then(JSValue0: JSC__JSValue, arg1: ?*JSC__JSGlobalObject, JSValue2: JSC__JSValue, ArgFn3: ?fn (?*JSC__JSGlobalObject, ?*bindings.CallFrame) callconv(.C) JSC__JSValue, ArgFn4: ?fn (?*JSC__JSGlobalObject, ?*bindings.CallFrame) callconv(.C) JSC__JSValue) void;
pub extern fn JSC__JSValue__asArrayBuffer_(JSValue0: JSC__JSValue, arg1: ?*JSC__JSGlobalObject, arg2: ?*Bun__ArrayBuffer) bool;
+pub extern fn JSC__JSValue__asBigIntCompare(JSValue0: JSC__JSValue, arg1: ?*JSC__JSGlobalObject, JSValue2: JSC__JSValue) u8;
pub extern fn JSC__JSValue__asCell(JSValue0: JSC__JSValue) [*c]JSC__JSCell;
pub extern fn JSC__JSValue__asInternalPromise(JSValue0: JSC__JSValue) [*c]JSC__JSInternalPromise;
pub extern fn JSC__JSValue__asNumber(JSValue0: JSC__JSValue) f64;
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 351049f65..240698753 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -828,6 +828,258 @@ pub const Expect = struct {
return .zero;
}
+ pub fn toBeGreaterThan(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue {
+ defer this.postMatch(globalObject);
+
+ const thisValue = callFrame.this();
+ const _arguments = callFrame.arguments(1);
+ const arguments: []const JSValue = _arguments.ptr[0.._arguments.len];
+
+ if (arguments.len < 1) {
+ globalObject.throwInvalidArguments("toBeGreaterThan() requires 1 argument", .{});
+ return .zero;
+ }
+
+ if (this.scope.tests.items.len <= this.test_id) {
+ globalObject.throw("toBeGreaterThan() must be called in a test", .{});
+ return .zero;
+ }
+
+ active_test_expectation_counter.actual += 1;
+
+ const other_value = arguments[0];
+ other_value.ensureStillAlive();
+
+ const value = Expect.capturedValueGetCached(thisValue) orelse {
+ globalObject.throw("Internal consistency error: thie expect(value) was garbage collected but it should not have been!", .{});
+ return .zero;
+ };
+ value.ensureStillAlive();
+
+ if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) {
+ globalObject.throw("Expected and actual values must be numbers or bigints", .{});
+ return .zero;
+ }
+
+ const not = this.op.contains(.not);
+ var pass = false;
+
+ if (!value.isBigInt() and !other_value.isBigInt()) {
+ pass = value.asNumber() > other_value.asNumber();
+ } else if (value.isBigInt()) {
+ pass = switch (value.asBigIntCompare(globalObject, other_value)) {
+ .greater_than => true,
+ else => pass,
+ };
+ } else {
+ pass = switch (other_value.asBigIntCompare(globalObject, value)) {
+ .less_than => true,
+ else => pass,
+ };
+ }
+
+ if (not) pass = !pass;
+ if (pass) return thisValue;
+
+ // handle failure
+ var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject };
+ if (not) {
+ globalObject.throw("Expected {any} to not be greater than {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ } else {
+ globalObject.throw("Expected {any} to be greater than {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ }
+ return .zero;
+ }
+
+ pub fn toBeGreaterThanOrEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue {
+ defer this.postMatch(globalObject);
+
+ const thisValue = callFrame.this();
+ const _arguments = callFrame.arguments(1);
+ const arguments: []const JSValue = _arguments.ptr[0.._arguments.len];
+
+ if (arguments.len < 1) {
+ globalObject.throwInvalidArguments("toBeGreaterThanOrEqual() requires 1 argument", .{});
+ return .zero;
+ }
+
+ if (this.scope.tests.items.len <= this.test_id) {
+ globalObject.throw("toBeGreaterThanOrEqual() must be called in a test", .{});
+ return .zero;
+ }
+
+ active_test_expectation_counter.actual += 1;
+
+ const other_value = arguments[0];
+ other_value.ensureStillAlive();
+
+ const value = Expect.capturedValueGetCached(thisValue) orelse {
+ globalObject.throw("Internal consistency error: thie expect(value) was garbage collected but it should not have been!", .{});
+ return .zero;
+ };
+ value.ensureStillAlive();
+
+ if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) {
+ globalObject.throw("Expected and actual values must be numbers or bigints", .{});
+ return .zero;
+ }
+
+ const not = this.op.contains(.not);
+ var pass = false;
+
+ if (!value.isBigInt() and !other_value.isBigInt()) {
+ pass = value.asNumber() >= other_value.asNumber();
+ } else if (value.isBigInt()) {
+ pass = switch (value.asBigIntCompare(globalObject, other_value)) {
+ .greater_than, .equal => true,
+ else => pass,
+ };
+ } else {
+ pass = switch (other_value.asBigIntCompare(globalObject, value)) {
+ .less_than, .equal => true,
+ else => pass,
+ };
+ }
+
+ if (not) pass = !pass;
+ if (pass) return thisValue;
+
+ // handle failure
+ var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject };
+ if (not) {
+ globalObject.throw("Expected {any} to not be greater than or equal to {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ } else {
+ globalObject.throw("Expected {any} to be greater than or equal to {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ }
+ return .zero;
+ }
+
+ pub fn toBeLessThan(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue {
+ defer this.postMatch(globalObject);
+
+ const thisValue = callFrame.this();
+ const _arguments = callFrame.arguments(1);
+ const arguments: []const JSValue = _arguments.ptr[0.._arguments.len];
+
+ if (arguments.len < 1) {
+ globalObject.throwInvalidArguments("toBeLessThan() requires 1 argument", .{});
+ return .zero;
+ }
+
+ if (this.scope.tests.items.len <= this.test_id) {
+ globalObject.throw("toBeLessThan() must be called in a test", .{});
+ return .zero;
+ }
+
+ active_test_expectation_counter.actual += 1;
+
+ const other_value = arguments[0];
+ other_value.ensureStillAlive();
+
+ const value = Expect.capturedValueGetCached(thisValue) orelse {
+ globalObject.throw("Internal consistency error: thie expect(value) was garbage collected but it should not have been!", .{});
+ return .zero;
+ };
+ value.ensureStillAlive();
+
+ if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) {
+ globalObject.throw("Expected and actual values must be numbers or bigints", .{});
+ return .zero;
+ }
+
+ const not = this.op.contains(.not);
+ var pass = false;
+
+ if (!value.isBigInt() and !other_value.isBigInt()) {
+ pass = value.asNumber() < other_value.asNumber();
+ } else if (value.isBigInt()) {
+ pass = switch (value.asBigIntCompare(globalObject, other_value)) {
+ .less_than => true,
+ else => pass,
+ };
+ } else {
+ pass = switch (other_value.asBigIntCompare(globalObject, value)) {
+ .greater_than => true,
+ else => pass,
+ };
+ }
+
+ if (not) pass = !pass;
+ if (pass) return thisValue;
+
+ // handle failure
+ var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject };
+ if (not) {
+ globalObject.throw("Expected {any} to not be less than {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ } else {
+ globalObject.throw("Expected {any} to be less than {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ }
+ return .zero;
+ }
+
+ pub fn toBeLessThanOrEqual(this: *Expect, globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSValue {
+ defer this.postMatch(globalObject);
+
+ const thisValue = callFrame.this();
+ const _arguments = callFrame.arguments(1);
+ const arguments: []const JSValue = _arguments.ptr[0.._arguments.len];
+
+ if (arguments.len < 1) {
+ globalObject.throwInvalidArguments("toBeLessThanOrEqual() requires 1 argument", .{});
+ return .zero;
+ }
+
+ if (this.scope.tests.items.len <= this.test_id) {
+ globalObject.throw("toBeLessThanOrEqual() must be called in a test", .{});
+ return .zero;
+ }
+
+ active_test_expectation_counter.actual += 1;
+
+ const other_value = arguments[0];
+ other_value.ensureStillAlive();
+
+ const value = Expect.capturedValueGetCached(thisValue) orelse {
+ globalObject.throw("Internal consistency error: thie expect(value) was garbage collected but it should not have been!", .{});
+ return .zero;
+ };
+ value.ensureStillAlive();
+
+ if ((!value.isNumber() and !value.isBigInt()) or (!other_value.isNumber() and !other_value.isBigInt())) {
+ globalObject.throw("Expected and actual values must be numbers or bigints", .{});
+ return .zero;
+ }
+
+ const not = this.op.contains(.not);
+ var pass = false;
+
+ if (!value.isBigInt() and !other_value.isBigInt()) {
+ pass = value.asNumber() <= other_value.asNumber();
+ } else if (value.isBigInt()) {
+ pass = switch (value.asBigIntCompare(globalObject, other_value)) {
+ .less_than, .equal => true,
+ else => pass,
+ };
+ } else {
+ pass = switch (other_value.asBigIntCompare(globalObject, value)) {
+ .greater_than, .equal => true,
+ else => pass,
+ };
+ }
+
+ if (not) pass = !pass;
+ if (pass) return thisValue;
+
+ // handle failure
+ var fmt = JSC.ZigConsoleClient.Formatter{ .globalThis = globalObject };
+ if (not) {
+ globalObject.throw("Expected {any} to not be less than or equal to {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ } else {
+ globalObject.throw("Expected {any} to be less than or equal to {any}", .{ value.toFmt(globalObject, &fmt), other_value.toFmt(globalObject, &fmt) });
+ }
+ return .zero;
+ }
+
pub const toHaveBeenCalledTimes = notImplementedJSCFn;
pub const toHaveBeenCalledWith = notImplementedJSCFn;
pub const toHaveBeenLastCalledWith = notImplementedJSCFn;
@@ -837,10 +1089,6 @@ pub const Expect = struct {
pub const toHaveLastReturnedWith = notImplementedJSCFn;
pub const toHaveNthReturnedWith = notImplementedJSCFn;
pub const toBeCloseTo = notImplementedJSCFn;
- pub const toBeGreaterThan = notImplementedJSCFn;
- pub const toBeGreaterThanOrEqual = notImplementedJSCFn;
- pub const toBeLessThan = notImplementedJSCFn;
- pub const toBeLessThanOrEqual = notImplementedJSCFn;
pub const toBeInstanceOf = notImplementedJSCFn;
pub const toContainEqual = notImplementedJSCFn;
pub const toMatch = notImplementedJSCFn;
diff --git a/test/bun.js/test-test.test.ts b/test/bun.js/test-test.test.ts
index a92c316ad..211830c3e 100644
--- a/test/bun.js/test-test.test.ts
+++ b/test/bun.js/test-test.test.ts
@@ -1507,3 +1507,452 @@ test("toBeFalsy()", () => {
expect([]).not.toBeFalsy();
expect(() => {}).not.toBeFalsy();
});
+
+test("toBeGreaterThan()", () => {
+ expect(3n).toBeGreaterThan(2);
+ expect(Number.MAX_VALUE).not.toBeGreaterThan(Number.MAX_VALUE);
+ expect(1).not.toBeGreaterThan(BigInt(Number.MAX_VALUE));
+ expect(1).not.toBeGreaterThan(Number.MAX_SAFE_INTEGER);
+ expect(1).not.toBeGreaterThan(BigInt(Number.MAX_SAFE_INTEGER));
+ expect(Number.MAX_SAFE_INTEGER).not.toBeGreaterThan(Number.MAX_SAFE_INTEGER);
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeGreaterThan(
+ BigInt(Number.MAX_SAFE_INTEGER),
+ );
+
+ expect(Infinity).toBeGreaterThan(-Infinity);
+ expect(-Infinity).not.toBeGreaterThan(Infinity);
+
+ expect(NaN).not.toBeGreaterThan(NaN);
+ expect(NaN).not.toBeGreaterThan(-Infinity);
+
+ expect(10).toBeGreaterThan(9);
+ expect(10).not.toBeGreaterThan(10);
+ expect(10).not.toBeGreaterThan(11);
+ expect(10).not.toBeGreaterThan(Infinity);
+ expect(10).toBeGreaterThan(-Infinity);
+ expect(10).not.toBeGreaterThan(NaN);
+ expect(10).toBeGreaterThan(0);
+ expect(10).toBeGreaterThan(-0);
+ expect(10).toBeGreaterThan(0.1);
+ expect(10).toBeGreaterThan(-0.1);
+ expect(10).toBeGreaterThan(0.9);
+ expect(10).toBeGreaterThan(-0.9);
+ expect(10).toBeGreaterThan(1);
+ expect(10).toBeGreaterThan(-1);
+ // switch the order
+ expect(9).not.toBeGreaterThan(10);
+ expect(10).not.toBeGreaterThan(10);
+ expect(11).toBeGreaterThan(10);
+ expect(Infinity).toBeGreaterThan(10);
+ expect(-Infinity).not.toBeGreaterThan(10);
+ expect(NaN).not.toBeGreaterThan(10);
+ expect(0).not.toBeGreaterThan(10);
+ expect(-0).not.toBeGreaterThan(10);
+ expect(0.1).not.toBeGreaterThan(10);
+ expect(-0.1).not.toBeGreaterThan(10);
+ expect(0.9).not.toBeGreaterThan(10);
+ expect(-0.9).not.toBeGreaterThan(10);
+ expect(1).not.toBeGreaterThan(10);
+ expect(-1).not.toBeGreaterThan(10);
+
+ // same tests but use bigints
+ expect(10n).toBeGreaterThan(9n);
+ expect(10n).not.toBeGreaterThan(10n);
+ expect(10n).not.toBeGreaterThan(11n);
+ expect(10n).not.toBeGreaterThan(Infinity);
+ expect(10n).toBeGreaterThan(-Infinity);
+ expect(10n).not.toBeGreaterThan(NaN);
+ expect(10n).toBeGreaterThan(0n);
+ expect(10n).toBeGreaterThan(-0n);
+ expect(10n).toBeGreaterThan(1n);
+ expect(10n).toBeGreaterThan(-1n);
+ // switch the order
+ expect(9n).not.toBeGreaterThan(10n);
+ expect(10n).not.toBeGreaterThan(10n);
+ expect(11n).toBeGreaterThan(10n);
+ expect(Infinity).toBeGreaterThan(10n);
+ expect(-Infinity).not.toBeGreaterThan(10n);
+ expect(NaN).not.toBeGreaterThan(10n);
+ expect(0n).not.toBeGreaterThan(10n);
+ expect(-0n).not.toBeGreaterThan(10n);
+ expect(1n).not.toBeGreaterThan(10n);
+ expect(-1n).not.toBeGreaterThan(10n);
+
+ // use bigints and numbers
+ expect(10n).toBeGreaterThan(9);
+ expect(10n).not.toBeGreaterThan(10);
+ expect(10n).not.toBeGreaterThan(11);
+ expect(10n).not.toBeGreaterThan(Infinity);
+ expect(10n).toBeGreaterThan(-Infinity);
+ expect(10n).not.toBeGreaterThan(NaN);
+ expect(10n).toBeGreaterThan(0);
+ expect(10n).toBeGreaterThan(-0);
+ expect(10n).toBeGreaterThan(0.1);
+ expect(10n).toBeGreaterThan(-0.1);
+ expect(10n).toBeGreaterThan(0.9);
+ expect(10n).toBeGreaterThan(-0.9);
+ expect(10n).toBeGreaterThan(1);
+ expect(10n).toBeGreaterThan(-1);
+ // switch the order
+ expect(9n).not.toBeGreaterThan(10);
+ expect(10n).not.toBeGreaterThan(10);
+ expect(11n).toBeGreaterThan(10);
+ expect(Infinity).toBeGreaterThan(10n);
+ expect(-Infinity).not.toBeGreaterThan(10n);
+ expect(NaN).not.toBeGreaterThan(10n);
+ expect(0n).not.toBeGreaterThan(10);
+ expect(-0n).not.toBeGreaterThan(10);
+ expect(1n).not.toBeGreaterThan(10);
+ expect(-1n).not.toBeGreaterThan(10);
+
+ expect(1n).not.toBeGreaterThan(1);
+ expect(1n).not.toBeGreaterThan(Number.MAX_SAFE_INTEGER);
+ expect(1n).not.toBeGreaterThan(Number.MAX_VALUE);
+ expect(1).not.toBeGreaterThan(1n);
+ expect(Number.MAX_SAFE_INTEGER).toBeGreaterThan(1n);
+ expect(Number.MAX_VALUE).toBeGreaterThan(1n);
+
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeGreaterThan(1n);
+ expect(BigInt(Number.MAX_VALUE)).toBeGreaterThan(1n);
+ expect(1n).not.toBeGreaterThan(BigInt(Number.MAX_SAFE_INTEGER));
+ expect(1n).not.toBeGreaterThan(BigInt(Number.MAX_VALUE));
+
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeGreaterThan(1);
+ expect(BigInt(Number.MAX_VALUE)).toBeGreaterThan(1);
+ expect(1).not.toBeGreaterThan(BigInt(Number.MAX_SAFE_INTEGER));
+});
+
+test("toBeGreaterThanOrEqual()", () => {
+ expect(Number.MAX_VALUE).toBeGreaterThanOrEqual(Number.MAX_VALUE);
+ expect(1).not.toBeGreaterThanOrEqual(Number.MAX_SAFE_INTEGER);
+ expect(1).not.toBeGreaterThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
+ expect(1).not.toBeGreaterThanOrEqual(BigInt(Number.MAX_VALUE));
+ expect(Number.MAX_SAFE_INTEGER).toBeGreaterThanOrEqual(
+ Number.MAX_SAFE_INTEGER,
+ );
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeGreaterThanOrEqual(
+ BigInt(Number.MAX_SAFE_INTEGER),
+ );
+
+ expect(Infinity).toBeGreaterThanOrEqual(-Infinity);
+ expect(-Infinity).not.toBeGreaterThanOrEqual(Infinity);
+
+ expect(NaN).not.toBeGreaterThanOrEqual(NaN);
+ expect(NaN).not.toBeGreaterThanOrEqual(-Infinity);
+
+ expect(10).toBeGreaterThanOrEqual(9);
+ expect(10).toBeGreaterThanOrEqual(10);
+ expect(10).not.toBeGreaterThanOrEqual(11);
+ expect(10).not.toBeGreaterThanOrEqual(Infinity);
+ expect(10).toBeGreaterThanOrEqual(-Infinity);
+ expect(10).not.toBeGreaterThanOrEqual(NaN);
+ expect(10).toBeGreaterThanOrEqual(0);
+ expect(10).toBeGreaterThanOrEqual(-0);
+ expect(10).toBeGreaterThanOrEqual(0.1);
+ expect(10).toBeGreaterThanOrEqual(-0.1);
+ expect(10).toBeGreaterThanOrEqual(0.9);
+ expect(10).toBeGreaterThanOrEqual(-0.9);
+ expect(10).toBeGreaterThanOrEqual(1);
+ expect(10).toBeGreaterThanOrEqual(-1);
+ // switch the order
+ expect(9).not.toBeGreaterThanOrEqual(10);
+ expect(10).toBeGreaterThanOrEqual(10);
+ expect(11).toBeGreaterThanOrEqual(10);
+ expect(Infinity).toBeGreaterThanOrEqual(10);
+ expect(-Infinity).not.toBeGreaterThanOrEqual(10);
+ expect(NaN).not.toBeGreaterThanOrEqual(10);
+ expect(0).not.toBeGreaterThanOrEqual(10);
+ expect(-0).not.toBeGreaterThanOrEqual(10);
+ expect(0.1).not.toBeGreaterThanOrEqual(10);
+ expect(-0.1).not.toBeGreaterThanOrEqual(10);
+ expect(0.9).not.toBeGreaterThanOrEqual(10);
+ expect(-0.9).not.toBeGreaterThanOrEqual(10);
+ expect(1).not.toBeGreaterThanOrEqual(10);
+ expect(-1).not.toBeGreaterThanOrEqual(10);
+
+ // same tests but use bigints
+ expect(10n).toBeGreaterThanOrEqual(9n);
+ expect(10n).toBeGreaterThanOrEqual(10n);
+ expect(10n).not.toBeGreaterThanOrEqual(11n);
+ expect(10n).not.toBeGreaterThanOrEqual(Infinity);
+ expect(10n).toBeGreaterThanOrEqual(-Infinity);
+ expect(10n).not.toBeGreaterThanOrEqual(NaN);
+ expect(10n).toBeGreaterThanOrEqual(0n);
+ expect(10n).toBeGreaterThanOrEqual(-0n);
+ expect(10n).toBeGreaterThanOrEqual(1n);
+ expect(10n).toBeGreaterThanOrEqual(-1n);
+ // switch the order
+ expect(9n).not.toBeGreaterThanOrEqual(10n);
+ expect(10n).toBeGreaterThanOrEqual(10n);
+ expect(11n).toBeGreaterThanOrEqual(10n);
+ expect(Infinity).toBeGreaterThanOrEqual(10n);
+ expect(-Infinity).not.toBeGreaterThanOrEqual(10n);
+ expect(NaN).not.toBeGreaterThanOrEqual(10n);
+ expect(0n).not.toBeGreaterThanOrEqual(10n);
+ expect(-0n).not.toBeGreaterThanOrEqual(10n);
+ expect(1n).not.toBeGreaterThanOrEqual(10n);
+ expect(-1n).not.toBeGreaterThanOrEqual(10n);
+
+ // use bigints and numbers
+ expect(10n).toBeGreaterThanOrEqual(9);
+ expect(10n).toBeGreaterThanOrEqual(10);
+ expect(10n).not.toBeGreaterThanOrEqual(11);
+ expect(10n).not.toBeGreaterThanOrEqual(Infinity);
+ expect(10n).toBeGreaterThanOrEqual(-Infinity);
+ expect(10n).not.toBeGreaterThanOrEqual(NaN);
+ expect(10n).toBeGreaterThanOrEqual(0);
+ expect(10n).toBeGreaterThanOrEqual(-0);
+ expect(10n).toBeGreaterThanOrEqual(0.1);
+ expect(10n).toBeGreaterThanOrEqual(-0.1);
+ expect(10n).toBeGreaterThanOrEqual(0.9);
+ expect(10n).toBeGreaterThanOrEqual(-0.9);
+ expect(10n).toBeGreaterThanOrEqual(1);
+ expect(10n).toBeGreaterThanOrEqual(-1);
+ // switch the order
+ expect(9n).not.toBeGreaterThanOrEqual(10);
+ expect(10n).toBeGreaterThanOrEqual(10);
+ expect(11n).toBeGreaterThanOrEqual(10);
+ expect(Infinity).toBeGreaterThanOrEqual(10n);
+ expect(-Infinity).not.toBeGreaterThanOrEqual(10n);
+ expect(NaN).not.toBeGreaterThanOrEqual(10n);
+ expect(0n).not.toBeGreaterThanOrEqual(10);
+ expect(-0n).not.toBeGreaterThanOrEqual(10);
+ expect(1n).not.toBeGreaterThanOrEqual(10);
+ expect(-1n).not.toBeGreaterThanOrEqual(10);
+
+ expect(1n).toBeGreaterThanOrEqual(1);
+ expect(1n).not.toBeGreaterThanOrEqual(Number.MAX_SAFE_INTEGER);
+ expect(1n).not.toBeGreaterThanOrEqual(Number.MAX_VALUE);
+ expect(1).toBeGreaterThanOrEqual(1n);
+ expect(Number.MAX_SAFE_INTEGER).toBeGreaterThanOrEqual(1n);
+ expect(Number.MAX_VALUE).toBeGreaterThanOrEqual(1n);
+
+ expect(1).not.toBeGreaterThanOrEqual(BigInt(Number.MAX_VALUE));
+});
+
+test("toBeLessThan()", () => {
+ expect(3n).not.toBeLessThan(2);
+ expect(Number.MAX_VALUE).not.toBeLessThan(Number.MAX_VALUE);
+ expect(1).toBeLessThan(BigInt(Number.MAX_VALUE));
+ expect(1).toBeLessThan(Number.MAX_SAFE_INTEGER);
+ expect(1).toBeLessThan(BigInt(Number.MAX_SAFE_INTEGER));
+ expect(Number.MAX_SAFE_INTEGER).not.toBeLessThan(Number.MAX_SAFE_INTEGER);
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeLessThan(
+ BigInt(Number.MAX_SAFE_INTEGER),
+ );
+
+ expect(Number.MAX_VALUE).not.toBeLessThan(BigInt(Number.MAX_VALUE));
+
+ expect(NaN).not.toBeLessThan(NaN);
+ expect(NaN).not.toBeLessThan(-Infinity);
+
+ expect(10).not.toBeLessThan(9);
+ expect(10).not.toBeLessThan(10);
+ expect(10).toBeLessThan(11);
+ expect(10).toBeLessThan(Infinity);
+ expect(10).not.toBeLessThan(-Infinity);
+ expect(10).not.toBeLessThan(NaN);
+ expect(10).not.toBeLessThan(0);
+ expect(10).not.toBeLessThan(-0);
+ expect(10).not.toBeLessThan(0.1);
+ expect(10).not.toBeLessThan(-0.1);
+ expect(10).not.toBeLessThan(0.9);
+ expect(10).not.toBeLessThan(-0.9);
+ expect(10).not.toBeLessThan(1);
+ expect(10).not.toBeLessThan(-1);
+ // switch the order
+ expect(9).toBeLessThan(10);
+ expect(10).not.toBeLessThan(10);
+ expect(11).not.toBeLessThan(10);
+ expect(Infinity).not.toBeLessThan(10);
+ expect(-Infinity).toBeLessThan(10);
+ expect(NaN).not.toBeLessThan(10);
+ expect(0).toBeLessThan(10);
+ expect(-0).toBeLessThan(10);
+ expect(0.1).toBeLessThan(10);
+ expect(-0.1).toBeLessThan(10);
+ expect(0.9).toBeLessThan(10);
+ expect(-0.9).toBeLessThan(10);
+ expect(1).toBeLessThan(10);
+ expect(-1).toBeLessThan(10);
+
+ // same tests but use bigints
+ expect(10n).not.toBeLessThan(9n);
+ expect(10n).not.toBeLessThan(10n);
+ expect(10n).toBeLessThan(11n);
+ expect(10n).toBeLessThan(Infinity);
+ expect(10n).not.toBeLessThan(-Infinity);
+ expect(10n).not.toBeLessThan(NaN);
+ expect(10n).not.toBeLessThan(0n);
+ expect(10n).not.toBeLessThan(-0n);
+ expect(10n).not.toBeLessThan(1n);
+ expect(10n).not.toBeLessThan(-1n);
+ // switch the order
+ expect(9n).toBeLessThan(10n);
+ expect(10n).not.toBeLessThan(10n);
+ expect(11n).not.toBeLessThan(10n);
+ expect(Infinity).not.toBeLessThan(10n);
+ expect(-Infinity).toBeLessThan(10n);
+ expect(NaN).not.toBeLessThan(10n);
+ expect(0n).toBeLessThan(10n);
+ expect(-0n).toBeLessThan(10n);
+ expect(1n).toBeLessThan(10n);
+ expect(-1n).toBeLessThan(10n);
+
+ // use bigints and numbers
+ expect(10n).not.toBeLessThan(9);
+ expect(10n).not.toBeLessThan(10);
+ expect(10n).toBeLessThan(11);
+ expect(10n).toBeLessThan(Infinity);
+ expect(10n).not.toBeLessThan(-Infinity);
+ expect(10n).not.toBeLessThan(NaN);
+ expect(10n).not.toBeLessThan(0);
+ expect(10n).not.toBeLessThan(-0);
+ expect(10n).not.toBeLessThan(0.1);
+ expect(10n).not.toBeLessThan(-0.1);
+ expect(10n).not.toBeLessThan(0.9);
+ expect(10n).not.toBeLessThan(-0.9);
+ expect(10n).not.toBeLessThan(1);
+ expect(10n).not.toBeLessThan(-1);
+ // switch the order
+ expect(9n).toBeLessThan(10);
+ expect(10n).not.toBeLessThan(10);
+ expect(11n).not.toBeLessThan(10);
+ expect(Infinity).not.toBeLessThan(10n);
+ expect(-Infinity).toBeLessThan(10n);
+ expect(NaN).not.toBeLessThan(10n);
+ expect(0n).toBeLessThan(10);
+ expect(-0n).toBeLessThan(10);
+ expect(1n).toBeLessThan(10);
+ expect(-1n).toBeLessThan(10);
+
+ expect(1n).not.toBeLessThan(1);
+ expect(1n).toBeLessThan(Number.MAX_SAFE_INTEGER);
+ expect(1n).toBeLessThan(Number.MAX_VALUE);
+ expect(1).not.toBeLessThan(1n);
+ expect(Number.MAX_SAFE_INTEGER).not.toBeLessThan(1n);
+ expect(Number.MAX_VALUE).not.toBeLessThan(1n);
+
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeLessThan(1n);
+ expect(BigInt(Number.MAX_VALUE)).not.toBeLessThan(1n);
+ expect(1n).toBeLessThan(BigInt(Number.MAX_SAFE_INTEGER));
+ expect(1n).toBeLessThan(BigInt(Number.MAX_VALUE));
+
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeLessThan(1);
+ expect(BigInt(Number.MAX_VALUE)).not.toBeLessThan(1);
+ expect(1).toBeLessThan(BigInt(Number.MAX_SAFE_INTEGER));
+});
+
+test("toBeLessThanOrEqual()", () => {
+ expect(3n).not.toBeLessThanOrEqual(2);
+ expect(Number.MAX_VALUE).toBeLessThanOrEqual(Number.MAX_VALUE);
+ expect(1).toBeLessThanOrEqual(BigInt(Number.MAX_VALUE));
+ expect(1).toBeLessThanOrEqual(Number.MAX_SAFE_INTEGER);
+ expect(1).toBeLessThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
+ expect(Number.MAX_SAFE_INTEGER).toBeLessThanOrEqual(Number.MAX_SAFE_INTEGER);
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeLessThanOrEqual(
+ BigInt(Number.MAX_SAFE_INTEGER),
+ );
+
+ expect(Number.MAX_VALUE).toBeLessThanOrEqual(BigInt(Number.MAX_VALUE));
+ expect(BigInt(Number.MAX_VALUE)).toBeLessThanOrEqual(Number.MAX_VALUE);
+
+ expect(NaN).not.toBeLessThanOrEqual(NaN);
+ expect(NaN).not.toBeLessThanOrEqual(-Infinity);
+
+ expect(10).not.toBeLessThanOrEqual(9);
+ expect(10).toBeLessThanOrEqual(10);
+ expect(10).toBeLessThanOrEqual(11);
+ expect(10).toBeLessThanOrEqual(Infinity);
+ expect(10).not.toBeLessThanOrEqual(-Infinity);
+ expect(10).not.toBeLessThanOrEqual(NaN);
+ expect(10).not.toBeLessThanOrEqual(0);
+ expect(10).not.toBeLessThanOrEqual(-0);
+ expect(10).not.toBeLessThanOrEqual(0.1);
+ expect(10).not.toBeLessThanOrEqual(-0.1);
+ expect(10).not.toBeLessThanOrEqual(0.9);
+ expect(10).not.toBeLessThanOrEqual(-0.9);
+ expect(10).not.toBeLessThanOrEqual(1);
+ expect(10).not.toBeLessThanOrEqual(-1);
+ // switch the order
+ expect(9).toBeLessThanOrEqual(10);
+ expect(10).toBeLessThanOrEqual(10);
+ expect(11).not.toBeLessThanOrEqual(10);
+ expect(Infinity).not.toBeLessThanOrEqual(10);
+ expect(-Infinity).toBeLessThanOrEqual(10);
+ expect(NaN).not.toBeLessThanOrEqual(10);
+ expect(0).toBeLessThanOrEqual(10);
+ expect(-0).toBeLessThanOrEqual(10);
+ expect(0.1).toBeLessThanOrEqual(10);
+ expect(-0.1).toBeLessThanOrEqual(10);
+ expect(0.9).toBeLessThanOrEqual(10);
+ expect(-0.9).toBeLessThanOrEqual(10);
+ expect(1).toBeLessThanOrEqual(10);
+ expect(-1).toBeLessThanOrEqual(10);
+
+ // same tests but use bigints
+ expect(10n).not.toBeLessThanOrEqual(9n);
+ expect(10n).toBeLessThanOrEqual(10n);
+ expect(10n).toBeLessThanOrEqual(11n);
+ expect(10n).toBeLessThanOrEqual(Infinity);
+ expect(10n).not.toBeLessThanOrEqual(-Infinity);
+ expect(10n).not.toBeLessThanOrEqual(NaN);
+ expect(10n).not.toBeLessThanOrEqual(0n);
+ expect(10n).not.toBeLessThanOrEqual(-0n);
+ expect(10n).not.toBeLessThanOrEqual(1n);
+ expect(10n).not.toBeLessThanOrEqual(-1n);
+ // switch the order
+ expect(9n).toBeLessThanOrEqual(10n);
+ expect(10n).toBeLessThanOrEqual(10n);
+ expect(11n).not.toBeLessThanOrEqual(10n);
+ expect(Infinity).not.toBeLessThanOrEqual(10n);
+ expect(-Infinity).toBeLessThanOrEqual(10n);
+ expect(NaN).not.toBeLessThanOrEqual(10n);
+ expect(0n).toBeLessThanOrEqual(10n);
+ expect(-0n).toBeLessThanOrEqual(10n);
+ expect(1n).toBeLessThanOrEqual(10n);
+ expect(-1n).toBeLessThanOrEqual(10n);
+
+ // use bigints and numbers
+ expect(10n).not.toBeLessThanOrEqual(9);
+ expect(10n).toBeLessThanOrEqual(10);
+ expect(10n).toBeLessThanOrEqual(11);
+ expect(10n).toBeLessThanOrEqual(Infinity);
+ expect(10n).not.toBeLessThanOrEqual(-Infinity);
+ expect(10n).not.toBeLessThanOrEqual(NaN);
+ expect(10n).not.toBeLessThanOrEqual(0);
+ expect(10n).not.toBeLessThanOrEqual(-0);
+ expect(10n).not.toBeLessThanOrEqual(0.1);
+ expect(10n).not.toBeLessThanOrEqual(-0.1);
+ expect(10n).not.toBeLessThanOrEqual(0.9);
+ expect(10n).not.toBeLessThanOrEqual(-0.9);
+ expect(10n).not.toBeLessThanOrEqual(1);
+ expect(10n).not.toBeLessThanOrEqual(-1);
+ // switch the order
+ expect(9n).toBeLessThanOrEqual(10);
+ expect(10n).toBeLessThanOrEqual(10);
+ expect(11n).not.toBeLessThanOrEqual(10);
+ expect(Infinity).not.toBeLessThanOrEqual(10n);
+ expect(-Infinity).toBeLessThanOrEqual(10n);
+ expect(NaN).not.toBeLessThanOrEqual(10n);
+ expect(0n).toBeLessThanOrEqual(10);
+ expect(-0n).toBeLessThanOrEqual(10);
+ expect(1n).toBeLessThanOrEqual(10);
+ expect(-1n).toBeLessThanOrEqual(10);
+
+ expect(1n).toBeLessThanOrEqual(1);
+ expect(1n).toBeLessThanOrEqual(Number.MAX_SAFE_INTEGER);
+ expect(1n).toBeLessThanOrEqual(Number.MAX_VALUE);
+ expect(1).toBeLessThanOrEqual(1n);
+ expect(Number.MAX_SAFE_INTEGER).not.toBeLessThanOrEqual(1n);
+ expect(Number.MAX_VALUE).not.toBeLessThanOrEqual(1n);
+
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeLessThanOrEqual(1n);
+ expect(BigInt(Number.MAX_VALUE)).not.toBeLessThanOrEqual(1n);
+ expect(1n).toBeLessThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
+ expect(1n).toBeLessThanOrEqual(BigInt(Number.MAX_VALUE));
+
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeLessThanOrEqual(1);
+ expect(BigInt(Number.MAX_VALUE)).not.toBeLessThanOrEqual(1);
+ expect(1).toBeLessThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
+});