File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,14 @@ Value IsLossless(const CallbackInfo& info) {
25
25
return Boolean::New (env, lossless);
26
26
}
27
27
28
+ Value IsBigInt (const CallbackInfo& info) {
29
+ Env env = info.Env ();
30
+
31
+ BigInt big = info[0 ].As <BigInt>();
32
+
33
+ return Boolean::New (env, big.IsBigInt ());
34
+ }
35
+
28
36
Value TestInt64 (const CallbackInfo& info) {
29
37
bool lossless;
30
38
int64_t input = info[0 ].As <BigInt>().Int64Value (&lossless);
@@ -71,6 +79,7 @@ Value TestTooBigBigInt(const CallbackInfo& info) {
71
79
Object InitBigInt (Env env) {
72
80
Object exports = Object::New (env);
73
81
exports[" IsLossless" ] = Function::New (env, IsLossless);
82
+ exports[" IsBigInt" ] = Function::New (env, IsBigInt);
74
83
exports[" TestInt64" ] = Function::New (env, TestInt64);
75
84
exports[" TestUint64" ] = Function::New (env, TestUint64);
76
85
exports[" TestWords" ] = Function::New (env, TestWords);
Original file line number Diff line number Diff line change @@ -4,13 +4,14 @@ const assert = require('assert');
4
4
5
5
module . exports = require ( './common' ) . runTest ( test ) ;
6
6
7
- function test ( binding ) {
7
+ function test ( binding ) {
8
8
const {
9
9
TestInt64,
10
10
TestUint64,
11
11
TestWords,
12
12
IsLossless,
13
- TestTooBigBigInt,
13
+ IsBigInt,
14
+ TestTooBigBigInt
14
15
} = binding . bigint ;
15
16
16
17
[
@@ -24,7 +25,7 @@ function test(binding) {
24
25
986583n ,
25
26
- 976675n ,
26
27
98765432213456789876546896323445679887645323232436587988766545658n ,
27
- - 4350987086545760976737453646576078997096876957864353245245769809n ,
28
+ - 4350987086545760976737453646576078997096876957864353245245769809n
28
29
] . forEach ( ( num ) => {
29
30
if ( num > - ( 2n ** 63n ) && num < 2n ** 63n ) {
30
31
assert . strictEqual ( TestInt64 ( num ) , num ) ;
@@ -40,11 +41,13 @@ function test(binding) {
40
41
assert . strictEqual ( IsLossless ( num , false ) , false ) ;
41
42
}
42
43
44
+ assert . strictEqual ( IsBigInt ( num ) , true ) ;
45
+
43
46
assert . strictEqual ( num , TestWords ( num ) ) ;
44
47
} ) ;
45
48
46
49
assert . throws ( TestTooBigBigInt , {
47
50
name : / ^ ( R a n g e E r r o r | E r r o r ) $ / ,
48
- message : / ^ ( M a x i m u m B i g I n t s i z e e x c e e d e d | I n v a l i d a r g u m e n t ) $ / ,
51
+ message : / ^ ( M a x i m u m B i g I n t s i z e e x c e e d e d | I n v a l i d a r g u m e n t ) $ /
49
52
} ) ;
50
53
}
You can’t perform that action at this time.
0 commit comments