Skip to content

Commit b8f1bf4

Browse files
committed
Add test case for util.inspect(foreignBigInteger).
1 parent 4d21cca commit b8f1bf4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

graal-nodejs/test/graal/unit/other.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ describe('Other', function () {
6060
util.inspect(Point);
6161
assert.match(util.inspect(point), /getX/);
6262
});
63+
it('util.inspect should work for java.math.BigInteger', function() {
64+
const BigInteger = Java.type('java.math.BigInteger');
65+
const Long = Java.type('java.lang.Long');
66+
assert.strictEqual(String(2n ** 64n - 2n), util.inspect(BigInteger.valueOf(Long.MAX_VALUE).shiftLeft(1)));
67+
assert.strictEqual(String(2n ** 63n - 1n), util.inspect(BigInteger.valueOf(Long.MAX_VALUE)));
68+
assert.strictEqual(String(2n ** 63n - 1n), util.inspect(Long.MAX_VALUE));
69+
});
6370
}
6471
it('should not regress in ExecuteNativeFunctionNode', function () {
6572
// inspired by a wrong rewrite of ExecuteNativeFunctionNode

0 commit comments

Comments
 (0)