@@ -33,27 +33,57 @@ for (let i = 0; i < 10; i++) {
3333 assert ( diffUsage . system >= 0 ) ;
3434}
3535
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+
3641// 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 ( ( ) => {
4675 process . cpuUsage ( {
4776 user : Number . POSITIVE_INFINITY ,
4877 system : 4
4978 } ) ;
50- } ) ;
51- assert . throws ( function ( ) {
79+ } , invalidUserArgument ) ;
80+
81+ assert . throws ( ( ) => {
5282 process . cpuUsage ( {
5383 user : 5 ,
5484 system : Number . NEGATIVE_INFINITY
5585 } ) ;
56- } ) ;
86+ } , invalidSystemArgument ) ;
5787
5888// Ensure that the return value is the expected shape.
5989function validateResult ( result ) {
0 commit comments