Commit 18ad3eb5 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by Adam Barth

avoid // ignore: prefer_const_constructors (#8419)

* avoid // ignore: prefer_const_constructors

* address review comments
parent bfef36f7
......@@ -8,12 +8,14 @@ import 'package:test/test.dart';
void main() {
test('TextSpan equals', () {
TextSpan a1 = new TextSpan(text: 'a'); // ignore: prefer_const_constructors
TextSpan a2 = new TextSpan(text: 'a'); // ignore: prefer_const_constructors
String text = 'a'; // we want these instances to be separate instances so that we're not just checking with a single object
TextSpan a1 = new TextSpan(text: text);
TextSpan a2 = new TextSpan(text: text);
TextSpan b1 = new TextSpan(children: <TextSpan>[ a1 ]);
TextSpan b2 = new TextSpan(children: <TextSpan>[ a2 ]);
TextSpan c1 = new TextSpan(); // ignore: prefer_const_constructors
TextSpan c2 = new TextSpan(); // ignore: prefer_const_constructors
String nullText; // we want these instances to be separate instances so that we're not just checking with a single object
TextSpan c1 = new TextSpan(text: nullText);
TextSpan c2 = new TextSpan(text: nullText);
expect(a1 == a2, isTrue);
expect(b1 == b2, isTrue);
......
......@@ -19,32 +19,37 @@ class NotEquals {
void main() {
testWidgets('Keys', (WidgetTester tester) async {
expect(new ValueKey<int>(3) == new ValueKey<int>(3), isTrue); // ignore: prefer_const_constructors
expect(new ValueKey<num>(3) == new ValueKey<int>(3), isFalse); // ignore: prefer_const_constructors
expect(new ValueKey<int>(3) == new ValueKey<int>(2), isFalse); // ignore: prefer_const_constructors
int int3 = 3; // we want these instances to be separate instances so that we're not just checking with a single object
expect(new ValueKey<int>(int3) == new ValueKey<int>(int3), isTrue);
expect(new ValueKey<num>(int3) == new ValueKey<int>(int3), isFalse);
int int2 = 2; // we want these instances to be separate instances so that we're not just checking with a single object
expect(new ValueKey<int>(int3) == new ValueKey<int>(int2), isFalse);
expect(const ValueKey<double>(double.NAN) == const ValueKey<double>(double.NAN), isFalse);
expect(new Key('') == new ValueKey<String>(''), isTrue); // ignore: prefer_const_constructors
expect(new ValueKey<String>('') == new ValueKey<String>(''), isTrue); // ignore: prefer_const_constructors
expect(new TestValueKey<String>('') == new ValueKey<String>(''), isFalse); // ignore: prefer_const_constructors
expect(new TestValueKey<String>('') == new TestValueKey<String>(''), isTrue); // ignore: prefer_const_constructors
expect(new ValueKey<String>('') == new ValueKey<dynamic>(''), isFalse); // ignore: prefer_const_constructors
expect(new TestValueKey<String>('') == new TestValueKey<dynamic>(''), isFalse); // ignore: prefer_const_constructors
String empty = ''; // we want these instances to be separate instances so that we're not just checking with a single object
expect(new Key(empty) == new ValueKey<String>(empty), isTrue);
expect(new ValueKey<String>(empty) == new ValueKey<String>(empty), isTrue);
expect(new TestValueKey<String>(empty) == new ValueKey<String>(empty), isFalse);
expect(new TestValueKey<String>(empty) == new TestValueKey<String>(empty), isTrue);
expect(new ValueKey<String>(empty) == new ValueKey<dynamic>(empty), isFalse);
expect(new TestValueKey<String>(empty) == new TestValueKey<dynamic>(empty), isFalse);
expect(new UniqueKey() == new UniqueKey(), isFalse);
LocalKey k = new UniqueKey();
expect(new UniqueKey() == new UniqueKey(), isFalse);
expect(k == k, isTrue);
expect(new ValueKey<LocalKey>(k) == new ValueKey<LocalKey>(k), isTrue);
expect(new ValueKey<LocalKey>(k) == new ValueKey<UniqueKey>(k), isFalse);
expect(new ObjectKey(k) == new ObjectKey(k), isTrue);
expect(new ValueKey<NotEquals>(const NotEquals()) == new ValueKey<NotEquals>(const NotEquals()), isFalse); // ignore: prefer_const_constructors
expect(new ObjectKey(const NotEquals()) == new ObjectKey(const NotEquals()), isTrue); // ignore: prefer_const_constructors
expect(new ObjectKey(const Object()) == new ObjectKey(const Object()), isTrue); // ignore: prefer_const_constructors
NotEquals constNotEquals = const NotEquals(); // we want these instances to be separate instances so that we're not just checking with a single object
expect(new ValueKey<NotEquals>(constNotEquals) == new ValueKey<NotEquals>(constNotEquals), isFalse);
expect(new ObjectKey(constNotEquals) == new ObjectKey(constNotEquals), isTrue);
Object constObject = const Object(); // we want these instances to be separate instances so that we're not just checking with a single object
expect(new ObjectKey(constObject) == new ObjectKey(constObject), isTrue);
expect(new ObjectKey(new Object()) == new ObjectKey(new Object()), isFalse);
expect(const ValueKey<bool>(true), hasOneLineDescription);
......
......@@ -6,9 +6,10 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
final BoxDecoration kBoxDecorationA = new BoxDecoration(); // ignore: prefer_const_constructors
final BoxDecoration kBoxDecorationB = new BoxDecoration(); // ignore: prefer_const_constructors
final BoxDecoration kBoxDecorationC = new BoxDecoration(); // ignore: prefer_const_constructors
final Border nullBorder = null; // we want these instances to be separate instances so that we're not just checking with a single object
final BoxDecoration kBoxDecorationA = new BoxDecoration(border: nullBorder);
final BoxDecoration kBoxDecorationB = new BoxDecoration(border: nullBorder);
final BoxDecoration kBoxDecorationC = new BoxDecoration(border: nullBorder);
class TestWidget extends StatelessWidget {
const TestWidget({ this.child });
......
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