Declare locals final where not reassigned (flutter_test) (#8569)
This commit is contained in:
@@ -10,9 +10,9 @@ void main() {
|
||||
expect(false, isTrue);
|
||||
throw 'unexpectedly did not throw';
|
||||
} catch (e, stack) {
|
||||
StringBuffer information = new StringBuffer();
|
||||
final StringBuffer information = new StringBuffer();
|
||||
expect(reportExpectCall(stack, information), 4);
|
||||
List<String> lines = information.toString().split('\n');
|
||||
final List<String> lines = information.toString().split('\n');
|
||||
expect(lines[0], 'This was caught by the test expectation on the following line:');
|
||||
expect(lines[1], matches(r'^ .*stack_manipulation_test.dart line [0-9]+$'));
|
||||
}
|
||||
@@ -20,7 +20,7 @@ void main() {
|
||||
try {
|
||||
throw null;
|
||||
} catch (e, stack) {
|
||||
StringBuffer information = new StringBuffer();
|
||||
final StringBuffer information = new StringBuffer();
|
||||
expect(reportExpectCall(stack, information), 0);
|
||||
expect(information.toString(), '');
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ Future<Null> guardedHelper(WidgetTester tester) {
|
||||
|
||||
void main() {
|
||||
test('TestAsyncUtils - one class', () async {
|
||||
TestAPI testAPI = new TestAPI();
|
||||
final TestAPI testAPI = new TestAPI();
|
||||
Future<Null> f1, f2;
|
||||
f1 = testAPI.testGuard1();
|
||||
try {
|
||||
f2 = testAPI.testGuard2();
|
||||
throw 'unexpectedly did not throw';
|
||||
} on FlutterError catch (e) {
|
||||
List<String> lines = e.message.split('\n');
|
||||
final List<String> lines = e.message.split('\n');
|
||||
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
|
||||
real_test.expect(lines[1], matches(r'The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.'));
|
||||
real_test.expect(lines[2], matches(r'Then, the "testGuard2" method \(also from class TestAPI\) was called from .*test_async_utils_test.dart on line [0-9]+\.'));
|
||||
@@ -60,14 +60,14 @@ void main() {
|
||||
});
|
||||
|
||||
test('TestAsyncUtils - two classes, all callers in superclass', () async {
|
||||
TestAPI testAPI = new TestAPISubclass();
|
||||
final TestAPI testAPI = new TestAPISubclass();
|
||||
Future<Null> f1, f2;
|
||||
f1 = testAPI.testGuard1();
|
||||
try {
|
||||
f2 = testAPI.testGuard2();
|
||||
throw 'unexpectedly did not throw';
|
||||
} on FlutterError catch (e) {
|
||||
List<String> lines = e.message.split('\n');
|
||||
final List<String> lines = e.message.split('\n');
|
||||
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
|
||||
real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
real_test.expect(lines[2], matches(r'^Then, the "testGuard2" method \(also from class TestAPI\) was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
@@ -81,14 +81,14 @@ void main() {
|
||||
});
|
||||
|
||||
test('TestAsyncUtils - two classes, mixed callers', () async {
|
||||
TestAPISubclass testAPI = new TestAPISubclass();
|
||||
final TestAPISubclass testAPI = new TestAPISubclass();
|
||||
Future<Null> f1, f2;
|
||||
f1 = testAPI.testGuard1();
|
||||
try {
|
||||
f2 = testAPI.testGuard3();
|
||||
throw 'unexpectedly did not throw';
|
||||
} on FlutterError catch (e) {
|
||||
List<String> lines = e.message.split('\n');
|
||||
final List<String> lines = e.message.split('\n');
|
||||
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
|
||||
real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
real_test.expect(lines[2], matches(r'^Then, the "testGuard3" method from class TestAPISubclass was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
@@ -102,14 +102,14 @@ void main() {
|
||||
});
|
||||
|
||||
test('TestAsyncUtils - expect() catches pending async work', () async {
|
||||
TestAPI testAPI = new TestAPISubclass();
|
||||
final TestAPI testAPI = new TestAPISubclass();
|
||||
Future<Null> f1;
|
||||
f1 = testAPI.testGuard1();
|
||||
try {
|
||||
flutter_test.expect(0, 0);
|
||||
throw 'unexpectedly did not throw';
|
||||
} on FlutterError catch (e) {
|
||||
List<String> lines = e.message.split('\n');
|
||||
final List<String> lines = e.message.split('\n');
|
||||
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
|
||||
real_test.expect(lines[1], matches(r'^The guarded method "testGuard1" from class TestAPI was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
real_test.expect(lines[2], matches(r'^Then, the "expect" function was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
@@ -129,7 +129,7 @@ void main() {
|
||||
f2 = tester.pump();
|
||||
throw 'unexpectedly did not throw';
|
||||
} on FlutterError catch (e) {
|
||||
List<String> lines = e.message.split('\n');
|
||||
final List<String> lines = e.message.split('\n');
|
||||
real_test.expect(lines[0], 'Guarded function conflict. You must use "await" with all Future-returning test APIs.');
|
||||
real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
real_test.expect(lines[2], matches(r'^Then, it was called from .*test_async_utils_test.dart on line [0-9]+\.$'));
|
||||
@@ -149,7 +149,7 @@ void main() {
|
||||
TestAsyncUtils.verifyAllScopesClosed();
|
||||
throw 'unexpectedly did not throw';
|
||||
} on FlutterError catch (e) {
|
||||
List<String> lines = e.message.split('\n');
|
||||
final List<String> lines = e.message.split('\n');
|
||||
real_test.expect(lines[0], 'Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.');
|
||||
real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+, but never completed before its parent scope closed\.$'));
|
||||
real_test.expect(lines[2], matches(r'^The guarded method "pump" from class AutomatedTestWidgetsFlutterBinding was called from [^ ]+ on line [0-9]+, but never completed before its parent scope closed\.'));
|
||||
@@ -165,7 +165,7 @@ void main() {
|
||||
TestAsyncUtils.verifyAllScopesClosed();
|
||||
throw 'unexpectedly did not throw';
|
||||
} on FlutterError catch (e) {
|
||||
List<String> lines = e.message.split('\n');
|
||||
final List<String> lines = e.message.split('\n');
|
||||
real_test.expect(lines[0], 'Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.');
|
||||
real_test.expect(lines[1], matches(r'^The guarded method "pump" from class WidgetTester was called from .*test_async_utils_test.dart on line [0-9]+, but never completed before its parent scope closed\.$'));
|
||||
real_test.expect(lines[2], matches(r'^The guarded method "pump" from class AutomatedTestWidgetsFlutterBinding was called from [^ ]+ on line [0-9]+, but never completed before its parent scope closed\.'));
|
||||
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
}
|
||||
|
||||
expect(failure, isNotNull);
|
||||
String message = failure.message;
|
||||
final String message = failure.message;
|
||||
expect(message, contains('Expected: exactly one matching node in the widget tree\n'));
|
||||
expect(message, contains('Actual: ?:<zero widgets with text "foo">\n'));
|
||||
expect(message, contains('Which: means none were found but one was expected\n'));
|
||||
@@ -44,7 +44,7 @@ void main() {
|
||||
}
|
||||
|
||||
expect(failure, isNotNull);
|
||||
String message = failure.message;
|
||||
final String message = failure.message;
|
||||
|
||||
expect(message, contains('Expected: no matching nodes in the widget tree\n'));
|
||||
expect(message, contains('Actual: ?:<exactly one widget with text "foo": Text("foo")>\n'));
|
||||
@@ -62,7 +62,7 @@ void main() {
|
||||
}
|
||||
|
||||
expect(failure, isNotNull);
|
||||
String message = failure.message;
|
||||
final String message = failure.message;
|
||||
|
||||
expect(message, contains('Expected: no matching nodes in the widget tree\n'));
|
||||
expect(message, contains('Actual: ?:<exactly one widget with text "foo" (ignoring offstage widgets): Text("foo")>\n'));
|
||||
@@ -73,7 +73,7 @@ void main() {
|
||||
await tester.pumpWidget(new Text('foo'));
|
||||
int count;
|
||||
|
||||
AnimationController test = new AnimationController(
|
||||
final AnimationController test = new AnimationController(
|
||||
duration: const Duration(milliseconds: 5100),
|
||||
vsync: tester,
|
||||
);
|
||||
@@ -108,7 +108,7 @@ void main() {
|
||||
testWidgets('fails with a custom description in the message', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(new Text('foo'));
|
||||
|
||||
String customDescription = 'custom description';
|
||||
final String customDescription = 'custom description';
|
||||
TestFailure failure;
|
||||
try {
|
||||
expect(find.byElementPredicate((_) => false, description: customDescription), findsOneWidget);
|
||||
@@ -125,7 +125,7 @@ void main() {
|
||||
testWidgets('fails with a custom description in the message', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(new Text('foo'));
|
||||
|
||||
String customDescription = 'custom description';
|
||||
final String customDescription = 'custom description';
|
||||
TestFailure failure;
|
||||
try {
|
||||
expect(find.byWidgetPredicate((_) => false, description: customDescription), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user