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

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

Issue 2679913006: Add KernelNativeBehaviorComputer (Closed)
Patch Set: Rebased Created 3 years, 10 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 | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.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 11 matching lines...) Expand all
22 import 'package:compiler/src/serialization/equivalence.dart'; 22 import 'package:compiler/src/serialization/equivalence.dart';
23 import 'package:compiler/src/universe/call_structure.dart'; 23 import 'package:compiler/src/universe/call_structure.dart';
24 import 'package:compiler/src/universe/feature.dart'; 24 import 'package:compiler/src/universe/feature.dart';
25 import 'package:compiler/src/universe/use.dart'; 25 import 'package:compiler/src/universe/use.dart';
26 import 'package:expect/expect.dart'; 26 import 'package:expect/expect.dart';
27 import 'package:kernel/ast.dart' as ir; 27 import 'package:kernel/ast.dart' as ir;
28 import '../memory_compiler.dart'; 28 import '../memory_compiler.dart';
29 import '../serialization/test_helper.dart'; 29 import '../serialization/test_helper.dart';
30 30
31 const Map<String, String> SOURCE = const <String, String>{ 31 const Map<String, String> SOURCE = const <String, String>{
32 'main.dart': r''' 32 // Pretend this is a dart2js_native test to allow use of 'native' keyword.
33 'sdk/tests/compiler/dart2js_native/main.dart': r'''
33 import 'dart:_foreign_helper'; 34 import 'dart:_foreign_helper';
35 import 'dart:_js_helper';
34 import 'helper.dart'; 36 import 'helper.dart';
35 import 'dart:html'; 37 import 'dart:html';
36 38
37 main() { 39 main() {
38 testEmpty(); 40 testEmpty();
39 testNull(); 41 testNull();
40 testTrue(); 42 testTrue();
41 testFalse(); 43 testFalse();
42 testInt(); 44 testInt();
43 testDouble(); 45 testDouble();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 testSuperSetterSet(); 172 testSuperSetterSet();
171 testSuperClosurization(); 173 testSuperClosurization();
172 testForwardingConstructor(); 174 testForwardingConstructor();
173 testForwardingConstructorTyped(); 175 testForwardingConstructorTyped();
174 testForwardingConstructorGeneric(); 176 testForwardingConstructorGeneric();
175 testEnum(); 177 testEnum();
176 testStaticGenericMethod(); 178 testStaticGenericMethod();
177 testInstanceGenericMethod(); 179 testInstanceGenericMethod();
178 testDynamicPrivateMethodInvoke(); 180 testDynamicPrivateMethodInvoke();
179 testJSCall(); 181 testJSCall();
182 testNativeMethod();
180 } 183 }
181 184
182 testEmpty() {} 185 testEmpty() {}
183 testNull() => null; 186 testNull() => null;
184 testTrue() => true; 187 testTrue() => true;
185 testFalse() => false; 188 testFalse() => false;
186 testInt() => 42; 189 testInt() => 42;
187 testDouble() => 37.5; 190 testDouble() => 37.5;
188 testString() => 'foo'; 191 testString() => 'foo';
189 testStringInterpolation() => '${0}'; 192 testStringInterpolation() => '${0}';
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 testStaticGenericMethod() { 600 testStaticGenericMethod() {
598 staticGenericMethod<int>(0); 601 staticGenericMethod<int>(0);
599 } 602 }
600 603
601 testInstanceGenericMethod() { 604 testInstanceGenericMethod() {
602 new GenericClass<int, String>.generative().genericMethod<bool>(false); 605 new GenericClass<int, String>.generative().genericMethod<bool>(false);
603 } 606 }
604 607
605 testDynamicPrivateMethodInvoke([o]) => o._privateMethod(); 608 testDynamicPrivateMethodInvoke([o]) => o._privateMethod();
606 testJSCall() => JS('int|bool', '#', null); 609 testJSCall() => JS('int|bool', '#', null);
610 @JSName('foo')
611 testNativeMethod() native;
607 ''', 612 ''',
608 'helper.dart': ''' 613 'sdk/tests/compiler/dart2js_native/helper.dart': '''
609 class Class { 614 class Class {
610 const Class.generative(); 615 const Class.generative();
611 factory Class.fact() => null; 616 factory Class.fact() => null;
612 const factory Class.redirect() = Class.generative; 617 const factory Class.redirect() = Class.generative;
613 } 618 }
614 class GenericClass<X, Y> { 619 class GenericClass<X, Y> {
615 const GenericClass.generative(); 620 const GenericClass.generative();
616 factory GenericClass.fact() => null; 621 factory GenericClass.fact() => null;
617 const factory GenericClass.redirect() = GenericClass<X, Y>.generative; 622 const factory GenericClass.redirect() = GenericClass<X, Y>.generative;
618 623
619 Map<X, T> genericMethod<T>(T arg) => { null: arg }; 624 Map<X, T> genericMethod<T>(T arg) => { null: arg };
620 } 625 }
621 typedef Typedef(); 626 typedef Typedef();
622 typedef X GenericTypedef<X, Y>(Y y); 627 typedef X GenericTypedef<X, Y>(Y y);
623 ''', 628 ''',
624 }; 629 };
625 630
626 main(List<String> args) { 631 main(List<String> args) {
627 bool fullTest = args.contains('--full'); 632 bool fullTest = args.contains('--full');
628 asyncTest(() async { 633 asyncTest(() async {
629 enableDebugMode(); 634 enableDebugMode();
630 Uri entryPoint = Uri.parse('memory:main.dart'); 635 Uri entryPoint =
636 Uri.parse('memory:sdk/tests/compiler/dart2js_native/main.dart');
631 Compiler compiler = compilerFor( 637 Compiler compiler = compilerFor(
632 entryPoint: entryPoint, 638 entryPoint: entryPoint,
633 memorySourceFiles: SOURCE, 639 memorySourceFiles: SOURCE,
634 options: [ 640 options: [
635 fullTest ? Flags.analyzeAll : Flags.analyzeOnly, 641 fullTest ? Flags.analyzeAll : Flags.analyzeOnly,
636 Flags.useKernel, 642 Flags.useKernel,
637 Flags.enableAssertMessage 643 Flags.enableAssertMessage
638 ]); 644 ]);
639 compiler.resolution.retainCachesForTesting = true; 645 compiler.resolution.retainCachesForTesting = true;
640 await compiler.run(entryPoint); 646 Expect.isTrue(await compiler.run(entryPoint));
641 JavaScriptBackend backend = compiler.backend; 647 JavaScriptBackend backend = compiler.backend;
642 KernelElementAdapter kernelElementAdapter = 648 KernelElementAdapter kernelElementAdapter =
643 new KernelWorldBuilder(compiler.reporter, backend.kernelTask.program); 649 new KernelWorldBuilder(compiler.reporter, backend.kernelTask.program);
644 650
645 checkLibrary(compiler, kernelElementAdapter, compiler.mainApp, 651 checkLibrary(compiler, kernelElementAdapter, compiler.mainApp,
646 fullTest: fullTest); 652 fullTest: fullTest);
647 if (fullTest) { 653 if (fullTest) {
648 // TODO(johnniwinther): Handle all libraries for `!fullTest`. 654 // TODO(johnniwinther): Handle all libraries for `!fullTest`.
649 compiler.libraryLoader.libraries.forEach((LibraryElement library) { 655 compiler.libraryLoader.libraries.forEach((LibraryElement library) {
650 if (library == compiler.mainApp) return; 656 if (library == compiler.mainApp) return;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 visitList(type.optionalParameterTypes), 870 visitList(type.optionalParameterTypes),
865 type.namedParameters, 871 type.namedParameters,
866 visitList(type.namedParameterTypes)); 872 visitList(type.namedParameterTypes));
867 } 873 }
868 } 874 }
869 875
870 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType]. 876 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType].
871 ResolutionDartType unalias(ResolutionDartType type) { 877 ResolutionDartType unalias(ResolutionDartType type) {
872 return const Unaliaser().visit(type); 878 return const Unaliaser().visit(type);
873 } 879 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698