@@ -11,11 +11,11 @@ class RealClass {
11
11
String methodWithObjArgs (RealClass x) => "Real" ;
12
12
// "SpecialArgs" here means type-parameterized args. But that makes for a long
13
13
// method name.
14
- String methodWithSpecialArgs (
14
+ String typeParameterizedFn (
15
15
List <int > w, List <int > x, [List <int > y, List <int > z]) => "Real" ;
16
16
// "SpecialNamedArgs" here means type-parameterized, named args. But that
17
17
// makes for a long method name.
18
- String methodWithSpecialNamedArgs (List <int > w, List <int > x, {List <int > y, List <int > z}) =>
18
+ String typeParameterizedNamedFn (List <int > w, List <int > x, {List <int > y, List <int > z}) =>
19
19
"Real" ;
20
20
String get getter => "Real" ;
21
21
void set setter (String arg) {
@@ -219,93 +219,78 @@ void main() {
219
219
expect (mock.methodWithNormalArgs (43 ), equals ("43" ));
220
220
});
221
221
test ("should mock method with typed arg matchers" , () {
222
- when (mock.methodWithSpecialArgs (
223
- typed/*<List<int>>*/ (any), typed/*<List<int>>*/ (any)))
222
+ when (mock.typeParameterizedFn (typed (any), typed (any)))
224
223
.thenReturn ("A lot!" );
225
- expect (mock.methodWithSpecialArgs ([42 ], [43 ]), equals ("A lot!" ));
226
- expect (mock.methodWithSpecialArgs ([43 ], [44 ]), equals ("A lot!" ));
224
+ expect (mock.typeParameterizedFn ([42 ], [43 ]), equals ("A lot!" ));
225
+ expect (mock.typeParameterizedFn ([43 ], [44 ]), equals ("A lot!" ));
227
226
});
228
227
test ("should mock method with an optional typed arg matcher" , () {
229
- when (mock.methodWithSpecialArgs (
230
- typed/*<List<int>>*/ (any),
231
- typed/*<List<int>>*/ (any),
232
- typed/*<List<int>>*/ (any)))
228
+ when (mock.typeParameterizedFn (typed (any), typed (any), typed (any)))
233
229
.thenReturn ("A lot!" );
234
- expect (mock.methodWithSpecialArgs ([42 ], [43 ], [44 ]), equals ("A lot!" ));
230
+ expect (mock.typeParameterizedFn ([42 ], [43 ], [44 ]), equals ("A lot!" ));
235
231
});
236
232
test ("should mock method with an optional typed arg matcher and an optional real arg" , () {
237
- when (mock.methodWithSpecialArgs (
238
- typed/*<List<int>>*/ (any),
239
- typed/*<List<int>>*/ (any),
240
- [44 ],
241
- typed/*<List<int>>*/ (any)))
233
+ when (mock.typeParameterizedFn (typed (any), typed (any), [44 ], typed (any)))
242
234
.thenReturn ("A lot!" );
243
- expect (mock.methodWithSpecialArgs ([42 ], [43 ], [44 ], [45 ]), equals ("A lot!" ));
235
+ expect (mock.typeParameterizedFn ([42 ], [43 ], [44 ], [45 ]), equals ("A lot!" ));
244
236
});
245
237
test ("should mock method with only some typed arg matchers" , () {
246
- when (mock.methodWithSpecialArgs (
247
- typed/*<List<int>>*/ (any), [43 ], typed/*<List<int>>*/ (any)))
238
+ when (mock.typeParameterizedFn (typed (any), [43 ], typed (any)))
248
239
.thenReturn ("A lot!" );
249
- expect (mock.methodWithSpecialArgs ([42 ], [43 ], [44 ]), equals ("A lot!" ));
250
- when (mock.methodWithSpecialArgs (typed/*<List<int>>*/ (any), [43 ]))
240
+ expect (mock.typeParameterizedFn ([42 ], [43 ], [44 ]), equals ("A lot!" ));
241
+ when (mock.typeParameterizedFn (typed (any), [43 ]))
251
242
.thenReturn ("A bunch!" );
252
- expect (mock.methodWithSpecialArgs ([42 ], [43 ]), equals ("A bunch!" ));
243
+ expect (mock.typeParameterizedFn ([42 ], [43 ]), equals ("A bunch!" ));
253
244
});
254
245
test ("should throw when [typed] used alongside [null]." , () {
255
- expect (() => when (mock.methodWithSpecialArgs (
256
- typed/*<List<int>>*/ (any), null , typed/*<List<int>>*/ (any))),
246
+ expect (() => when (mock.typeParameterizedFn (typed (any), null , typed (any))),
257
247
throwsArgumentError);
258
- expect (() => when (mock.methodWithSpecialArgs (
259
- typed/*<List<int>>*/ (any), typed/*<List<int>>*/ (any), null )),
248
+ expect (() => when (mock.typeParameterizedFn (typed (any), typed (any), null )),
260
249
throwsArgumentError);
261
250
});
262
251
test ("should mock method when [typed] used alongside matched [null]." , () {
263
- when (mock.methodWithSpecialArgs (
264
- typed/*<List<int>>*/ (any), argThat (equals (null )), typed/*<List<int>>*/ (any)))
252
+ when (mock.typeParameterizedFn (
253
+ typed (any), argThat (equals (null )), typed (any)))
265
254
.thenReturn ("A lot!" );
266
- expect (mock.methodWithSpecialArgs ([42 ], null , [44 ]), equals ("A lot!" ));
255
+ expect (mock.typeParameterizedFn ([42 ], null , [44 ]), equals ("A lot!" ));
267
256
});
268
257
test ("should mock method with named, typed arg matcher" , () {
269
- when (mock.methodWithSpecialNamedArgs (
270
- typed/*<List<int>>*/ (any), [43 ], y: typed/*<List<int>>*/ (any, named: "y" )))
258
+ when (mock.typeParameterizedNamedFn (
259
+ typed (any), [43 ], y: typed (any, named: "y" )))
271
260
.thenReturn ("A lot!" );
272
- expect (mock.methodWithSpecialNamedArgs ([42 ], [43 ], y: [44 ]), equals ("A lot!" ));
261
+ expect (mock.typeParameterizedNamedFn ([42 ], [43 ], y: [44 ]), equals ("A lot!" ));
273
262
});
274
263
test ("should mock method with named, typed arg matcher and an arg matcher" , () {
275
264
when (
276
- mock.methodWithSpecialNamedArgs (
277
- typed/*<List<int>>*/ (any),
278
- [43 ],
279
- y: typed/*<List<int>>*/ (any, named: "y" ),
280
- z: argThat (contains (45 ))))
265
+ mock.typeParameterizedNamedFn (
266
+ typed (any), [43 ],
267
+ y: typed (any, named: "y" ), z: argThat (contains (45 ))))
281
268
.thenReturn ("A lot!" );
282
- expect (mock.methodWithSpecialNamedArgs ([42 ], [43 ], y: [44 ], z: [45 ]),
269
+ expect (mock.typeParameterizedNamedFn ([42 ], [43 ], y: [44 ], z: [45 ]),
283
270
equals ("A lot!" ));
284
271
});
285
272
test ("should mock method with named, typed arg matcher and a regular arg" , () {
286
273
when (
287
- mock.methodWithSpecialNamedArgs (
288
- typed/*<List<int>>*/ (any),
289
- [43 ],
290
- y: typed/*<List<int>>*/ (any, named: "y" ),
291
- z: [45 ]))
274
+ mock.typeParameterizedNamedFn (
275
+ typed (any), [43 ],
276
+ y: typed (any, named: "y" ), z: [45 ]))
292
277
.thenReturn ("A lot!" );
293
- expect (mock.methodWithSpecialNamedArgs ([42 ], [43 ], y: [44 ], z: [45 ]),
278
+ expect (mock.typeParameterizedNamedFn ([42 ], [43 ], y: [44 ], z: [45 ]),
294
279
equals ("A lot!" ));
295
280
});
296
281
test ("should throw when [typed] used as a named arg, without `named:`" , () {
297
- expect (() => when (mock.methodWithSpecialNamedArgs (
298
- typed/*<List<int>>*/ (any), [43 ], y: typed/*<List<int>>*/ (any))),
282
+ expect (() => when (mock.typeParameterizedNamedFn (
283
+ typed (any), [43 ], y: typed (any))),
299
284
throwsArgumentError);
300
285
});
301
286
test ("should throw when [typed] used as a positional arg, with `named:`" , () {
302
- expect (() => when (mock.methodWithSpecialNamedArgs (
303
- typed/*<List<int>>*/ (any), typed/*<List<int>>*/ (any, named: "y" ))),
287
+ expect (() => when (mock.typeParameterizedNamedFn (
288
+ typed (any), typed (any, named: "y" ))),
304
289
throwsArgumentError);
305
290
});
306
291
test ("should throw when [typed] used as a named arg, with the wrong `named:`" , () {
307
- expect (() => when (mock.methodWithSpecialNamedArgs (
308
- typed/*<List<int>>*/ (any), [43 ], y: typed/*<List<int>>*/ (any, named: "z" ))),
292
+ expect (() => when (mock.typeParameterizedNamedFn (
293
+ typed (any), [43 ], y: typed (any, named: "z" ))),
309
294
throwsArgumentError);
310
295
});
311
296
});
@@ -424,15 +409,14 @@ void main() {
424
409
verify (mock.setter = "A" );
425
410
});
426
411
test ("should verify method with typed arg matchers" , () {
427
- mock.methodWithSpecialArgs ([42 ], [43 ]);
428
- verify (mock.methodWithSpecialArgs (
429
- typed/*<List<int>>*/ (any), typed/*<List<int>>*/ (any)));
412
+ mock.typeParameterizedFn ([42 ], [43 ]);
413
+ verify (mock.typeParameterizedFn (typed (any), typed (any)));
430
414
});
431
415
test ("should verify method with argument capturer" , () {
432
- mock.methodWithSpecialArgs ([50 ], [17 ]);
433
- mock.methodWithSpecialArgs ([100 ], [17 ]);
434
- expect (verify (mock.methodWithSpecialArgs (
435
- typed/*<List<int>>*/ (captureAny), [17 ])).captured,
416
+ mock.typeParameterizedFn ([50 ], [17 ]);
417
+ mock.typeParameterizedFn ([100 ], [17 ]);
418
+ expect (verify (mock.typeParameterizedFn (
419
+ typed (captureAny), [17 ])).captured,
436
420
equals ([[50 ], [100 ]]));
437
421
});
438
422
});
0 commit comments