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

Unified Diff: tests/compiler/dart2js/kernel/impact_test.dart

Issue 2359453002: Handle local functions in kernel_impact. (Closed)
Patch Set: Updated cf. comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_impact.dart ('k') | tests/compiler/dart2js/serialization/test_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/kernel/impact_test.dart
diff --git a/tests/compiler/dart2js/kernel/impact_test.dart b/tests/compiler/dart2js/kernel/impact_test.dart
index 9581e13261f4de4cb00fb98ecd5ced5912845ffd..640a925c93324cd90efe3ee55ed79a838190a543 100644
--- a/tests/compiler/dart2js/kernel/impact_test.dart
+++ b/tests/compiler/dart2js/kernel/impact_test.dart
@@ -6,18 +6,22 @@ library dart2js.kernel.impact_test;
import 'dart:async';
import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/common.dart';
import 'package:compiler/src/commandline_options.dart';
+import 'package:compiler/src/common.dart';
+import 'package:compiler/src/common/names.dart';
import 'package:compiler/src/common/resolution.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/elements/elements.dart';
+import 'package:compiler/src/resolution/registry.dart';
import 'package:compiler/src/ssa/kernel_impact.dart';
import 'package:compiler/src/serialization/equivalence.dart';
+import 'package:compiler/src/universe/feature.dart';
+import 'package:compiler/src/universe/use.dart';
import '../memory_compiler.dart';
import '../serialization/test_helper.dart';
const Map<String, String> SOURCE = const <String, String>{
- 'main.dart': '''
+ 'main.dart': r'''
import 'helper.dart';
main() {
@@ -28,6 +32,9 @@ main() {
testInt();
testDouble();
testString();
+ testStringInterpolation();
+ testStringInterpolationConst();
+ testStringJuxtaposition();
testSymbol();
testEmptyListLiteral();
testEmptyListLiteralDynamic();
@@ -56,6 +63,9 @@ main() {
testDynamicGet(null);
testDynamicSet(null);
testLocalWithInitializer();
+ testLocalFunction();
+ testLocalFunctionInvoke();
+ testLocalFunctionGet();
testInvokeIndex(null);
testInvokeIndexSet(null);
testAssert();
@@ -73,6 +83,11 @@ testFalse() => false;
testInt() => 42;
testDouble() => 37.5;
testString() => 'foo';
+testStringInterpolation() => '${0}';
+testStringInterpolationConst() {
+ const b = '${0}';
+}
+testStringJuxtaposition() => 'a' 'b';
testSymbol() => #main;
testEmptyListLiteral() => [];
testEmptyListLiteralDynamic() => <dynamic>[];
@@ -152,6 +167,17 @@ testDynamicSet(o) => o.foo = 42;
testLocalWithInitializer() {
var l = 42;
}
+testLocalFunction() {
+ localFunction() {}
+}
+testLocalFunctionInvoke() {
+ localFunction() {}
+ localFunction();
+}
+testLocalFunctionGet() {
+ localFunction() {}
+ localFunction;
+}
testInvokeIndex(o) => o[42];
testInvokeIndexSet(o) => o[42] = null;
testAssert() {
@@ -213,7 +239,37 @@ void checkLibrary(Compiler compiler, LibraryElement library) {
void checkElement(Compiler compiler, AstElement element) {
ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element);
+ astImpact = laxImpact(element, astImpact);
ResolutionImpact kernelImpact = build(compiler, element.resolvedAst);
testResolutionImpactEquivalence(
astImpact, kernelImpact, const CheckStrategy());
}
+
+/// Lax the precision of [impact] to meet expectancy of the corresponding impact
+/// generated from kernel.
+ResolutionImpact laxImpact(AstElement element, ResolutionImpact impact) {
+ ResolutionWorldImpactBuilder builder =
+ new ResolutionWorldImpactBuilder('Lax impact of ${element}');
+ impact.staticUses.forEach(builder.registerStaticUse);
+ impact.dynamicUses.forEach(builder.registerDynamicUse);
+ impact.typeUses.forEach(builder.registerTypeUse);
+ impact.constantLiterals.forEach(builder.registerConstantLiteral);
+ impact.constSymbolNames.forEach(builder.registerConstSymbolName);
+ impact.listLiterals.forEach(builder.registerListLiteral);
+ impact.mapLiterals.forEach(builder.registerMapLiteral);
+ for (Feature feature in impact.features) {
+ builder.registerFeature(feature);
+ switch (feature) {
+ case Feature.STRING_INTERPOLATION:
+ case Feature.STRING_JUXTAPOSITION:
+ // These are both converted into a string concatenation in kernel so
+ // we cannot tell the diferrence.
+ builder.registerFeature(Feature.STRING_INTERPOLATION);
+ builder.registerFeature(Feature.STRING_JUXTAPOSITION);
+ break;
+ default:
+ }
+ }
+ impact.nativeData.forEach(builder.registerNativeData);
+ return builder;
+}
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_impact.dart ('k') | tests/compiler/dart2js/serialization/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698