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

Side by Side Diff: tests/compiler/dart2js/kernel/closed_world2_test.dart

Issue 3000763002: Implement .getCallType (Closed)
Patch Set: Created 3 years, 4 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 // Partial test that the closed world computed from [WorldImpact]s derived from 5 // Partial test that the closed world computed from [WorldImpact]s derived from
6 // kernel is equivalent to the original computed from resolution. 6 // kernel is equivalent to the original computed from resolution.
7 library dart2js.kernel.closed_world2_test; 7 library dart2js.kernel.closed_world2_test;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 method2() {} 44 method2() {}
45 method3() {} 45 method3() {}
46 } 46 }
47 class Class1 = Object with Mixin; 47 class Class1 = Object with Mixin;
48 class Class2 extends Object with Mixin { 48 class Class2 extends Object with Mixin {
49 method3() {} 49 method3() {}
50 } 50 }
51 51
52 method1() {} // Deliberately the same name as the instance member in Mixin. 52 method1() {} // Deliberately the same name as the instance member in Mixin.
53 53
54 class ClassWithCallBase {
55 void call() {}
56 }
57
58 class ClassWithCallRequired {
59 void call(int i) {}
60 }
61
62 class ClassWithCallGeneric<T> {
63 void call(T t) {}
64 }
65
66 class ClassWithCallOptional<T> {
67 void call([T t]) {}
68 }
69
70 class ClassWithCallNamed<T> {
71 void call({T t}) {}
72 }
73
74 class ClassWithCallGetter {
75 int get call => 0;
76 }
77
78 class ClassWithCallSetter {
79 void set call(int i) {}
80 }
81
82 // Inherits the call type:
83 class ClassWithCall1 extends ClassWithCallBase {}
84 class ClassWithCall2 extends ClassWithCallRequired {}
85 class ClassWithCall3 extends ClassWithCallGeneric<String> {}
86 class ClassWithCall4 extends ClassWithCallOptional<String> {}
87 class ClassWithCall5 extends ClassWithCallNamed<String> {}
88
89 // Inherits the same call type twice:
90 class ClassWithCall6 extends ClassWithCallRequired
91 implements ClassWithCallGeneric<int> {}
92
93 // Inherits different but compatible call types:
94 class ClassWithCall7 extends ClassWithCallRequired
95 implements ClassWithCallGeneric<String> {}
96 class ClassWithCall8 extends ClassWithCallRequired
97 implements ClassWithCallOptional<int> {}
98 class ClassWithCall9 extends ClassWithCallRequired
99 implements ClassWithCallOptional<String> {}
100 class ClassWithCall10 extends ClassWithCallBase
101 implements ClassWithCallNamed<String> {}
102
103 // Inherits incompatible call types:
104 class ClassWithCall11 extends ClassWithCallNamed<int>
105 implements ClassWithCallOptional<int> {}
106 class ClassWithCall12 extends ClassWithCallGetter {}
107 class ClassWithCall13 extends ClassWithCallSetter {}
108 class ClassWithCall14 extends ClassWithCallBase
109 implements ClassWithCallGetter {}
110 class ClassWithCall15 extends ClassWithCallBase
111 implements ClassWithCallSetter {}
112
113 class ClassImplementsFunction implements Function {}
114
54 @NoInline() 115 @NoInline()
55 main() { 116 main() {
56 print('Hello World'); 117 print('Hello World');
57 ''.contains; // Trigger member closurization. 118 ''.contains; // Trigger member closurization.
58 new Element.div(); 119 new Element.div();
59 new ClassWithSetter().setter = null; 120 new ClassWithSetter().setter = null;
60 new Class1().method1(); 121 new Class1().method1();
61 new Class2().method2(); 122 new Class2().method2();
62 new Class2().method3(); 123 new Class2().method3();
63 null is List<int>; // Use generic test 124 null is List<int>; // Use generic test
64 method1(); // Both top level and instance method named 'method1' are live. 125 method1(); // Both top level and instance method named 'method1' are live.
65 #main; // Use a const symbol. 126 #main; // Use a const symbol.
66 const Symbol('foo'); // Use the const Symbol constructor directly 127 const Symbol('foo'); // Use the const Symbol constructor directly
67 new Int8List(0); // Use redirect factory to abstract native class 128 new Int8List(0); // Use redirect factory to abstract native class
129
130 new ClassWithCall1();
131 new ClassWithCall2();
132 new ClassWithCall3();
133 new ClassWithCall4();
134 new ClassWithCall5();
135 new ClassWithCall6();
136 new ClassWithCall7();
137 new ClassWithCall8();
138 new ClassWithCall9();
139 new ClassWithCall10();
140 new ClassWithCall11();
141 new ClassWithCall12();
142 new ClassWithCall13();
143 new ClassWithCall14();
144 new ClassWithCall15();
145 new ClassImplementsFunction();
68 } 146 }
69 ''' 147 '''
70 }; 148 };
71 149
72 main(List<String> args) { 150 main(List<String> args) {
73 asyncTest(() async { 151 asyncTest(() async {
74 await mainInternal(args); 152 await mainInternal(args);
75 }); 153 });
76 } 154 }
77 155
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Compiler compiler2 = compilers.b; 207 Compiler compiler2 = compilers.b;
130 KernelFrontEndStrategy frontendStrategy = compiler2.frontendStrategy; 208 KernelFrontEndStrategy frontendStrategy = compiler2.frontendStrategy;
131 KernelToElementMapForImpact elementMap = frontendStrategy.elementMap; 209 KernelToElementMapForImpact elementMap = frontendStrategy.elementMap;
132 Expect.isFalse(compiler2.compilationFailed); 210 Expect.isFalse(compiler2.compilationFailed);
133 211
134 KernelEquivalence equivalence = new KernelEquivalence(elementMap); 212 KernelEquivalence equivalence = new KernelEquivalence(elementMap);
135 TestStrategy strategy = equivalence.defaultStrategy; 213 TestStrategy strategy = equivalence.defaultStrategy;
136 214
137 ElementEnvironment environment2 = 215 ElementEnvironment environment2 =
138 compiler2.frontendStrategy.elementEnvironment; 216 compiler2.frontendStrategy.elementEnvironment;
139 checkElementEnvironment(environment1, environment2, strategy); 217 checkElementEnvironment(
218 environment1,
219 environment2,
220 compiler1.frontendStrategy.dartTypes,
221 compiler2.frontendStrategy.dartTypes,
222 strategy);
140 223
141 ResolutionEnqueuer enqueuer2 = compiler2.enqueuer.resolution; 224 ResolutionEnqueuer enqueuer2 = compiler2.enqueuer.resolution;
142 ClosedWorld closedWorld2 = compiler2.resolutionWorldBuilder.closeWorld(); 225 ClosedWorld closedWorld2 = compiler2.resolutionWorldBuilder.closeWorld();
143 BackendUsage backendUsage2 = closedWorld2.backendUsage; 226 BackendUsage backendUsage2 = closedWorld2.backendUsage;
144 227
145 checkNativeClasses(compiler1, compiler2, strategy); 228 checkNativeClasses(compiler1, compiler2, strategy);
146 229
147 checkBackendUsage(backendUsage1, backendUsage2, strategy); 230 checkBackendUsage(backendUsage1, backendUsage2, strategy);
148 231
149 checkResolutionEnqueuers(backendUsage1, backendUsage2, enqueuer1, enqueuer2, 232 checkResolutionEnqueuers(backendUsage1, backendUsage2, enqueuer1, enqueuer2,
150 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), 233 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b),
151 typeEquivalence: (DartType a, DartType b) { 234 typeEquivalence: (DartType a, DartType b) {
152 return equivalence.typeEquivalence(unalias(a), b); 235 return equivalence.typeEquivalence(unalias(a), b);
153 }, 236 },
154 elementFilter: elementFilter, 237 elementFilter: elementFilter,
155 verbose: arguments.verbose); 238 verbose: arguments.verbose);
156 239
157 checkClosedWorlds(closedWorld1, closedWorld2, 240 checkClosedWorlds(closedWorld1, closedWorld2,
158 strategy: equivalence.defaultStrategy, verbose: arguments.verbose); 241 strategy: equivalence.defaultStrategy, verbose: arguments.verbose);
159 242
160 return ResultKind.success; 243 return ResultKind.success;
161 } 244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698