File tree 3 files changed +35
-2
lines changed
3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 4
4
validateFunction,
5
5
} = require ( 'internal/validators' ) ;
6
6
const {
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
+ } ,
9
11
} = require ( 'internal/errors' ) ;
10
12
11
13
const {
Original file line number Diff line number Diff line change @@ -30,3 +30,8 @@ addDeserializeCallback(({ filePath }) => {
30
30
setDeserializeMainFunction ( ( { filePath } ) => {
31
31
console . log ( storage [ filePath ] . toString ( ) ) ;
32
32
} , { 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