@@ -50,6 +50,53 @@ tape( 'attached to the main export is a `from` method for creating a complex num
50
50
t . end ( ) ;
51
51
} ) ;
52
52
53
+ tape ( 'the method throws an error if invoked with `this` context which is not a constructor' , function test ( t ) {
54
+ var values ;
55
+ var i ;
56
+
57
+ values = [
58
+ '5' ,
59
+ 5 ,
60
+ NaN ,
61
+ true ,
62
+ false ,
63
+ null ,
64
+ void 0 ,
65
+ { } ,
66
+ [ ]
67
+ ] ;
68
+ for ( i = 0 ; i < values . length ; i ++ ) {
69
+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
70
+ }
71
+ t . end ( ) ;
72
+
73
+ function badValue ( value ) {
74
+ return function badValue ( ) {
75
+ return Complex64Array . from . call ( value , [ ] ) ;
76
+ } ;
77
+ }
78
+ } ) ;
79
+
80
+ tape ( 'the method throws an error if invoked with `this` context which is not a complex array constructor' , function test ( t ) {
81
+ var values ;
82
+ var i ;
83
+
84
+ values = [
85
+ Complex64 ,
86
+ function noop ( ) { }
87
+ ] ;
88
+ for ( i = 0 ; i < values . length ; i ++ ) {
89
+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
90
+ }
91
+ t . end ( ) ;
92
+
93
+ function badValue ( value ) {
94
+ return function badValue ( ) {
95
+ return Complex64Array . from . call ( value , [ ] ) ;
96
+ } ;
97
+ }
98
+ } ) ;
99
+
53
100
tape ( 'the method throws an error if not provided an iterable or array-like object' , function test ( t ) {
54
101
var values ;
55
102
var i ;
@@ -130,7 +177,7 @@ tape( 'the method throws an error if not provided an iterable or array-like obje
130
177
131
178
function badValue ( value ) {
132
179
return function badValue ( ) {
133
- return Complex64Array . from ( value , clbk , Complex64Array ) ;
180
+ return Complex64Array . from ( value , clbk , { } ) ;
134
181
} ;
135
182
}
136
183
@@ -139,6 +186,60 @@ tape( 'the method throws an error if not provided an iterable or array-like obje
139
186
}
140
187
} ) ;
141
188
189
+ tape ( 'the method throws an error if provided a second argument which is not a function' , function test ( t ) {
190
+ var values ;
191
+ var i ;
192
+
193
+ values = [
194
+ '5' ,
195
+ 5 ,
196
+ NaN ,
197
+ true ,
198
+ false ,
199
+ null ,
200
+ void 0 ,
201
+ { } ,
202
+ [ ]
203
+ ] ;
204
+ for ( i = 0 ; i < values . length ; i ++ ) {
205
+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
206
+ }
207
+ t . end ( ) ;
208
+
209
+ function badValue ( value ) {
210
+ return function badValue ( ) {
211
+ return Complex64Array . from ( [ ] , value ) ;
212
+ } ;
213
+ }
214
+ } ) ;
215
+
216
+ tape ( 'the method throws an error if provided a second argument which is not a function (thisArg)' , function test ( t ) {
217
+ var values ;
218
+ var i ;
219
+
220
+ values = [
221
+ '5' ,
222
+ 5 ,
223
+ NaN ,
224
+ true ,
225
+ false ,
226
+ null ,
227
+ void 0 ,
228
+ { } ,
229
+ [ ]
230
+ ] ;
231
+ for ( i = 0 ; i < values . length ; i ++ ) {
232
+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
233
+ }
234
+ t . end ( ) ;
235
+
236
+ function badValue ( value ) {
237
+ return function badValue ( ) {
238
+ return Complex64Array . from ( [ ] , value , { } ) ;
239
+ } ;
240
+ }
241
+ } ) ;
242
+
142
243
tape ( 'the method returns a complex number array' , function test ( t ) {
143
244
var arr ;
144
245
var z ;
0 commit comments