node/test/parallel/test-v8-startup-snapshot-api.js
Chengzhong Wu bddf341774
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>
2023-04-29 16:50:42 +00:00

27 lines
653 B
JavaScript

'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',
});