2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- import "package:expect/expect.dart" ;
6
-
7
- _expectInErrorMessage (String expected, String actual) {
8
- Expect .isTrue (
9
- actual.contains (expected),
10
- 'Error message should contain "$expected ", '
11
- 'but was ${actual .toString ()}.' );
12
- }
5
+ import "utils.dart" ;
13
6
14
7
class A {
15
8
int x = 42 ;
@@ -33,8 +26,8 @@ void main() {
33
26
instanceOfA ();
34
27
} on NoSuchMethodError catch (error) {
35
28
var message = error.toString ();
36
- _expectInErrorMessage ("NoSuchMethodError: 'call'" , message);
37
- _expectInErrorMessage ("Receiver: Instance of 'A'" , message);
29
+ expectStringContains ("NoSuchMethodError: 'call'" , message);
30
+ expectStringContains ("Receiver: Instance of 'A'" , message);
38
31
}
39
32
40
33
dynamic tearOff = instanceOfA.arity1;
@@ -43,52 +36,52 @@ void main() {
43
36
tearOff (1 , 2 );
44
37
} on NoSuchMethodError catch (error) {
45
38
var message = error.toString ();
46
- _expectInErrorMessage ("NoSuchMethodError: 'bound arity1'" , message);
47
- _expectInErrorMessage ("too many arguments" , message);
39
+ expectStringContains ("NoSuchMethodError: 'bound arity1'" , message);
40
+ expectStringContains ("too many arguments" , message);
48
41
}
49
42
50
43
// Dynamic call of a class method with too few arguments.
51
44
try {
52
45
tearOff ();
53
46
} on NoSuchMethodError catch (error) {
54
47
var message = error.toString ();
55
- _expectInErrorMessage ("NoSuchMethodError: 'bound arity1'" , message);
56
- _expectInErrorMessage ("too few arguments" , message);
48
+ expectStringContains ("NoSuchMethodError: 'bound arity1'" , message);
49
+ expectStringContains ("too few arguments" , message);
57
50
}
58
51
59
52
// Dynamic call of a top level funciton with too many arguments.
60
53
try {
61
54
dynamicFunction (1 , 2 );
62
55
} on NoSuchMethodError catch (error) {
63
56
var message = error.toString ();
64
- _expectInErrorMessage ("NoSuchMethodError: 'arity1'" , message);
65
- _expectInErrorMessage ("too many arguments" , message);
57
+ expectStringContains ("NoSuchMethodError: 'arity1'" , message);
58
+ expectStringContains ("too many arguments" , message);
66
59
}
67
60
68
61
// Dynamic call of a top level funciton with too few arguments.
69
62
try {
70
63
dynamicFunction ();
71
64
} on NoSuchMethodError catch (error) {
72
65
var message = error.toString ();
73
- _expectInErrorMessage ("NoSuchMethodError: 'arity1'" , message);
74
- _expectInErrorMessage ("too few arguments" , message);
66
+ expectStringContains ("NoSuchMethodError: 'arity1'" , message);
67
+ expectStringContains ("too few arguments" , message);
75
68
}
76
69
77
70
// Function.apply() with too many arguments.
78
71
try {
79
72
Function .apply (dynamicFunction, [1 , 2 ]);
80
73
} on NoSuchMethodError catch (error) {
81
74
var message = error.toString ();
82
- _expectInErrorMessage ("NoSuchMethodError: 'arity1'" , message);
83
- _expectInErrorMessage ("too many arguments" , message);
75
+ expectStringContains ("NoSuchMethodError: 'arity1'" , message);
76
+ expectStringContains ("too many arguments" , message);
84
77
}
85
78
86
79
// Function.apply() with too few arguments.
87
80
try {
88
81
Function .apply (dynamicFunction, []);
89
82
} on NoSuchMethodError catch (error) {
90
83
var message = error.toString ();
91
- _expectInErrorMessage ("NoSuchMethodError: 'arity1'" , message);
92
- _expectInErrorMessage ("too few arguments" , message);
84
+ expectStringContains ("NoSuchMethodError: 'arity1'" , message);
85
+ expectStringContains ("too few arguments" , message);
93
86
}
94
87
}
0 commit comments