File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 44 validateFunction,
55} = require ( 'internal/validators' ) ;
66const {
7- ERR_NOT_BUILDING_SNAPSHOT ,
8- ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION ,
7+ codes : {
8+ ERR_NOT_BUILDING_SNAPSHOT ,
9+ ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION ,
10+ } ,
911} = require ( 'internal/errors' ) ;
1012
1113const {
Original file line number Diff line number Diff line change @@ -30,3 +30,8 @@ addDeserializeCallback(({ filePath }) => {
3030setDeserializeMainFunction ( ( { filePath } ) => {
3131 console . log ( storage [ filePath ] . toString ( ) ) ;
3232} , { filePath } ) ;
33+ assert . throws ( ( ) => setDeserializeMainFunction ( ( ) => {
34+ assert . fail ( 'unreachable duplicated main function' ) ;
35+ } ) , {
36+ code : 'ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION' ,
37+ } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ require ( '../common' ) ;
4+ const assert = require ( 'assert' ) ;
5+
6+ const {
7+ isBuildingSnapshot,
8+ addSerializeCallback,
9+ addDeserializeCallback,
10+ setDeserializeMainFunction
11+ } = require ( 'v8' ) . startupSnapshot ;
12+
13+ // This test verifies that the v8.startupSnapshot APIs are not available when
14+ // it is not building snapshot.
15+
16+ assert ( ! isBuildingSnapshot ( ) ) ;
17+
18+ assert . throws ( ( ) => addSerializeCallback ( ( ) => { } ) , {
19+ code : 'ERR_NOT_BUILDING_SNAPSHOT' ,
20+ } ) ;
21+ assert . throws ( ( ) => addDeserializeCallback ( ( ) => { } ) , {
22+ code : 'ERR_NOT_BUILDING_SNAPSHOT' ,
23+ } ) ;
24+ assert . throws ( ( ) => setDeserializeMainFunction ( ( ) => { } ) , {
25+ code : 'ERR_NOT_BUILDING_SNAPSHOT' ,
26+ } ) ;
You can’t perform that action at this time.
0 commit comments