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

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

Issue 2857373002: Handle more constants in Constantifier (Closed)
Patch Set: Updated cf. comments. Created 3 years, 7 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/constant_expression_evaluate_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 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import 'package:compiler/src/commandline_options.dart'; 8 import 'package:compiler/src/commandline_options.dart';
9 import 'package:compiler/src/common.dart'; 9 import 'package:compiler/src/common.dart';
10 import 'package:compiler/src/common/names.dart'; 10 import 'package:compiler/src/common/names.dart';
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 testTrue(); 49 testTrue();
50 testFalse(); 50 testFalse();
51 testInt(); 51 testInt();
52 testDouble(); 52 testDouble();
53 testString(); 53 testString();
54 testStringInterpolation(); 54 testStringInterpolation();
55 testStringInterpolationConst(); 55 testStringInterpolationConst();
56 testStringJuxtaposition(); 56 testStringJuxtaposition();
57 testSymbol(); 57 testSymbol();
58 testConstSymbol(); 58 testConstSymbol();
59 testComplexConstSymbol();
59 testTypeLiteral(); 60 testTypeLiteral();
60 testBoolFromEnvironment(); 61 testBoolFromEnvironment();
61 testEmptyListLiteral(); 62 testEmptyListLiteral();
62 testEmptyListLiteralDynamic(); 63 testEmptyListLiteralDynamic();
63 testEmptyListLiteralTyped(); 64 testEmptyListLiteralTyped();
64 testEmptyListLiteralConstant(); 65 testEmptyListLiteralConstant();
65 testNonEmptyListLiteral(); 66 testNonEmptyListLiteral();
66 testEmptyMapLiteral(); 67 testEmptyMapLiteral();
67 testEmptyMapLiteralDynamic(); 68 testEmptyMapLiteralDynamic();
68 testEmptyMapLiteralTyped(); 69 testEmptyMapLiteralTyped();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 testInt() => 42; 211 testInt() => 42;
211 testDouble() => 37.5; 212 testDouble() => 37.5;
212 testString() => 'foo'; 213 testString() => 'foo';
213 testStringInterpolation() => '${0}'; 214 testStringInterpolation() => '${0}';
214 testStringInterpolationConst() { 215 testStringInterpolationConst() {
215 const b = '${0}'; 216 const b = '${0}';
216 } 217 }
217 testStringJuxtaposition() => 'a' 'b'; 218 testStringJuxtaposition() => 'a' 'b';
218 testSymbol() => #main; 219 testSymbol() => #main;
219 testConstSymbol() => const Symbol('main'); 220 testConstSymbol() => const Symbol('main');
221
222 const complexSymbolField1 = "true".length == 4;
223 const complexSymbolField2 = "true" "false" "${4}${null}";
224 const complexSymbolField3 = const {
225 0.1: const bool.fromEnvironment('a', defaultValue: true),
226 false: const int.fromEnvironment('b', defaultValue: 42),
227 const <int>[]: const String.fromEnvironment('c'),
228 testComplexConstSymbol: #testComplexConstSymbol,
229 1 + 2: identical(0, -0),
230 true || false: false && true,
231 override: const GenericClass<int, String>.generative(),
232 };
233 const complexSymbolField =
234 complexSymbolField1 ? complexSymbolField2 : complexSymbolField3;
235 testComplexConstSymbol() => const Symbol(complexSymbolField);
236
220 testTypeLiteral() => Object; 237 testTypeLiteral() => Object;
221 testBoolFromEnvironment() => const bool.fromEnvironment('FOO'); 238 testBoolFromEnvironment() => const bool.fromEnvironment('FOO');
222 testEmptyListLiteral() => []; 239 testEmptyListLiteral() => [];
223 testEmptyListLiteralDynamic() => <dynamic>[]; 240 testEmptyListLiteralDynamic() => <dynamic>[];
224 testEmptyListLiteralTyped() => <String>[]; 241 testEmptyListLiteralTyped() => <String>[];
225 testEmptyListLiteralConstant() => const []; 242 testEmptyListLiteralConstant() => const [];
226 testNonEmptyListLiteral() => [0]; 243 testNonEmptyListLiteral() => [0];
227 testEmptyMapLiteral() => {}; 244 testEmptyMapLiteral() => {};
228 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{}; 245 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{};
229 testEmptyMapLiteralTyped() => <String, int>{}; 246 testEmptyMapLiteralTyped() => <String, int>{};
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 memorySourceFiles: SOURCE, 734 memorySourceFiles: SOURCE,
718 options: [ 735 options: [
719 fullTest ? Flags.analyzeAll : Flags.analyzeOnly, 736 fullTest ? Flags.analyzeAll : Flags.analyzeOnly,
720 Flags.useKernel, 737 Flags.useKernel,
721 Flags.enableAssertMessage 738 Flags.enableAssertMessage
722 ]); 739 ]);
723 compiler.resolution.retainCachesForTesting = true; 740 compiler.resolution.retainCachesForTesting = true;
724 Expect.isTrue(await compiler.run(entryPoint)); 741 Expect.isTrue(await compiler.run(entryPoint));
725 JavaScriptBackend backend = compiler.backend; 742 JavaScriptBackend backend = compiler.backend;
726 KernelToElementMap kernelElementMap = 743 KernelToElementMap kernelElementMap =
727 new KernelToElementMap(compiler.reporter); 744 new KernelToElementMap(compiler.reporter, compiler.environment);
728 kernelElementMap.addProgram(backend.kernelTask.program); 745 kernelElementMap.addProgram(backend.kernelTask.program);
729 746
730 checkLibrary(compiler, kernelElementMap, compiler.mainApp, 747 checkLibrary(compiler, kernelElementMap, compiler.mainApp,
731 fullTest: fullTest); 748 fullTest: fullTest);
732 compiler.libraryLoader.libraries.forEach((LibraryElement library) { 749 compiler.libraryLoader.libraries.forEach((LibraryElement library) {
733 if (library == compiler.mainApp) return; 750 if (library == compiler.mainApp) return;
734 checkLibrary(compiler, kernelElementMap, library, fullTest: fullTest); 751 checkLibrary(compiler, kernelElementMap, library, fullTest: fullTest);
735 }); 752 });
736 }); 753 });
737 } 754 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 visitList(type.optionalParameterTypes), 938 visitList(type.optionalParameterTypes),
922 type.namedParameters, 939 type.namedParameters,
923 visitList(type.namedParameterTypes)); 940 visitList(type.namedParameterTypes));
924 } 941 }
925 } 942 }
926 943
927 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType]. 944 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType].
928 ResolutionDartType unalias(ResolutionDartType type) { 945 ResolutionDartType unalias(ResolutionDartType type) {
929 return const Unaliaser().visit(type); 946 return const Unaliaser().visit(type);
930 } 947 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/constant_expression_evaluate_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698