n-api: simplify bigint-from-word creation · nodejs/node@02fe750 · GitHub
Skip to content

Commit 02fe750

Browse files
Gabriel Schulhofaddaleax
authored andcommitted
n-api: simplify bigint-from-word creation
Macro `CHECK_MAYBE_EMPTY_WITH_PREAMBLE()` does the work of checking the `TryCatch` and returning `napi_pending_exception` so this change reuses it for `napi_create_bigint_words()`. Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com> PR-URL: #34554 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 09a6cef commit 02fe750

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/js_native_api_v8.cc

Lines changed: 4 additions & 7 deletions

test/js-native-api/test_bigint/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
TestUint64,
88
TestWords,
99
CreateTooBigBigInt,
10+
MakeBigIntWordsThrow,
1011
} = require(`./build/${common.buildType}/test_bigint`);
1112

1213
[
@@ -43,3 +44,9 @@ assert.throws(CreateTooBigBigInt, {
4344
name: 'Error',
4445
message: 'Invalid argument',
4546
});
47+
48+
// Test that we correctly forward exceptions from the engine.
49+
assert.throws(MakeBigIntWordsThrow, {
50+
name: 'RangeError',
51+
message: 'Maximum BigInt size exceeded'
52+
});

test/js-native-api/test_bigint/test_bigint.c

Lines changed: 18 additions & 0 deletions

0 commit comments

Comments
 (0)