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

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

Issue 2329403003: More features handled in kernel impact. (Closed)
Patch Set: Fix analyze_test_test. 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
« no previous file with comments | « tests/compiler/dart2js/analyze_test_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
(...skipping 21 matching lines...) Expand all
32 testEmptyListLiteralTyped(); 32 testEmptyListLiteralTyped();
33 testEmptyListLiteralConstant(); 33 testEmptyListLiteralConstant();
34 testNonEmptyListLiteral(); 34 testNonEmptyListLiteral();
35 testEmptyMapLiteral(); 35 testEmptyMapLiteral();
36 testEmptyMapLiteralDynamic(); 36 testEmptyMapLiteralDynamic();
37 testEmptyMapLiteralTyped(); 37 testEmptyMapLiteralTyped();
38 testEmptyMapLiteralConstant(); 38 testEmptyMapLiteralConstant();
39 testNonEmptyMapLiteral(); 39 testNonEmptyMapLiteral();
40 testNot(); 40 testNot();
41 testUnaryMinus(); 41 testUnaryMinus();
42 testConditional();
43 testPostInc(null);
44 testPostDec(null);
45 testPreInc(null);
46 testPreDec(null);
42 testIfThen(); 47 testIfThen();
43 testIfThenElse(); 48 testIfThenElse();
44 testTopLevelInvoke(); 49 testTopLevelInvoke();
45 testTopLevelInvokeTyped(); 50 testTopLevelInvokeTyped();
46 testTopLevelField(); 51 testTopLevelField();
47 testTopLevelFieldTyped(); 52 testTopLevelFieldTyped();
53 testDynamicInvoke(null);
54 testDynamicGet(null);
55 testDynamicSet(null);
56 testLocalWithInitializer();
57 testInvokeIndex(null);
58 testInvokeIndexSet(null);
59 testAssert();
60 testAssertWithMessage();
48 } 61 }
49 62
50 testEmpty() {} 63 testEmpty() {}
51 testNull() => null; 64 testNull() => null;
52 testTrue() => true; 65 testTrue() => true;
53 testFalse() => false; 66 testFalse() => false;
54 testInt() => 42; 67 testInt() => 42;
55 testDouble() => 37.5; 68 testDouble() => 37.5;
56 testString() => 'foo'; 69 testString() => 'foo';
57 testSymbol() => #main; 70 testSymbol() => #main;
58 testEmptyListLiteral() => []; 71 testEmptyListLiteral() => [];
59 testEmptyListLiteralDynamic() => <dynamic>[]; 72 testEmptyListLiteralDynamic() => <dynamic>[];
60 testEmptyListLiteralTyped() => <String>[]; 73 testEmptyListLiteralTyped() => <String>[];
61 testEmptyListLiteralConstant() => const []; 74 testEmptyListLiteralConstant() => const [];
62 testNonEmptyListLiteral() => [0]; 75 testNonEmptyListLiteral() => [0];
63 testEmptyMapLiteral() => {}; 76 testEmptyMapLiteral() => {};
64 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{}; 77 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{};
65 testEmptyMapLiteralTyped() => <String, int>{}; 78 testEmptyMapLiteralTyped() => <String, int>{};
66 testEmptyMapLiteralConstant() => const {}; 79 testEmptyMapLiteralConstant() => const {};
67 testNonEmptyMapLiteral() => {0: true}; 80 testNonEmptyMapLiteral() => {0: true};
68 testNot() => !false; 81 testNot() => !false;
69 testUnaryMinus() => -1; 82 testUnaryMinus() => -1;
83 testConditional() => true ? 1 : '';
84 testPostInc(o) => o++;
85 testPostDec(o) => o--;
86 testPreInc(o) => ++o;
87 testPreDec(o) => --o;
70 testIfThen() { 88 testIfThen() {
71 if (false) return 42; 89 if (false) return 42;
72 return 1; 90 return 1;
73 } 91 }
74 testIfThenElse() { 92 testIfThenElse() {
75 if (true) { 93 if (true) {
76 return 42; 94 return 42;
77 } else { 95 } else {
78 return 1; 96 return 1;
79 } 97 }
(...skipping 25 matching lines...) Expand all
105 topLevelFunction3Typed(true); 123 topLevelFunction3Typed(true);
106 topLevelFunction3Typed(false, b: []); 124 topLevelFunction3Typed(false, b: []);
107 topLevelFunction3Typed(null, c: {}); 125 topLevelFunction3Typed(null, c: {});
108 topLevelFunction3Typed(true, b: [13], c: {'14': true}); 126 topLevelFunction3Typed(true, b: [13], c: {'14': true});
109 topLevelFunction3Typed(false, c: {'16': false}, b: [17]); 127 topLevelFunction3Typed(false, c: {'16': false}, b: [17]);
110 } 128 }
111 var topLevelField; 129 var topLevelField;
112 testTopLevelField() => topLevelField; 130 testTopLevelField() => topLevelField;
113 int topLevelFieldTyped; 131 int topLevelFieldTyped;
114 testTopLevelFieldTyped() => topLevelFieldTyped; 132 testTopLevelFieldTyped() => topLevelFieldTyped;
133 testDynamicInvoke(o) {
134 o.f1(0);
135 o.f2(1);
136 o.f3(2, 3);
137 o.f4(4, 5, 6);
138 o.f5(7);
139 o.f6(8, b: 9);
140 o.f7(10, c: 11);
141 o.f8(12, b: 13, c: 14);
142 o.f9(15, c: 16, b: 17);
143 }
144 testDynamicGet(o) => o.foo;
145 testDynamicSet(o) => o.foo = 42;
146 testLocalWithInitializer() {
147 var l = 42;
148 }
149 testInvokeIndex(o) => o[42];
150 testInvokeIndexSet(o) => o[42] = null;
151 testAssert() {
152 assert(true);
153 }
154 testAssertWithMessage() {
155 assert(true, 'ok');
156 }
115 ''' 157 '''
116 }; 158 };
117 159
118 main(List<String> args) { 160 main(List<String> args) {
119 asyncTest(() async { 161 asyncTest(() async {
120 enableDebugMode(); 162 enableDebugMode();
121 Uri entryPoint = Uri.parse('memory:main.dart'); 163 Uri entryPoint = Uri.parse('memory:main.dart');
122 Compiler compiler = compilerFor( 164 Compiler compiler = compilerFor(
123 entryPoint: entryPoint, 165 entryPoint: entryPoint,
124 memorySourceFiles: SOURCE, 166 memorySourceFiles: SOURCE,
125 options: [Flags.analyzeOnly, Flags.useKernel]); 167 options:
168 [Flags.analyzeAll, Flags.useKernel, Flags.enableAssertMessage]);
126 compiler.resolution.retainCachesForTesting = true; 169 compiler.resolution.retainCachesForTesting = true;
127 await compiler.run(entryPoint); 170 await compiler.run(entryPoint);
128 compiler.mainApp 171 checkLibrary(compiler, compiler.mainApp);
129 .forEachLocalMember((element) => checkElement(compiler, element));
130 }); 172 });
131 } 173 }
132 174
175 void checkLibrary(Compiler compiler, LibraryElement library) {
176 library.forEachLocalMember((AstElement element) {
177 if (element.isClass) {
178 // TODO(johnniwinther): Handle class members.
179 } else {
180 checkElement(compiler, element);
181 }
182 });
183 }
184
133 void checkElement(Compiler compiler, AstElement element) { 185 void checkElement(Compiler compiler, AstElement element) {
134 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); 186 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element);
135 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); 187 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst);
136 testResolutionImpactEquivalence( 188 testResolutionImpactEquivalence(
137 astImpact, kernelImpact, const CheckStrategy()); 189 astImpact, kernelImpact, const CheckStrategy());
138 } 190 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/analyze_test_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698