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

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

Issue 2341263002: Handle generic factory constructors in kernel_impact (Closed)
Patch Set: Created 4 years, 3 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) 2016, the Dart project authors. Please see the AUTHORS file 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 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 library dart2js.kernel.impact_test; 5 library dart2js.kernel.impact_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:compiler/src/common.dart'; 9 import 'package:compiler/src/common.dart';
10 import 'package:compiler/src/commandline_options.dart'; 10 import 'package:compiler/src/commandline_options.dart';
11 import 'package:compiler/src/common/resolution.dart'; 11 import 'package:compiler/src/common/resolution.dart';
12 import 'package:compiler/src/compiler.dart'; 12 import 'package:compiler/src/compiler.dart';
13 import 'package:compiler/src/elements/elements.dart'; 13 import 'package:compiler/src/elements/elements.dart';
14 import 'package:compiler/src/ssa/kernel_impact.dart'; 14 import 'package:compiler/src/ssa/kernel_impact.dart';
15 import 'package:compiler/src/serialization/equivalence.dart'; 15 import 'package:compiler/src/serialization/equivalence.dart';
16 import '../memory_compiler.dart'; 16 import '../memory_compiler.dart';
17 import '../serialization/test_helper.dart'; 17 import '../serialization/test_helper.dart';
18 18
19 const Map<String, String> SOURCE = const <String, String>{ 19 const Map<String, String> SOURCE = const <String, String>{
20 'main.dart': ''' 20 'main.dart': '''
21 import 'helper.dart';
22
21 main() { 23 main() {
22 testEmpty(); 24 testEmpty();
23 testNull(); 25 testNull();
24 testTrue(); 26 testTrue();
25 testFalse(); 27 testFalse();
26 testInt(); 28 testInt();
27 testDouble(); 29 testDouble();
28 testString(); 30 testString();
29 testSymbol(); 31 testSymbol();
30 testEmptyListLiteral(); 32 testEmptyListLiteral();
(...skipping 20 matching lines...) Expand all
51 testTopLevelField(); 53 testTopLevelField();
52 testTopLevelFieldTyped(); 54 testTopLevelFieldTyped();
53 testDynamicInvoke(null); 55 testDynamicInvoke(null);
54 testDynamicGet(null); 56 testDynamicGet(null);
55 testDynamicSet(null); 57 testDynamicSet(null);
56 testLocalWithInitializer(); 58 testLocalWithInitializer();
57 testInvokeIndex(null); 59 testInvokeIndex(null);
58 testInvokeIndexSet(null); 60 testInvokeIndexSet(null);
59 testAssert(); 61 testAssert();
60 testAssertWithMessage(); 62 testAssertWithMessage();
63 testFactoryInvoke();
64 testFactoryInvokeGeneric();
65 testFactoryInvokeGenericRaw();
66 testFactoryInvokeGenericDynamic();
61 } 67 }
62 68
63 testEmpty() {} 69 testEmpty() {}
64 testNull() => null; 70 testNull() => null;
65 testTrue() => true; 71 testTrue() => true;
66 testFalse() => false; 72 testFalse() => false;
67 testInt() => 42; 73 testInt() => 42;
68 testDouble() => 37.5; 74 testDouble() => 37.5;
69 testString() => 'foo'; 75 testString() => 'foo';
70 testSymbol() => #main; 76 testSymbol() => #main;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 var l = 42; 153 var l = 42;
148 } 154 }
149 testInvokeIndex(o) => o[42]; 155 testInvokeIndex(o) => o[42];
150 testInvokeIndexSet(o) => o[42] = null; 156 testInvokeIndexSet(o) => o[42] = null;
151 testAssert() { 157 testAssert() {
152 assert(true); 158 assert(true);
153 } 159 }
154 testAssertWithMessage() { 160 testAssertWithMessage() {
155 assert(true, 'ok'); 161 assert(true, 'ok');
156 } 162 }
157 ''' 163 testFactoryInvoke() {
164 new Class.fact();
165 }
166 testFactoryInvokeGeneric() {
167 new GenericClass<int, String>.fact();
168 }
169 testFactoryInvokeGenericRaw() {
170 new GenericClass.fact();
171 }
172 testFactoryInvokeGenericDynamic() {
173 new GenericClass<dynamic, dynamic>.fact();
174 }
175 ''',
176 'helper.dart': '''
177 class Class {
178 factory Class.fact() => null;
179 }
180 class GenericClass<X, Y> {
181 factory GenericClass.fact() => null;
182 }
183 ''',
158 }; 184 };
159 185
160 main(List<String> args) { 186 main(List<String> args) {
161 asyncTest(() async { 187 asyncTest(() async {
162 enableDebugMode(); 188 enableDebugMode();
163 Uri entryPoint = Uri.parse('memory:main.dart'); 189 Uri entryPoint = Uri.parse('memory:main.dart');
164 Compiler compiler = compilerFor( 190 Compiler compiler = compilerFor(
165 entryPoint: entryPoint, 191 entryPoint: entryPoint,
166 memorySourceFiles: SOURCE, 192 memorySourceFiles: SOURCE,
167 options: 193 options:
(...skipping 13 matching lines...) Expand all
181 } 207 }
182 }); 208 });
183 } 209 }
184 210
185 void checkElement(Compiler compiler, AstElement element) { 211 void checkElement(Compiler compiler, AstElement element) {
186 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); 212 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element);
187 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); 213 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst);
188 testResolutionImpactEquivalence( 214 testResolutionImpactEquivalence(
189 astImpact, kernelImpact, const CheckStrategy()); 215 astImpact, kernelImpact, const CheckStrategy());
190 } 216 }
OLDNEW
« pkg/compiler/lib/src/ssa/kernel_impact.dart ('K') | « pkg/compiler/lib/src/ssa/kernel_impact.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698