From c5a3ee7f315c655de6d058cad20b49de817627fd Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Thu, 22 Apr 2021 22:33:59 +0200 Subject: [PATCH] add trailing commas in flutter/test/{foundation,gestures} (#80926) --- .../test/foundation/assertions_test.dart | 13 +- .../test/foundation/change_notifier_test.dart | 58 +++---- .../test/foundation/collections_test.dart | 7 +- .../foundation/consolidate_response_test.dart | 6 +- .../test/foundation/diagnostics_test.dart | 152 +++++++++--------- .../test/foundation/error_reporting_test.dart | 13 +- .../foundation/service_extensions_test.dart | 8 +- .../test/gestures/gesture_binding_test.dart | 21 +-- 8 files changed, 137 insertions(+), 141 deletions(-) diff --git a/packages/flutter/test/foundation/assertions_test.dart b/packages/flutter/test/foundation/assertions_test.dart index e5f9b9ab25..88e1d1da46 100644 --- a/packages/flutter/test/foundation/assertions_test.dart +++ b/packages/flutter/test/foundation/assertions_test.dart @@ -71,7 +71,7 @@ void main() { 'The null value was thrown CONTEXTING.\n' '\n' 'INFO\n' - '═════════════════════════════════════════════════════════════════\n' + '═════════════════════════════════════════════════════════════════\n', ); expect( FlutterErrorDetails( @@ -116,7 +116,7 @@ void main() { FlutterErrorDetails(exception: NullThrownError()).toString(), '══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞══════════════════════\n' 'The null value was thrown.\n' - '═════════════════════════════════════════════════════════════════\n' + '═════════════════════════════════════════════════════════════════\n', ); }); @@ -138,7 +138,7 @@ void main() { FlutterError error = FlutterError( 'My Error Summary.\n' 'My first description.\n' - 'My second description.' + 'My second description.', ); expect(error.diagnostics.length, equals(3)); expect(error.diagnostics[0].level, DiagnosticLevel.summary); @@ -159,7 +159,7 @@ void main() { 'My Error Summary.\n' 'My first description.\n' 'My second description.\n' - '\n' + '\n', ); expect(error.diagnostics.length, equals(5)); @@ -185,7 +185,7 @@ void main() { 'My Error Summary.\n' 'My first description.\n' '\n' - 'My second description.' + 'My second description.', ); expect(error.diagnostics.length, equals(4)); expect(error.diagnostics[0].level, DiagnosticLevel.summary); @@ -238,7 +238,8 @@ void main() { final AssertionError error; try { throw FlutterError.fromParts([ - (ErrorDescription('Error description without a summary'))]); + ErrorDescription('Error description without a summary'), + ]); } on AssertionError catch (e) { error = e; } diff --git a/packages/flutter/test/foundation/change_notifier_test.dart b/packages/flutter/test/foundation/change_notifier_test.dart index 05b406c486..bca63e324e 100644 --- a/packages/flutter/test/foundation/change_notifier_test.dart +++ b/packages/flutter/test/foundation/change_notifier_test.dart @@ -172,8 +172,7 @@ void main() { log.clear(); }); - test('During notifyListeners, a listener was added and removed immediately', - () { + test('During notifyListeners, a listener was added and removed immediately', () { final TestNotifier source = TestNotifier(); final List log = []; @@ -200,32 +199,32 @@ void main() { }); test( - 'If a listener in the middle of the list of listeners removes itself, ' - 'notifyListeners still notifies all listeners', () { - final TestNotifier source = TestNotifier(); - final List log = []; + 'If a listener in the middle of the list of listeners removes itself, ' + 'notifyListeners still notifies all listeners', + () { + final TestNotifier source = TestNotifier(); + final List log = []; - void selfRemovingListener() { - log.add('selfRemovingListener'); - source.removeListener(selfRemovingListener); - } + void selfRemovingListener() { + log.add('selfRemovingListener'); + source.removeListener(selfRemovingListener); + } - void listener1() { - log.add('listener1'); - } + void listener1() { + log.add('listener1'); + } - source.addListener(listener1); - source.addListener(selfRemovingListener); - source.addListener(listener1); + source.addListener(listener1); + source.addListener(selfRemovingListener); + source.addListener(listener1); - source.notify(); + source.notify(); - expect(log, ['listener1', 'selfRemovingListener', 'listener1']); - }); + expect(log, ['listener1', 'selfRemovingListener', 'listener1']); + }, + ); - test( - 'If the first listener removes itself, notifyListeners still notify all listeners', - () { + test('If the first listener removes itself, notifyListeners still notify all listeners', () { final TestNotifier source = TestNotifier(); final List log = []; @@ -457,11 +456,14 @@ void main() { expect(error, isNotNull); expect(error!, isFlutterError); expect( - error.toStringDeep(), - equalsIgnoringHashCodes('FlutterError\n' - ' A TestNotifier was used after being disposed.\n' - ' Once you have called dispose() on a TestNotifier, it can no\n' - ' longer be used.\n')); + error.toStringDeep(), + equalsIgnoringHashCodes( + 'FlutterError\n' + ' A TestNotifier was used after being disposed.\n' + ' Once you have called dispose() on a TestNotifier, it can no\n' + ' longer be used.\n', + ), + ); }); test('notifyListener can be called recursively', () { @@ -524,7 +526,7 @@ void main() { 8, 9, 10, - 11 + 11, ]; final List expectedLog = remainingListenerIndexes.map((int i) => 'listener$i').toList(); diff --git a/packages/flutter/test/foundation/collections_test.dart b/packages/flutter/test/foundation/collections_test.dart index ee7ce63fe3..7ca6a90be3 100644 --- a/packages/flutter/test/foundation/collections_test.dart +++ b/packages/flutter/test/foundation/collections_test.dart @@ -82,7 +82,9 @@ void main() { // collisions are guaranteed. These should be sorted so that the 'order' // part of the objects are still in order. final List list = List.generate( - size, (int i) => OrderedComparable(random.nextInt(size >> 2), i)); + size, + (int i) => OrderedComparable(random.nextInt(size >> 2), i), + ); mergeSort(list); OrderedComparable prev = list[0]; for (int i = 1; i < size; i++) { @@ -121,8 +123,7 @@ void main() { test('MergeSortSpecialCases', () { for (final int size in [511, 512, 513]) { // All equal. - final List list = List.generate( - size, (int i) => OrderedComparable(0, i)); + final List list = List.generate(size, (int i) => OrderedComparable(0, i)); mergeSort(list); for (int i = 0; i < size; i++) { expect(list[i].order, equals(i)); diff --git a/packages/flutter/test/foundation/consolidate_response_test.dart b/packages/flutter/test/foundation/consolidate_response_test.dart index f9a3a78633..60f5af8d7b 100644 --- a/packages/flutter/test/foundation/consolidate_response_test.dart +++ b/packages/flutter/test/foundation/consolidate_response_test.dart @@ -166,16 +166,14 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse { @override StreamSubscription> listen(void Function(List event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) { if (error != null) { - return Stream>.fromFuture( - Future>.error(error as Object)).listen( + return Stream>.fromFuture(Future>.error(error as Object)).listen( onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError, ); } - return Stream>.fromIterable( - >[chunkOne, chunkTwo]).listen( + return Stream>.fromIterable(>[chunkOne, chunkTwo]).listen( onData, onDone: onDone, onError: onError, diff --git a/packages/flutter/test/foundation/diagnostics_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart index e1f37e7df0..4b5194a8f3 100644 --- a/packages/flutter/test/foundation/diagnostics_test.dart +++ b/packages/flutter/test/foundation/diagnostics_test.dart @@ -905,8 +905,8 @@ void main() { throwsA(isAssertionError.having( (AssertionError e) => e.message, 'message', - 'The provided object "Hello World" is not an enum.'), - ), + 'The provided object "Hello World" is not an enum.', + )), ); }); @@ -1882,7 +1882,7 @@ void main() { final StackTrace stack = StackTrace.fromString( '#0 someMethod (file:///diagnostics_test.dart:42:19)\n' '#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n' - '#2 someMethod3 (file:///foo.dart:4:1)\n' + '#2 someMethod3 (file:///foo.dart:4:1)\n', ); expect( @@ -1891,7 +1891,7 @@ void main() { 'Stack trace:\n' '#0 someMethod (file:///diagnostics_test.dart:42:19)\n' '#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n' - '#2 someMethod3 (file:///foo.dart:4:1)\n' + '#2 someMethod3 (file:///foo.dart:4:1)\n', ), ); @@ -1901,7 +1901,7 @@ void main() { '-- callback 2 --\n' '#0 someMethod (file:///diagnostics_test.dart:42:19)\n' '#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n' - '#2 someMethod3 (file:///foo.dart:4:1)\n' + '#2 someMethod3 (file:///foo.dart:4:1)\n', ), ); }); @@ -2164,83 +2164,83 @@ void main() { ' [1.0, 0.0, 0.0, 1.0]\n' ' --- example property at max length --\n' ' diagnosis: insufficient data to draw\n' - ' conclusion (less than five repaints)\n' + ' conclusion (less than five repaints)\n', ), ); // This case matches the styles that should generally be used for error // messages expect( - renderer.render(createTreeWithWrappingNodes( - rootStyle: DiagnosticsTreeStyle.error, - propertyStyle: DiagnosticsTreeStyle.errorProperty, - )), - equalsIgnoringHashCodes( - '══╡ TESTTREE#00000 ╞════════════════════\n' - '--- example property at max length --\n' - 'This is a very long message that must\n' - 'wrap as it cannot fit on one line. This\n' - 'is a very long message that must wrap as\n' - 'it cannot fit on one line. This is a\n' - 'very long message that must wrap as it\n' - 'cannot fit on one line.\n' - '--- example property at max length --\n' - 'Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap.\n' - '--- example property at max length --\n' - 'This property has a very long property\n' - 'name that will be allowed to wrap unlike\n' - 'most property names. This property has a\n' - 'very long property name that will be\n' - 'allowed to wrap unlike most property\n' - 'names:\n' - ' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n' - 'This property has a very long property\n' - 'name that will be allowed to wrap unlike\n' - 'most property names. This property has a\n' - 'very long property name that will be\n' - 'allowed to wrap unlike most property\n' - 'names:\n' - ' https://goo.gl/\n' - 'Click on the following url:\n' - ' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n' - 'Click on the following url\n' - ' https://goo.gl/\n' - '--- example property at max length --\n' - 'multi-line value:\n' - ' [1.0, 0.0, 0.0, 0.0]\n' - ' [1.0, 1.0, 0.0, 0.0]\n' - ' [1.0, 0.0, 1.0, 0.0]\n' - ' [1.0, 0.0, 0.0, 1.0]\n' - '--- example property at max length --\n' - 'This property has a very long property\n' - 'name that will be allowed to wrap unlike\n' - 'most property names. This property has a\n' - 'very long property name that will be\n' - 'allowed to wrap unlike most property\n' - 'names:\n' - ' This is a very long message that must\n' - ' wrap as it cannot fit on one line.\n' - ' This is a very long message that must\n' - ' wrap as it cannot fit on one line.\n' - ' This is a very long message that must\n' - ' wrap as it cannot fit on one line.\n' - '--- example property at max length --\n' - 'This property has a very long property\n' - 'name that will be allowed to wrap unlike\n' - 'most property names. This property has a\n' - 'very long property name that will be\n' - 'allowed to wrap unlike most property\n' - 'names:\n' - ' [1.0, 0.0, 0.0, 0.0]\n' - ' [1.0, 1.0, 0.0, 0.0]\n' - ' [1.0, 0.0, 1.0, 0.0]\n' - ' [1.0, 0.0, 0.0, 1.0]\n' - '--- example property at max length --\n' - 'diagnosis:\n' - ' insufficient data to draw conclusion\n' - ' (less than five repaints)\n' - '════════════════════════════════════════\n' - ), + renderer.render(createTreeWithWrappingNodes( + rootStyle: DiagnosticsTreeStyle.error, + propertyStyle: DiagnosticsTreeStyle.errorProperty, + )), + equalsIgnoringHashCodes( + '══╡ TESTTREE#00000 ╞════════════════════\n' + '--- example property at max length --\n' + 'This is a very long message that must\n' + 'wrap as it cannot fit on one line. This\n' + 'is a very long message that must wrap as\n' + 'it cannot fit on one line. This is a\n' + 'very long message that must wrap as it\n' + 'cannot fit on one line.\n' + '--- example property at max length --\n' + 'Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap.\n' + '--- example property at max length --\n' + 'This property has a very long property\n' + 'name that will be allowed to wrap unlike\n' + 'most property names. This property has a\n' + 'very long property name that will be\n' + 'allowed to wrap unlike most property\n' + 'names:\n' + ' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n' + 'This property has a very long property\n' + 'name that will be allowed to wrap unlike\n' + 'most property names. This property has a\n' + 'very long property name that will be\n' + 'allowed to wrap unlike most property\n' + 'names:\n' + ' https://goo.gl/\n' + 'Click on the following url:\n' + ' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n' + 'Click on the following url\n' + ' https://goo.gl/\n' + '--- example property at max length --\n' + 'multi-line value:\n' + ' [1.0, 0.0, 0.0, 0.0]\n' + ' [1.0, 1.0, 0.0, 0.0]\n' + ' [1.0, 0.0, 1.0, 0.0]\n' + ' [1.0, 0.0, 0.0, 1.0]\n' + '--- example property at max length --\n' + 'This property has a very long property\n' + 'name that will be allowed to wrap unlike\n' + 'most property names. This property has a\n' + 'very long property name that will be\n' + 'allowed to wrap unlike most property\n' + 'names:\n' + ' This is a very long message that must\n' + ' wrap as it cannot fit on one line.\n' + ' This is a very long message that must\n' + ' wrap as it cannot fit on one line.\n' + ' This is a very long message that must\n' + ' wrap as it cannot fit on one line.\n' + '--- example property at max length --\n' + 'This property has a very long property\n' + 'name that will be allowed to wrap unlike\n' + 'most property names. This property has a\n' + 'very long property name that will be\n' + 'allowed to wrap unlike most property\n' + 'names:\n' + ' [1.0, 0.0, 0.0, 0.0]\n' + ' [1.0, 1.0, 0.0, 0.0]\n' + ' [1.0, 0.0, 1.0, 0.0]\n' + ' [1.0, 0.0, 0.0, 1.0]\n' + '--- example property at max length --\n' + 'diagnosis:\n' + ' insufficient data to draw conclusion\n' + ' (less than five repaints)\n' + '════════════════════════════════════════\n', + ), ); }); diff --git a/packages/flutter/test/foundation/error_reporting_test.dart b/packages/flutter/test/foundation/error_reporting_test.dart index a66f918ec9..3a9488c868 100644 --- a/packages/flutter/test/foundation/error_reporting_test.dart +++ b/packages/flutter/test/foundation/error_reporting_test.dart @@ -78,7 +78,7 @@ Future main() async { r'#0 getSampleStack\. \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n' r'#2 getSampleStack \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n' r'#3 main \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n' - r'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main() + r'(.+\n)+', // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main() )); console.clear(); FlutterError.dumpErrorToConsole(FlutterErrorDetails( @@ -145,7 +145,7 @@ Future main() async { r'#0 getSampleStack\. \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n' r'#2 getSampleStack \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n' r'#3 main \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n' - r'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main() + r'(.+\n)+', // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main() )); console.clear(); FlutterError.dumpErrorToConsole(FlutterErrorDetails( @@ -158,8 +158,7 @@ Future main() async { test('Error reporting - NoSuchMethodError', () async { expect(console, isEmpty); - final Object exception = NoSuchMethodError.withInvocation(5, - Invocation.method(#foo, [2, 4])); + final Object exception = NoSuchMethodError.withInvocation(5, Invocation.method(#foo, [2, 4])); FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: exception, @@ -174,8 +173,10 @@ Future main() async { FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: exception, )); - expect(console.join('\n'), - 'Another exception was thrown: NoSuchMethodError: int has no foo method accepting arguments (_, _)'); + expect( + console.join('\n'), + 'Another exception was thrown: NoSuchMethodError: int has no foo method accepting arguments (_, _)', + ); console.clear(); FlutterError.resetErrorCount(); }); diff --git a/packages/flutter/test/foundation/service_extensions_test.dart b/packages/flutter/test/foundation/service_extensions_test.dart index 563a6d4131..dd7ae1a4bd 100644 --- a/packages/flutter/test/foundation/service_extensions_test.dart +++ b/packages/flutter/test/foundation/service_extensions_test.dart @@ -245,7 +245,7 @@ void main() { r' window size: Size\(2400\.0, 1800\.0\) \(in physical pixels\)\n' r' device pixel ratio: 3\.0 \(physical pixels per logical pixel\)\n' r' configuration: Size\(800\.0, 600\.0\) at 3\.0x \(in logical pixels\)\n' - r'$' + r'$', ), }); }); @@ -267,7 +267,7 @@ void main() { r' \[1] 0\.0,3\.0,0\.0,0\.0\n' r' \[2] 0\.0,0\.0,1\.0,0\.0\n' r' \[3] 0\.0,0\.0,0\.0,1\.0\n' - r'$' + r'$', ), }); }); @@ -277,7 +277,7 @@ void main() { final Map result = await binding.testExtension('debugDumpSemanticsTreeInTraversalOrder', {}); expect(result, { - 'data': 'Semantics not collected.' + 'data': 'Semantics not collected.', }); }); @@ -286,7 +286,7 @@ void main() { final Map result = await binding.testExtension('debugDumpSemanticsTreeInInverseHitTestOrder', {}); expect(result, { - 'data': 'Semantics not collected.' + 'data': 'Semantics not collected.', }); }); diff --git a/packages/flutter/test/gestures/gesture_binding_test.dart b/packages/flutter/test/gestures/gesture_binding_test.dart index c7330d493b..c8143834a1 100644 --- a/packages/flutter/test/gestures/gesture_binding_test.dart +++ b/packages/flutter/test/gestures/gesture_binding_test.dart @@ -92,8 +92,7 @@ void main() { expect(events[0], isA()); expect(events[1], isA()); expect(events[2], isA()); - expect(pointerRouterEvents.length, 6, - reason: 'pointerRouterEvents contains: $pointerRouterEvents'); + expect(pointerRouterEvents.length, 6, reason: 'pointerRouterEvents contains: $pointerRouterEvents'); expect(pointerRouterEvents[0], isA()); expect(pointerRouterEvents[1], isA()); expect(pointerRouterEvents[2], isA()); @@ -151,8 +150,7 @@ void main() { ], ); - final List events = PointerEventConverter.expand( - packet.data, ui.window.devicePixelRatio).toList(); + final List events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList(); expect(events.length, 5); expect(events[0], isA()); @@ -170,8 +168,7 @@ void main() { ], ); - final List events = PointerEventConverter.expand( - packet.data, ui.window.devicePixelRatio).toList(); + final List events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList(); expect(events.length, 2); expect(events[0], isA()); @@ -191,8 +188,7 @@ void main() { ], ); - final List events = PointerEventConverter.expand( - packet.data, ui.window.devicePixelRatio).toList(); + final List events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList(); expect(events.length, 5); expect(events[0], isA()); @@ -224,8 +220,7 @@ void main() { ], ); - final List events = PointerEventConverter.expand( - packet.data, ui.window.devicePixelRatio).toList(); + final List events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList(); expect(events.length, 5); expect(events[0], isA()); @@ -254,8 +249,7 @@ void main() { ], ); - final List events = PointerEventConverter.expand( - packet.data, ui.window.devicePixelRatio).toList(); + final List events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList(); expect(events.length, 5); expect(events[0], isA()); @@ -285,8 +279,7 @@ void main() { ], ); - final List events = PointerEventConverter.expand( - packet.data, ui.window.devicePixelRatio).toList(); + final List events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList(); expect(events.length, 5); expect(events[0], isA());