Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: test/rules/dont_compare_unrelated_types_for_equality.dart

Issue 1972183002: Linter version 0.1.16 bump [TBR]. (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | test/rules/unrelated_type_equality_checks.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // test w/ `dart test/util/solo_test.dart dont_compare_unrelated_types_for_equal ity`
6
7 void someFunction() {
8 var x = '1';
9 if (x == 1) print('someFunction'); // LINT
10 }
11
12 void someFunction1() {
13 String x = '1';
14 if (x == 1) print('someFunction1'); // LINT
15 }
16
17 void someFunction2() {
18 var x = '1';
19 var y = '2';
20 if (x == y) print(someFunction2); // OK
21 }
22
23 void someFunction3() {
24 for (var i = 0; i < 10; i++) {
25 if (i == 0) print(someFunction3); // OK
26 }
27 }
28
29 void someFunction4() {
30 var x = '1';
31 if (x == null) print(someFunction4); // OK
32 }
33
34 void someFunction5(Object object) {
35 List<ClassBase> someList;
36
37 for (ClassBase someInstance in someList) {
38 if (object == someInstance) print('someFunction5'); // OK
39 }
40 }
41
42 void someFunction6(Object object) {
43 List someList;
44
45 for (var someInstance in someList) {
46 if (object == someInstance) print('someFunction6'); // OK
47 }
48 }
49
50 void someFunction7() {
51 List someList;
52
53 if (someList.length == 0) print('someFunction7'); // OK
54 }
55
56 void someFunction8(ClassBase instance) {
57 DerivedClass1 other;
58
59 if (other == instance) print('someFunction8'); // OK
60 }
61
62 void someFunction9(ClassBase instance) {
63 var other = new DerivedClass1();
64
65 if (other == instance) print('someFunction9'); // OK
66 }
67
68 void someFunction10(unknown) {
69 var what = unknown - 1;
70 for (var index = 0; index < unknown; index++) {
71 if (what == index) print('someFunction10'); // OK
72 }
73 }
74
75 void someFunction11(Mixin instance) {
76 var other = new DerivedClass2();
77
78 if (other == instance) print('someFunction11'); // OK
79 }
80
81 void someFunction12(Mixin instance) {
82 var other = new DerivedClass3();
83
84 if (other == instance) print('someFunction12'); // OK
85 }
86
87 void someFunction13(DerivedClass2 instance) {
88 var other = new DerivedClass3();
89
90 if (other == instance) print('someFunction13'); // OK
91 }
92
93 void someFunction14(DerivedClass4 instance) {
94 var other = new DerivedClass5();
95
96 if (other == instance) print('someFunction15'); // LINT
97 }
98
99 class ClassBase {}
100
101 class DerivedClass1 extends ClassBase {}
102
103 abstract class Mixin {}
104
105 class DerivedClass2 extends ClassBase with Mixin {}
106
107 class DerivedClass3 extends ClassBase implements Mixin {}
108
109 class DerivedClass4 extends DerivedClass2 {}
110
111 class DerivedClass5 extends DerivedClass3 {}
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/rules/unrelated_type_equality_checks.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698