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

Side by Side Diff: tests/language/null_test.dart

Issue 2770063002: Revert "Format all multitests" (Closed)
Patch Set: Created 3 years, 9 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Second dart test program. 4 // Second dart test program.
5 5
6 // VMOptions=--optimization-counter-threshold=5 --no-background-compilation 6 // VMOptions=--optimization-counter-threshold=5 --no-background-compilation
7 7
8 import "dart:mirrors"; 8 import "dart:mirrors";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
11 class BadInherit 11 class BadInherit
12 extends Null // //# 01: compile-time error 12 extends Null // //# 01: compile-time error
13 implements Null // //# 02: compile-time error 13 implements Null // //# 02: compile-time error
14 extends Object with Null // //# 03: compile-time error 14 extends Object with Null // //# 03: compile-time error
15 {} 15 {}
16 16
17 class EqualsNotCalled { 17 class EqualsNotCalled {
18 int get hashCode => throw "And don't warn!"; 18 int get hashCode => throw "And don't warn!";
19 bool operator ==(Object other) { 19 bool operator==(Object other) {
20 throw "SHOULD NOT GET HERE"; 20 throw "SHOULD NOT GET HERE";
21 } 21 }
22 } 22 }
23 23
24 class Generic<T> { 24 class Generic<T> {
25 bool test(o) => o is T; 25 bool test(o) => o is T;
26 T cast(o) => o as T; 26 T cast(o) => o as T;
27 Type get type => T; 27 Type get type => T;
28 } 28 }
29 29
(...skipping 10 matching lines...) Expand all
40 @AssumeDynamic() 40 @AssumeDynamic()
41 confuse(x) => x; 41 confuse(x) => x;
42 42
43 void main() { 43 void main() {
44 for (int i = 0; i < 10; i++) { 44 for (int i = 0; i < 10; i++) {
45 test(); 45 test();
46 } 46 }
47 } 47 }
48 48
49 void test() { 49 void test() {
50 new BadInherit(); // Make sure class is referenced. 50 new BadInherit(); // Make sure class is referenced.
51 51
52 int foo(var obj) { 52 int foo(var obj) {
53 Expect.equals(null, obj); 53 Expect.equals(null, obj);
54 } 54 }
55 55
56 bool compareToNull(var value) { 56 bool compareToNull(var value) {
57 return null == value; 57 return null == value;
58 } 58 }
59 59
60 bool compareWithNull(var value) { 60 bool compareWithNull(var value) {
61 return value == null; 61 return value == null;
62 } 62 }
63 63
64 var val = 1; 64 var val = 1;
65 var obj = confuse(null); // Null value that isn't known at compile-time. 65 var obj = confuse(null); // Null value that isn't known at compile-time.
66 Expect.isTrue(identical(obj, null), "identical"); 66 Expect.isTrue(identical(obj, null), "identical");
67 67
68 Expect.isTrue(null == null); 68 Expect.isTrue(null == null);
69 Expect.isTrue(null == obj); 69 Expect.isTrue(null == obj);
70 Expect.isTrue(obj == null); 70 Expect.isTrue(obj == null);
71 Expect.isTrue(obj == obj); 71 Expect.isTrue(obj == obj);
72 72
73 // Using == null or null == will not call any equality method. 73 // Using == null or null == will not call any equality method.
74 Expect.isFalse(new EqualsNotCalled() == null); 74 Expect.isFalse(new EqualsNotCalled() == null);
75 Expect.isFalse(null == new EqualsNotCalled()); 75 Expect.isFalse(null == new EqualsNotCalled());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 // Test "is" operator. 111 // Test "is" operator.
112 Expect.isTrue(null is Null); 112 Expect.isTrue(null is Null);
113 Expect.isTrue(obj is Null); 113 Expect.isTrue(obj is Null);
114 Expect.isTrue(null is Object); 114 Expect.isTrue(null is Object);
115 Expect.isTrue(obj is Object); 115 Expect.isTrue(obj is Object);
116 Expect.isTrue(null is dynamic); 116 Expect.isTrue(null is dynamic);
117 Expect.isTrue(obj is dynamic); 117 Expect.isTrue(obj is dynamic);
118 Expect.isFalse(null is String); 118 Expect.isFalse(null is String);
119 Expect.isFalse(obj is String); 119 Expect.isFalse(obj is String);
120 Expect.isFalse(0 is Null); // It's only assignable. 120 Expect.isFalse(0 is Null); // It's only assignable.
121 Expect.isFalse(null is! Null); 121 Expect.isFalse(null is! Null);
122 Expect.isFalse(obj is! Null); 122 Expect.isFalse(obj is! Null);
123 Expect.isFalse(null is! Object); 123 Expect.isFalse(null is! Object);
124 Expect.isFalse(obj is! Object); 124 Expect.isFalse(obj is! Object);
125 Expect.isFalse(null is! dynamic); 125 Expect.isFalse(null is! dynamic);
126 Expect.isFalse(obj is! dynamic); 126 Expect.isFalse(obj is! dynamic);
127 Expect.isTrue(null is! String); 127 Expect.isTrue(null is! String);
128 Expect.isTrue(obj is! String); 128 Expect.isTrue(obj is! String);
129 Expect.isTrue(0 is! Null); // It's only assignable. 129 Expect.isTrue(0 is! Null); // It's only assignable.
130 130
131 // Test "is" operator with generic type variable. 131 // Test "is" operator with generic type variable.
132 Expect.isTrue(new Generic<Null>().test(null)); 132 Expect.isTrue(new Generic<Null>().test(null));
133 Expect.isFalse(new Generic<Null>().test(42)); 133 Expect.isFalse(new Generic<Null>().test(42));
134 Expect.isTrue(new Generic2<Null, int>().test(null)); 134 Expect.isTrue(new Generic2<Null, int>().test(null));
135 Expect.isFalse(new Generic2<Null, int>().test(42)); 135 Expect.isFalse(new Generic2<Null, int>().test(42));
136 136
137 // Test cast, "as", operator. 137 // Test cast, "as", operator.
138 Expect.equals(null, null as Null); 138 Expect.equals(null, null as Null);
139 Expect.equals(null, null as Object); 139 Expect.equals(null, null as Object);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 Expect.throws(() => obj.notDeclared()); 191 Expect.throws(() => obj.notDeclared());
192 var noSuchMethod = null.noSuchMethod; 192 var noSuchMethod = null.noSuchMethod;
193 // Assing to "var" to prevent warning. 193 // Assing to "var" to prevent warning.
194 var capture = new CaptureInvocationMirror(); 194 var capture = new CaptureInvocationMirror();
195 var mirror = capture.notDeclared(); 195 var mirror = capture.notDeclared();
196 Expect.throws(() => noSuchMethod(mirror)); 196 Expect.throws(() => noSuchMethod(mirror));
197 Expect.throws(() => Function.apply(noSuchMethod, [mirror])); 197 Expect.throws(() => Function.apply(noSuchMethod, [mirror]));
198 } 198 }
199 199
200
200 class CaptureInvocationMirror { 201 class CaptureInvocationMirror {
201 noSuchMethod(mirror) => mirror; 202 noSuchMethod(mirror) => mirror;
202 } 203 }
OLDNEW
« no previous file with comments | « tests/language/null_is_bottom_type_test.dart ('k') | tests/language/number_identifier_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698