@@ -9,8 +9,8 @@ const stringExpected = /string was expected/;
99
1010const testSym = Symbol ( 'test' ) ;
1111
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 ) ;
1414assert . throws ( ( ) => test . asBool ( undefined ) , boolExpected ) ;
1515assert . throws ( ( ) => test . asBool ( null ) , boolExpected ) ;
1616assert . throws ( ( ) => test . asBool ( Number . NaN ) , boolExpected ) ;
@@ -25,14 +25,14 @@ assert.throws(() => test.asBool([]), boolExpected);
2525assert . throws ( ( ) => test . asBool ( testSym ) , boolExpected ) ;
2626
2727[ 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 ) ;
3636 assert . throws ( ( ) => asInt ( undefined ) , numberExpected ) ;
3737 assert . throws ( ( ) => asInt ( null ) , numberExpected ) ;
3838 assert . throws ( ( ) => asInt ( false ) , numberExpected ) ;
@@ -43,18 +43,18 @@ assert.throws(() => test.asBool(testSym), boolExpected);
4343 assert . throws ( ( ) => asInt ( testSym ) , numberExpected ) ;
4444} ) ;
4545
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 ) ;
4949
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 ) ;
5858assert . ok ( Number . isNaN ( test . asDouble ( Number . NaN ) ) ) ;
5959assert . throws ( ( ) => test . asDouble ( undefined ) , numberExpected ) ;
6060assert . throws ( ( ) => test . asDouble ( null ) , numberExpected ) ;
@@ -65,8 +65,8 @@ assert.throws(() => test.asDouble({}), numberExpected);
6565assert . throws ( ( ) => test . asDouble ( [ ] ) , numberExpected ) ;
6666assert . throws ( ( ) => test . asDouble ( testSym ) , numberExpected ) ;
6767
68- assert . strictEqual ( '' , test . asString ( '' ) ) ;
69- assert . strictEqual ( ' test' , test . asString ( 'test' ) ) ;
68+ assert . strictEqual ( test . asString ( '' ) , '' ) ;
69+ assert . strictEqual ( test . asString ( 'test' ) , 'test' ) ;
7070assert . throws ( ( ) => test . asString ( undefined ) , stringExpected ) ;
7171assert . throws ( ( ) => test . asString ( null ) , stringExpected ) ;
7272assert . throws ( ( ) => test . asString ( false ) , stringExpected ) ;
@@ -77,32 +77,32 @@ assert.throws(() => test.asString({}), stringExpected);
7777assert . throws ( ( ) => test . asString ( [ ] ) , stringExpected ) ;
7878assert . throws ( ( ) => test . asString ( testSym ) , stringExpected ) ;
7979
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 ) ;
9494
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 ) ;
106106assert . ok ( Number . isNaN ( test . toNumber ( Number . NaN ) ) ) ;
107107assert . ok ( Number . isNaN ( test . toNumber ( { } ) ) ) ;
108108assert . ok ( Number . isNaN ( test . toNumber ( undefined ) ) ) ;
@@ -124,17 +124,17 @@ assert.notDeepStrictEqual(test.toObject(''), '');
124124assert . notDeepStrictEqual ( test . toObject ( 0 ) , 0 ) ;
125125assert . ok ( ! Number . isNaN ( test . toObject ( Number . NaN ) ) ) ;
126126
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' ) ;
140140assert . throws ( ( ) => test . toString ( testSym ) , TypeError ) ;
0 commit comments