Unverified Commit 5865c14d authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

add trailing commas in flutter/test/animation (#80852)

parent d9638d25
...@@ -385,7 +385,7 @@ void main() { ...@@ -385,7 +385,7 @@ void main() {
' A given AnimationController cannot be disposed more than once.\n' ' A given AnimationController cannot be disposed more than once.\n'
' The following AnimationController object was disposed multiple\n' ' The following AnimationController object was disposed multiple\n'
' times:\n' ' times:\n'
' AnimationController#00000(⏮ 0.000; paused; DISPOSED)\n' ' AnimationController#00000(⏮ 0.000; paused; DISPOSED)\n',
), ),
); );
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
...@@ -966,41 +966,44 @@ void main() { ...@@ -966,41 +966,44 @@ void main() {
expect( expect(
error.toStringDeep(), error.toStringDeep(),
'FlutterError\n' 'FlutterError\n'
' AnimationController.forward() called with no default duration.\n' ' AnimationController.forward() called with no default duration.\n'
' The "duration" property should be set, either in the constructor\n' ' The "duration" property should be set, either in the constructor\n'
' or later, before calling the forward() function.\n' ' or later, before calling the forward() function.\n',
); );
controller.dispose(); controller.dispose();
}); });
test('AnimationController animateTo() will throw an error if there is no explicit duration ' test(
'and default duration', () { 'AnimationController animateTo() will throw an error if there is no explicit duration '
final AnimationController controller = AnimationController( 'and default duration',
vsync: const TestVSync(), () {
); final AnimationController controller = AnimationController(
vsync: const TestVSync(),
late FlutterError error; );
try {
controller.animateTo(0.8); late FlutterError error;
} on FlutterError catch (e) { try {
error = e; controller.animateTo(0.8);
} } on FlutterError catch (e) {
error = e;
expect(error, isNotNull); }
expect(
error.toStringDeep(), expect(error, isNotNull);
'FlutterError\n' expect(
error.toStringDeep(),
'FlutterError\n'
' AnimationController.animateTo() called with no explicit duration\n' ' AnimationController.animateTo() called with no explicit duration\n'
' and no default duration.\n' ' and no default duration.\n'
' Either the "duration" argument to the animateTo() method should\n' ' Either the "duration" argument to the animateTo() method should\n'
' be provided, or the "duration" property should be set, either in\n' ' be provided, or the "duration" property should be set, either in\n'
' the constructor or later, before calling the animateTo()\n' ' the constructor or later, before calling the animateTo()\n'
' function.\n' ' function.\n',
); );
controller.dispose(); controller.dispose();
}); },
);
test('AnimationController reverse() will throw an error if there is no default duration or reverseDuration', () { test('AnimationController reverse() will throw an error if there is no default duration or reverseDuration', () {
final AnimationController controller = AnimationController( final AnimationController controller = AnimationController(
...@@ -1018,43 +1021,46 @@ void main() { ...@@ -1018,43 +1021,46 @@ void main() {
expect( expect(
error.toStringDeep(), error.toStringDeep(),
'FlutterError\n' 'FlutterError\n'
' AnimationController.reverse() called with no default duration or\n' ' AnimationController.reverse() called with no default duration or\n'
' reverseDuration.\n' ' reverseDuration.\n'
' The "duration" or "reverseDuration" property should be set,\n' ' The "duration" or "reverseDuration" property should be set,\n'
' either in the constructor or later, before calling the reverse()\n' ' either in the constructor or later, before calling the reverse()\n'
' function.\n' ' function.\n',
); );
controller.dispose(); controller.dispose();
}); });
test('AnimationController animateBack() will throw an error if there is no explicit duration and ' test(
'no default duration or reverseDuration', () { 'AnimationController animateBack() will throw an error if there is no explicit duration and '
final AnimationController controller = AnimationController( 'no default duration or reverseDuration',
vsync: const TestVSync(), () {
); final AnimationController controller = AnimationController(
vsync: const TestVSync(),
late FlutterError error; );
try {
controller.animateBack(0.8); late FlutterError error;
} on FlutterError catch (e) { try {
error = e; controller.animateBack(0.8);
} } on FlutterError catch (e) {
error = e;
expect(error, isNotNull); }
expect(
error.toStringDeep(), expect(error, isNotNull);
'FlutterError\n' expect(
error.toStringDeep(),
'FlutterError\n'
' AnimationController.animateBack() called with no explicit\n' ' AnimationController.animateBack() called with no explicit\n'
' duration and no default duration or reverseDuration.\n' ' duration and no default duration or reverseDuration.\n'
' Either the "duration" argument to the animateBack() method should\n' ' Either the "duration" argument to the animateBack() method should\n'
' be provided, or the "duration" or "reverseDuration" property\n' ' be provided, or the "duration" or "reverseDuration" property\n'
' should be set, either in the constructor or later, before calling\n' ' should be set, either in the constructor or later, before calling\n'
' the animateBack() function.\n' ' the animateBack() function.\n',
); );
controller.dispose(); controller.dispose();
}); },
);
}); });
} }
......
...@@ -243,19 +243,18 @@ void main() { ...@@ -243,19 +243,18 @@ void main() {
error = e; error = e;
} }
expect(error, isNotNull); expect(error, isNotNull);
expect(error!.toStringDeep(), matches( expect(
error!.toStringDeep(),
// RegExp matcher is required here due to flutter web and flutter mobile generating // RegExp matcher is required here due to flutter web and flutter mobile generating
// slightly different floating point numbers // slightly different floating point numbers
// in Flutter web 0.0 sometimes just appears as 0. or 0 // in Flutter web 0.0 sometimes just appears as 0. or 0
RegExp(r''' matches(RegExp(r'''
FlutterError FlutterError
Invalid curve endpoint at \d+(\.\d*)?\. Invalid curve endpoint at \d+(\.\d*)?\.
Curves must map 0\.0 to near zero and 1\.0 to near one but Curves must map 0\.0 to near zero and 1\.0 to near one but
BogusCurve mapped \d+(\.\d*)? to \d+(\.\d*)?, which is near \d+(\.\d*)?\. BogusCurve mapped \d+(\.\d*)? to \d+(\.\d*)?, which is near \d+(\.\d*)?\.
''', ''', multiLine: true)),
multiLine: true );
),
));
}); });
test('CurvedAnimation running with different forward and reverse durations.', () { test('CurvedAnimation running with different forward and reverse durations.', () {
......
...@@ -398,14 +398,15 @@ void main() { ...@@ -398,14 +398,15 @@ void main() {
// Monotonically increasing in X. // Monotonically increasing in X.
expect( expect(
CatmullRomCurve.validateControlPoints( CatmullRomCurve.validateControlPoints(
const <Offset>[ const <Offset>[
Offset(0.2, 0.25), Offset(0.2, 0.25),
Offset(0.01, 0.25), Offset(0.01, 0.25),
], ],
tension: 0.0, tension: 0.0,
), ),
isFalse); isFalse,
);
expect(() { expect(() {
CatmullRomCurve( CatmullRomCurve(
const <Offset>[ const <Offset>[
...@@ -418,14 +419,15 @@ void main() { ...@@ -418,14 +419,15 @@ void main() {
// X within range (0.0, 1.0). // X within range (0.0, 1.0).
expect( expect(
CatmullRomCurve.validateControlPoints( CatmullRomCurve.validateControlPoints(
const <Offset>[ const <Offset>[
Offset(0.2, 0.25), Offset(0.2, 0.25),
Offset(1.01, 0.25), Offset(1.01, 0.25),
], ],
tension: 0.0, tension: 0.0,
), ),
isFalse); isFalse,
);
expect(() { expect(() {
CatmullRomCurve( CatmullRomCurve(
const <Offset>[ const <Offset>[
......
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
expect(error.diagnostics.map((DiagnosticsNode node) => node.toString()), <String>[ expect(error.diagnostics.map((DiagnosticsNode node) => node.toString()), <String>[
'Cannot lerp between "Instance of \'Object\'" and "Instance of \'Object\'".', 'Cannot lerp between "Instance of \'Object\'" and "Instance of \'Object\'".',
'The type Object might not fully implement `+`, `-`, and/or `*`. $kApiDocsLink', 'The type Object might not fully implement `+`, `-`, and/or `*`. $kApiDocsLink',
'There may be a dedicated "ObjectTween" for this type, or you may need to create one.' 'There may be a dedicated "ObjectTween" for this type, or you may need to create one.',
]); ]);
}); });
...@@ -59,7 +59,7 @@ void main() { ...@@ -59,7 +59,7 @@ void main() {
test('throws flutter error when tweening types that do not fully satisfy tween requirements - Rect', () { test('throws flutter error when tweening types that do not fully satisfy tween requirements - Rect', () {
final Tween<Rect> rectTween = Tween<Rect>( final Tween<Rect> rectTween = Tween<Rect>(
begin: const Rect.fromLTWH(0, 0, 10, 10), begin: const Rect.fromLTWH(0, 0, 10, 10),
end: const Rect.fromLTWH(2, 2, 2, 2) end: const Rect.fromLTWH(2, 2, 2, 2),
); );
FlutterError? error; FlutterError? error;
...@@ -185,9 +185,7 @@ void main() { ...@@ -185,9 +185,7 @@ void main() {
expect(rotationTween.lerp(0.0), equals(a)); expect(rotationTween.lerp(0.0), equals(a));
expect(rotationTween.lerp(1.0), equals(c)); expect(rotationTween.lerp(1.0), equals(c));
expect( expect(
rotationTween.lerp(0.5).absoluteError( rotationTween.lerp(0.5).absoluteError(a.clone()..rotateZ(0.5)),
a.clone()..rotateZ(0.5)
),
moreOrLessEquals(0.0), moreOrLessEquals(0.0),
); );
}, skip: isWindows); // floating point math not quite deterministic on Windows? }, skip: isWindows); // floating point math not quite deterministic on Windows?
...@@ -210,7 +208,7 @@ void main() { ...@@ -210,7 +208,7 @@ void main() {
test('ColorTween', () { test('ColorTween', () {
final ColorTween tween = ColorTween( final ColorTween tween = ColorTween(
begin: const Color(0xff000000), begin: const Color(0xff000000),
end: const Color(0xffffffff) end: const Color(0xffffffff),
); );
expect(tween.lerp(0.0), const Color(0xff000000)); expect(tween.lerp(0.0), const Color(0xff000000));
expect(tween.lerp(0.5), const Color(0xff7f7f7f)); expect(tween.lerp(0.5), const Color(0xff7f7f7f));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment