@@ -33,27 +33,57 @@ for (let i = 0; i < 10; i++) {
33
33
assert ( diffUsage . system >= 0 ) ;
34
34
}
35
35
36
+ const invalidUserArgument =
37
+ / ^ T y p e E r r o r : v a l u e o f u s e r p r o p e r t y o f a r g u m e n t i s i n v a l i d $ / ;
38
+ const invalidSystemArgument =
39
+ / ^ T y p e E r r o r : v a l u e o f s y s t e m p r o p e r t y o f a r g u m e n t i s i n v a l i d $ / ;
40
+
36
41
// Ensure that an invalid shape for the previous value argument throws an error.
37
- assert . throws ( function ( ) { process . cpuUsage ( 1 ) ; } ) ;
38
- assert . throws ( function ( ) { process . cpuUsage ( { } ) ; } ) ;
39
- assert . throws ( function ( ) { process . cpuUsage ( { user : 'a' } ) ; } ) ;
40
- assert . throws ( function ( ) { process . cpuUsage ( { system : 'b' } ) ; } ) ;
41
- assert . throws ( function ( ) { process . cpuUsage ( { user : null , system : 'c' } ) ; } ) ;
42
- assert . throws ( function ( ) { process . cpuUsage ( { user : 'd' , system : null } ) ; } ) ;
43
- assert . throws ( function ( ) { process . cpuUsage ( { user : - 1 , system : 2 } ) ; } ) ;
44
- assert . throws ( function ( ) { process . cpuUsage ( { user : 3 , system : - 2 } ) ; } ) ;
45
- assert . throws ( function ( ) {
42
+ assert . throws ( ( ) => {
43
+ process . cpuUsage ( 1 ) ;
44
+ } , invalidUserArgument ) ;
45
+
46
+ assert . throws ( ( ) => {
47
+ process . cpuUsage ( { } ) ;
48
+ } , invalidUserArgument ) ;
49
+
50
+ assert . throws ( ( ) => {
51
+ process . cpuUsage ( { user : 'a' } ) ;
52
+ } , invalidUserArgument ) ;
53
+
54
+ assert . throws ( ( ) => {
55
+ process . cpuUsage ( { system : 'b' } ) ;
56
+ } , invalidUserArgument ) ;
57
+
58
+ assert . throws ( ( ) => {
59
+ process . cpuUsage ( { user : null , system : 'c' } ) ;
60
+ } , invalidUserArgument ) ;
61
+
62
+ assert . throws ( ( ) => {
63
+ process . cpuUsage ( { user : 'd' , system : null } ) ;
64
+ } , invalidUserArgument ) ;
65
+
66
+ assert . throws ( ( ) => {
67
+ process . cpuUsage ( { user : - 1 , system : 2 } ) ;
68
+ } , invalidUserArgument ) ;
69
+
70
+ assert . throws ( ( ) => {
71
+ process . cpuUsage ( { user : 3 , system : - 2 } ) ;
72
+ } , invalidSystemArgument ) ;
73
+
74
+ assert . throws ( ( ) => {
46
75
process . cpuUsage ( {
47
76
user : Number . POSITIVE_INFINITY ,
48
77
system : 4
49
78
} ) ;
50
- } ) ;
51
- assert . throws ( function ( ) {
79
+ } , invalidUserArgument ) ;
80
+
81
+ assert . throws ( ( ) => {
52
82
process . cpuUsage ( {
53
83
user : 5 ,
54
84
system : Number . NEGATIVE_INFINITY
55
85
} ) ;
56
- } ) ;
86
+ } , invalidSystemArgument ) ;
57
87
58
88
// Ensure that the return value is the expected shape.
59
89
function validateResult ( result ) {
0 commit comments