diff options
author | Chengzhong Wu <chengzhong.wcz@alibaba-inc.com> | 2023-04-30 00:50:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 16:50:42 +0000 |
commit | bddf341774586895ead3b9232cba7387752440f7 (patch) | |
tree | 7b72e58d85872da7603ddd1fb567425066d21c4a /test | |
parent | 4c620427741878a1c2d97533d7ebe175eed8c29f (diff) | |
download | node-new-bddf341774586895ead3b9232cba7387752440f7.tar.gz |
v8: fix ERR_NOT_BUILDING_SNAPSHOT is not a constructor
PR-URL: https://github.com/nodejs/node/pull/47721
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/snapshot/v8-startup-snapshot-api.js | 5 | ||||
-rw-r--r-- | test/parallel/test-v8-startup-snapshot-api.js | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/fixtures/snapshot/v8-startup-snapshot-api.js b/test/fixtures/snapshot/v8-startup-snapshot-api.js index f41f519755..9eccc65599 100644 --- a/test/fixtures/snapshot/v8-startup-snapshot-api.js +++ b/test/fixtures/snapshot/v8-startup-snapshot-api.js @@ -30,3 +30,8 @@ addDeserializeCallback(({ filePath }) => { setDeserializeMainFunction(({ filePath }) => { console.log(storage[filePath].toString()); }, { filePath }); +assert.throws(() => setDeserializeMainFunction(() => { + assert.fail('unreachable duplicated main function'); +}), { + code: 'ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION', +}); diff --git a/test/parallel/test-v8-startup-snapshot-api.js b/test/parallel/test-v8-startup-snapshot-api.js new file mode 100644 index 0000000000..c373891154 --- /dev/null +++ b/test/parallel/test-v8-startup-snapshot-api.js @@ -0,0 +1,26 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +const { + isBuildingSnapshot, + addSerializeCallback, + addDeserializeCallback, + setDeserializeMainFunction +} = require('v8').startupSnapshot; + +// This test verifies that the v8.startupSnapshot APIs are not available when +// it is not building snapshot. + +assert(!isBuildingSnapshot()); + +assert.throws(() => addSerializeCallback(() => {}), { + code: 'ERR_NOT_BUILDING_SNAPSHOT', +}); +assert.throws(() => addDeserializeCallback(() => {}), { + code: 'ERR_NOT_BUILDING_SNAPSHOT', +}); +assert.throws(() => setDeserializeMainFunction(() => {}), { + code: 'ERR_NOT_BUILDING_SNAPSHOT', +}); |