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

Side by Side Diff: tests/language_strong/instanceof_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 class InstanceofTest { 7 class InstanceofTest {
8
9 InstanceofTest() {} 8 InstanceofTest() {}
10 9
11 static void testBasicTypes() { 10 static void testBasicTypes() {
12 Expect.equals(true, 0 is int); 11 Expect.equals(true, 0 is int);
13 Expect.equals(false, (0 is bool)); 12 Expect.equals(false, (0 is bool));
14 Expect.equals(false, (0 is String)); 13 Expect.equals(false, (0 is String));
15 Expect.equals(true, 1 is int); 14 Expect.equals(true, 1 is int);
16 Expect.equals(false, (1 is bool)); 15 Expect.equals(false, (1 is bool));
17 Expect.equals(false, (1 is String)); 16 Expect.equals(false, (1 is String));
18 17
(...skipping 29 matching lines...) Expand all
48 Expect.equals(true, c is I); 47 Expect.equals(true, c is I);
49 Expect.equals(true, c is J); 48 Expect.equals(true, c is J);
50 Expect.equals(true, c is K); 49 Expect.equals(true, c is K);
51 50
52 var d = new D(); 51 var d = new D();
53 Expect.equals(true, d is I); 52 Expect.equals(true, d is I);
54 Expect.equals(true, d is J); 53 Expect.equals(true, d is J);
55 Expect.equals(true, d is K); 54 Expect.equals(true, d is K);
56 55
57 Expect.equals(true, [] is List); 56 Expect.equals(true, [] is List);
58 Expect.equals(true, [1,2,3] is List); 57 Expect.equals(true, [1, 2, 3] is List);
59 Expect.equals(false, (d is List)); 58 Expect.equals(false, (d is List));
60 Expect.equals(false, (null is List)); 59 Expect.equals(false, (null is List));
61 Expect.equals(false, (null is D)); 60 Expect.equals(false, (null is D));
62 } 61 }
63 62
64 static void testnum() { 63 static void testnum() {
65 Expect.equals(true, 0 is num); 64 Expect.equals(true, 0 is num);
66 Expect.equals(true, 123 is num); 65 Expect.equals(true, 123 is num);
67 Expect.equals(true, 123.34 is num); 66 Expect.equals(true, 123.34 is num);
68 Expect.equals(false, ("123" is num)); 67 Expect.equals(false, ("123" is num));
69 Expect.equals(false, (null is num)); 68 Expect.equals(false, (null is num));
70 Expect.equals(false, (true is num)); 69 Expect.equals(false, (true is num));
71 Expect.equals(false, (false is num)); 70 Expect.equals(false, (false is num));
72 var a = new A(); 71 var a = new A();
73 Expect.equals(false, (a is num)); 72 Expect.equals(false, (a is num));
74 } 73 }
75 74
76
77 static void testTypeOfInstanceOf() { 75 static void testTypeOfInstanceOf() {
78 var a = new A(); 76 var a = new A();
79 // Interfaces with parent 77 // Interfaces with parent
80 var c = new C(); 78 var c = new C();
81 var d = new D(); 79 var d = new D();
82 80
83 Expect.equals(true, (null is int) is bool); 81 Expect.equals(true, (null is int) is bool);
84 Expect.equals(true, (null is bool) is bool); 82 Expect.equals(true, (null is bool) is bool);
85 Expect.equals(true, (null is String) is bool); 83 Expect.equals(true, (null is String) is bool);
86 Expect.equals(true, (null is A) is bool); 84 Expect.equals(true, (null is A) is bool);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 static void testMain() { 162 static void testMain() {
165 testBasicTypes(); 163 testBasicTypes();
166 // TODO(sra): enable after fixing b/4604295 164 // TODO(sra): enable after fixing b/4604295
167 // testnum(); 165 // testnum();
168 testInterfaces(); 166 testInterfaces();
169 testTypeOfInstanceOf(); 167 testTypeOfInstanceOf();
170 } 168 }
171 } 169 }
172 170
173 abstract class I {} 171 abstract class I {}
174 class A implements I {A() {}} 172
175 class B {B() {}} 173 class A implements I {
174 A() {}
175 }
176
177 class B {
178 B() {}
179 }
176 180
177 abstract class J {} 181 abstract class J {}
178 182
179 abstract class K implements J {} 183 abstract class K implements J {}
180 class C implements I, K {C() {}}
181 184
182 class D extends C {D() : super() {}} 185 class C implements I, K {
186 C() {}
187 }
188
189 class D extends C {
190 D() : super() {}
191 }
183 192
184 main() { 193 main() {
185 // Repeat type checks so that inlined tests can be tested as well. 194 // Repeat type checks so that inlined tests can be tested as well.
186 for (int i = 0; i < 5; i++) { 195 for (int i = 0; i < 5; i++) {
187 InstanceofTest.testMain(); 196 InstanceofTest.testMain();
188 } 197 }
189 } 198 }
190
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698