@@ -9,8 +9,8 @@ const stringExpected = /string was expected/;
9
9
10
10
const testSym = Symbol ( 'test' ) ;
11
11
12
- assert . strictEqual ( false , test . asBool ( false ) ) ;
13
- assert . strictEqual ( true , test . asBool ( true ) ) ;
12
+ assert . strictEqual ( test . asBool ( false ) , false ) ;
13
+ assert . strictEqual ( test . asBool ( true ) , true ) ;
14
14
assert . throws ( ( ) => test . asBool ( undefined ) , boolExpected ) ;
15
15
assert . throws ( ( ) => test . asBool ( null ) , boolExpected ) ;
16
16
assert . throws ( ( ) => test . asBool ( Number . NaN ) , boolExpected ) ;
@@ -25,14 +25,14 @@ assert.throws(() => test.asBool([]), boolExpected);
25
25
assert . throws ( ( ) => test . asBool ( testSym ) , boolExpected ) ;
26
26
27
27
[ test . asInt32 , test . asUInt32 , test . asInt64 ] . forEach ( ( asInt ) => {
28
- assert . strictEqual ( 0 , asInt ( 0 ) ) ;
29
- assert . strictEqual ( 1 , asInt ( 1 ) ) ;
30
- assert . strictEqual ( 1 , asInt ( 1.0 ) ) ;
31
- assert . strictEqual ( 1 , asInt ( 1.1 ) ) ;
32
- assert . strictEqual ( 1 , asInt ( 1.9 ) ) ;
33
- assert . strictEqual ( 0 , asInt ( 0.9 ) ) ;
34
- assert . strictEqual ( 999 , asInt ( 999.9 ) ) ;
35
- assert . strictEqual ( 0 , asInt ( Number . NaN ) ) ;
28
+ assert . strictEqual ( asInt ( 0 ) , 0 ) ;
29
+ assert . strictEqual ( asInt ( 1 ) , 1 ) ;
30
+ assert . strictEqual ( asInt ( 1.0 ) , 1 ) ;
31
+ assert . strictEqual ( asInt ( 1.1 ) , 1 ) ;
32
+ assert . strictEqual ( asInt ( 1.9 ) , 1 ) ;
33
+ assert . strictEqual ( asInt ( 0.9 ) , 0 ) ;
34
+ assert . strictEqual ( asInt ( 999.9 ) , 999 ) ;
35
+ assert . strictEqual ( asInt ( Number . NaN ) , 0 ) ;
36
36
assert . throws ( ( ) => asInt ( undefined ) , numberExpected ) ;
37
37
assert . throws ( ( ) => asInt ( null ) , numberExpected ) ;
38
38
assert . throws ( ( ) => asInt ( false ) , numberExpected ) ;
@@ -43,18 +43,18 @@ assert.throws(() => test.asBool(testSym), boolExpected);
43
43
assert . throws ( ( ) => asInt ( testSym ) , numberExpected ) ;
44
44
} ) ;
45
45
46
- assert . strictEqual ( - 1 , test . asInt32 ( - 1 ) ) ;
47
- assert . strictEqual ( - 1 , test . asInt64 ( - 1 ) ) ;
48
- assert . strictEqual ( Math . pow ( 2 , 32 ) - 1 , test . asUInt32 ( - 1 ) ) ;
46
+ assert . strictEqual ( test . asInt32 ( - 1 ) , - 1 ) ;
47
+ assert . strictEqual ( test . asInt64 ( - 1 ) , - 1 ) ;
48
+ assert . strictEqual ( test . asUInt32 ( - 1 ) , Math . pow ( 2 , 32 ) - 1 ) ;
49
49
50
- assert . strictEqual ( 0 , test . asDouble ( 0 ) ) ;
51
- assert . strictEqual ( 1 , test . asDouble ( 1 ) ) ;
52
- assert . strictEqual ( 1.0 , test . asDouble ( 1.0 ) ) ;
53
- assert . strictEqual ( 1.1 , test . asDouble ( 1.1 ) ) ;
54
- assert . strictEqual ( 1.9 , test . asDouble ( 1.9 ) ) ;
55
- assert . strictEqual ( 0.9 , test . asDouble ( 0.9 ) ) ;
56
- assert . strictEqual ( 999.9 , test . asDouble ( 999.9 ) ) ;
57
- assert . strictEqual ( - 1 , test . asDouble ( - 1 ) ) ;
50
+ assert . strictEqual ( test . asDouble ( 0 ) , 0 ) ;
51
+ assert . strictEqual ( test . asDouble ( 1 ) , 1 ) ;
52
+ assert . strictEqual ( test . asDouble ( 1.0 ) , 1.0 ) ;
53
+ assert . strictEqual ( test . asDouble ( 1.1 ) , 1.1 ) ;
54
+ assert . strictEqual ( test . asDouble ( 1.9 ) , 1.9 ) ;
55
+ assert . strictEqual ( test . asDouble ( 0.9 ) , 0.9 ) ;
56
+ assert . strictEqual ( test . asDouble ( 999.9 ) , 999.9 ) ;
57
+ assert . strictEqual ( test . asDouble ( - 1 ) , - 1 ) ;
58
58
assert . ok ( Number . isNaN ( test . asDouble ( Number . NaN ) ) ) ;
59
59
assert . throws ( ( ) => test . asDouble ( undefined ) , numberExpected ) ;
60
60
assert . throws ( ( ) => test . asDouble ( null ) , numberExpected ) ;
@@ -65,8 +65,8 @@ assert.throws(() => test.asDouble({}), numberExpected);
65
65
assert . throws ( ( ) => test . asDouble ( [ ] ) , numberExpected ) ;
66
66
assert . throws ( ( ) => test . asDouble ( testSym ) , numberExpected ) ;
67
67
68
- assert . strictEqual ( '' , test . asString ( '' ) ) ;
69
- assert . strictEqual ( ' test' , test . asString ( 'test' ) ) ;
68
+ assert . strictEqual ( test . asString ( '' ) , '' ) ;
69
+ assert . strictEqual ( test . asString ( 'test' ) , 'test' ) ;
70
70
assert . throws ( ( ) => test . asString ( undefined ) , stringExpected ) ;
71
71
assert . throws ( ( ) => test . asString ( null ) , stringExpected ) ;
72
72
assert . throws ( ( ) => test . asString ( false ) , stringExpected ) ;
@@ -77,32 +77,32 @@ assert.throws(() => test.asString({}), stringExpected);
77
77
assert . throws ( ( ) => test . asString ( [ ] ) , stringExpected ) ;
78
78
assert . throws ( ( ) => test . asString ( testSym ) , stringExpected ) ;
79
79
80
- assert . strictEqual ( true , test . toBool ( true ) ) ;
81
- assert . strictEqual ( true , test . toBool ( 1 ) ) ;
82
- assert . strictEqual ( true , test . toBool ( - 1 ) ) ;
83
- assert . strictEqual ( true , test . toBool ( 'true' ) ) ;
84
- assert . strictEqual ( true , test . toBool ( 'false' ) ) ;
85
- assert . strictEqual ( true , test . toBool ( { } ) ) ;
86
- assert . strictEqual ( true , test . toBool ( [ ] ) ) ;
87
- assert . strictEqual ( true , test . toBool ( testSym ) ) ;
88
- assert . strictEqual ( false , test . toBool ( false ) ) ;
89
- assert . strictEqual ( false , test . toBool ( undefined ) ) ;
90
- assert . strictEqual ( false , test . toBool ( null ) ) ;
91
- assert . strictEqual ( false , test . toBool ( 0 ) ) ;
92
- assert . strictEqual ( false , test . toBool ( Number . NaN ) ) ;
93
- assert . strictEqual ( false , test . toBool ( '' ) ) ;
80
+ assert . strictEqual ( test . toBool ( true ) , true ) ;
81
+ assert . strictEqual ( test . toBool ( 1 ) , true ) ;
82
+ assert . strictEqual ( test . toBool ( - 1 ) , true ) ;
83
+ assert . strictEqual ( test . toBool ( 'true' ) , true ) ;
84
+ assert . strictEqual ( test . toBool ( 'false' ) , true ) ;
85
+ assert . strictEqual ( test . toBool ( { } ) , true ) ;
86
+ assert . strictEqual ( test . toBool ( [ ] ) , true ) ;
87
+ assert . strictEqual ( test . toBool ( testSym ) , true ) ;
88
+ assert . strictEqual ( test . toBool ( false ) , false ) ;
89
+ assert . strictEqual ( test . toBool ( undefined ) , false ) ;
90
+ assert . strictEqual ( test . toBool ( null ) , false ) ;
91
+ assert . strictEqual ( test . toBool ( 0 ) , false ) ;
92
+ assert . strictEqual ( test . toBool ( Number . NaN ) , false ) ;
93
+ assert . strictEqual ( test . toBool ( '' ) , false ) ;
94
94
95
- assert . strictEqual ( 0 , test . toNumber ( 0 ) ) ;
96
- assert . strictEqual ( 1 , test . toNumber ( 1 ) ) ;
97
- assert . strictEqual ( 1.1 , test . toNumber ( 1.1 ) ) ;
98
- assert . strictEqual ( - 1 , test . toNumber ( - 1 ) ) ;
99
- assert . strictEqual ( 0 , test . toNumber ( '0' ) ) ;
100
- assert . strictEqual ( 1 , test . toNumber ( '1' ) ) ;
101
- assert . strictEqual ( 1.1 , test . toNumber ( '1.1' ) ) ;
102
- assert . strictEqual ( 0 , test . toNumber ( [ ] ) ) ;
103
- assert . strictEqual ( 0 , test . toNumber ( false ) ) ;
104
- assert . strictEqual ( 0 , test . toNumber ( null ) ) ;
105
- assert . strictEqual ( 0 , test . toNumber ( '' ) ) ;
95
+ assert . strictEqual ( test . toNumber ( 0 ) , 0 ) ;
96
+ assert . strictEqual ( test . toNumber ( 1 ) , 1 ) ;
97
+ assert . strictEqual ( test . toNumber ( 1.1 ) , 1.1 ) ;
98
+ assert . strictEqual ( test . toNumber ( - 1 ) , - 1 ) ;
99
+ assert . strictEqual ( test . toNumber ( '0' ) , 0 ) ;
100
+ assert . strictEqual ( test . toNumber ( '1' ) , 1 ) ;
101
+ assert . strictEqual ( test . toNumber ( '1.1' ) , 1.1 ) ;
102
+ assert . strictEqual ( test . toNumber ( [ ] ) , 0 ) ;
103
+ assert . strictEqual ( test . toNumber ( false ) , 0 ) ;
104
+ assert . strictEqual ( test . toNumber ( null ) , 0 ) ;
105
+ assert . strictEqual ( test . toNumber ( '' ) , 0 ) ;
106
106
assert . ok ( Number . isNaN ( test . toNumber ( Number . NaN ) ) ) ;
107
107
assert . ok ( Number . isNaN ( test . toNumber ( { } ) ) ) ;
108
108
assert . ok ( Number . isNaN ( test . toNumber ( undefined ) ) ) ;
@@ -124,17 +124,17 @@ assert.notDeepStrictEqual(test.toObject(''), '');
124
124
assert . notDeepStrictEqual ( test . toObject ( 0 ) , 0 ) ;
125
125
assert . ok ( ! Number . isNaN ( test . toObject ( Number . NaN ) ) ) ;
126
126
127
- assert . strictEqual ( '' , test . toString ( '' ) ) ;
128
- assert . strictEqual ( ' test' , test . toString ( 'test' ) ) ;
129
- assert . strictEqual ( 'undefined' , test . toString ( undefined ) ) ;
130
- assert . strictEqual ( 'null' , test . toString ( null ) ) ;
131
- assert . strictEqual ( 'false' , test . toString ( false ) ) ;
132
- assert . strictEqual ( 'true' , test . toString ( true ) ) ;
133
- assert . strictEqual ( '0' , test . toString ( 0 ) ) ;
134
- assert . strictEqual ( '1.1' , test . toString ( 1.1 ) ) ;
135
- assert . strictEqual ( 'NaN' , test . toString ( Number . NaN ) ) ;
136
- assert . strictEqual ( '[object Object]' , test . toString ( { } ) ) ;
137
- assert . strictEqual ( ' test' , test . toString ( { toString : ( ) => 'test' } ) ) ;
138
- assert . strictEqual ( '' , test . toString ( [ ] ) ) ;
139
- assert . strictEqual ( '1,2,3' , test . toString ( [ 1 , 2 , 3 ] ) ) ;
127
+ assert . strictEqual ( test . toString ( '' ) , '' ) ;
128
+ assert . strictEqual ( test . toString ( 'test' ) , 'test' ) ;
129
+ assert . strictEqual ( test . toString ( undefined ) , 'undefined' ) ;
130
+ assert . strictEqual ( test . toString ( null ) , 'null' ) ;
131
+ assert . strictEqual ( test . toString ( false ) , 'false' ) ;
132
+ assert . strictEqual ( test . toString ( true ) , 'true' ) ;
133
+ assert . strictEqual ( test . toString ( 0 ) , '0' ) ;
134
+ assert . strictEqual ( test . toString ( 1.1 ) , '1.1' ) ;
135
+ assert . strictEqual ( test . toString ( Number . NaN ) , 'NaN' ) ;
136
+ assert . strictEqual ( test . toString ( { } ) , '[object Object]' ) ;
137
+ assert . strictEqual ( test . toString ( { toString : ( ) => 'test' } ) , 'test' ) ;
138
+ assert . strictEqual ( test . toString ( [ ] ) , '' ) ;
139
+ assert . strictEqual ( test . toString ( [ 1 , 2 , 3 ] ) , '1,2,3' ) ;
140
140
assert . throws ( ( ) => test . toString ( testSym ) , TypeError ) ;
0 commit comments