| OLD | NEW |
| 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/common.dart'; | 8 import 'package:compiler/src/common.dart'; |
| 9 import 'package:compiler/src/common_elements.dart'; | 9 import 'package:compiler/src/common_elements.dart'; |
| 10 import 'package:compiler/src/common/names.dart'; | 10 import 'package:compiler/src/common/names.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 import 'package:compiler/src/universe/feature.dart'; | 23 import 'package:compiler/src/universe/feature.dart'; |
| 24 import 'package:compiler/src/universe/use.dart'; | 24 import 'package:compiler/src/universe/use.dart'; |
| 25 import 'package:compiler/src/util/util.dart'; | 25 import 'package:compiler/src/util/util.dart'; |
| 26 import '../equivalence/check_helpers.dart'; | 26 import '../equivalence/check_helpers.dart'; |
| 27 import 'compiler_helper.dart'; | 27 import 'compiler_helper.dart'; |
| 28 import 'test_helpers.dart'; | 28 import 'test_helpers.dart'; |
| 29 | 29 |
| 30 const Map<String, String> SOURCE = const <String, String>{ | 30 const Map<String, String> SOURCE = const <String, String>{ |
| 31 // Pretend this is a dart2js_native test to allow use of 'native' keyword. | 31 // Pretend this is a dart2js_native test to allow use of 'native' keyword. |
| 32 'sdk/tests/compiler/dart2js_native/main.dart': r''' | 32 'sdk/tests/compiler/dart2js_native/main.dart': r''' |
| 33 import 'dart:_foreign_helper'; | 33 @JS() |
| 34 library test; |
| 35 |
| 36 import 'dart:_foreign_helper' as foreign show JS; |
| 37 import 'dart:_foreign_helper' hide JS; |
| 34 import 'dart:_js_helper'; | 38 import 'dart:_js_helper'; |
| 35 import 'dart:_interceptors'; | 39 import 'dart:_interceptors'; |
| 36 import 'dart:_native_typed_data'; | 40 import 'dart:_native_typed_data'; |
| 37 import 'dart:indexed_db'; | 41 import 'dart:indexed_db'; |
| 38 import 'dart:html'; | 42 import 'dart:html'; |
| 39 import 'dart:html_common'; | 43 import 'dart:html_common'; |
| 40 import 'dart:math'; | 44 import 'dart:math'; |
| 41 import 'dart:typed_data'; | 45 import 'dart:typed_data'; |
| 42 import 'dart:web_sql'; | 46 import 'dart:web_sql'; |
| 47 import 'package:js/js.dart'; |
| 43 import 'helper.dart'; | 48 import 'helper.dart'; |
| 44 | 49 |
| 45 main() { | 50 main() { |
| 46 testEmpty(); | 51 testEmpty(); |
| 47 testNull(); | 52 testNull(); |
| 48 testTrue(); | 53 testTrue(); |
| 49 testFalse(); | 54 testFalse(); |
| 50 testInt(); | 55 testInt(); |
| 51 testDouble(); | 56 testDouble(); |
| 52 testString(); | 57 testString(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 testDynamicPrivateMethodInvoke(); | 200 testDynamicPrivateMethodInvoke(); |
| 196 testJSCall(); | 201 testJSCall(); |
| 197 testNativeMethod(); | 202 testNativeMethod(); |
| 198 testNativeMethodCreates(); | 203 testNativeMethodCreates(); |
| 199 testNativeMethodReturns(); | 204 testNativeMethodReturns(); |
| 200 testNativeField(null); | 205 testNativeField(null); |
| 201 testMixinInstantiation(); | 206 testMixinInstantiation(); |
| 202 testNamedMixinInstantiation(); | 207 testNamedMixinInstantiation(); |
| 203 testGenericMixinInstantiation(); | 208 testGenericMixinInstantiation(); |
| 204 testGenericNamedMixinInstantiation(); | 209 testGenericNamedMixinInstantiation(); |
| 210 testJsInteropMethod(); |
| 211 testJsInteropClass(); |
| 205 } | 212 } |
| 206 | 213 |
| 207 testEmpty() {} | 214 testEmpty() {} |
| 208 testNull() => null; | 215 testNull() => null; |
| 209 testTrue() => true; | 216 testTrue() => true; |
| 210 testFalse() => false; | 217 testFalse() => false; |
| 211 testInt() => 42; | 218 testInt() => 42; |
| 212 testDouble() => 37.5; | 219 testDouble() => 37.5; |
| 213 testString() => 'foo'; | 220 testString() => 'foo'; |
| 214 testStringInterpolation() => '${0}'; | 221 testStringInterpolation() => '${0}'; |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 List<T> staticGenericMethod<T>(T arg) => [arg]; | 669 List<T> staticGenericMethod<T>(T arg) => [arg]; |
| 663 testStaticGenericMethod() { | 670 testStaticGenericMethod() { |
| 664 staticGenericMethod<int>(0); | 671 staticGenericMethod<int>(0); |
| 665 } | 672 } |
| 666 | 673 |
| 667 testInstanceGenericMethod() { | 674 testInstanceGenericMethod() { |
| 668 new GenericClass<int, String>.generative().genericMethod<bool>(false); | 675 new GenericClass<int, String>.generative().genericMethod<bool>(false); |
| 669 } | 676 } |
| 670 | 677 |
| 671 testDynamicPrivateMethodInvoke([o]) => o._privateMethod(); | 678 testDynamicPrivateMethodInvoke([o]) => o._privateMethod(); |
| 672 testJSCall() => JS('int|bool|NativeUint8List|Rectangle|IdbFactory|' | 679 testJSCall() => foreign.JS('int|bool|NativeUint8List|Rectangle|IdbFactory|' |
| 673 'SqlDatabase|TypedData|ContextAttributes', '#', null); | 680 'SqlDatabase|TypedData|ContextAttributes', '#', null); |
| 674 @JSName('foo') | 681 @JSName('foo') |
| 675 @SupportedBrowser(SupportedBrowser.CHROME) | 682 @SupportedBrowser(SupportedBrowser.CHROME) |
| 676 testNativeMethod() native; | 683 testNativeMethod() native; |
| 677 @Creates('int|Null|JSArray') | 684 @Creates('int|Null|JSArray') |
| 678 testNativeMethodCreates() native; | 685 testNativeMethodCreates() native; |
| 679 @Returns('String|Null|JSArray') | 686 @Returns('String|Null|JSArray') |
| 680 testNativeMethodReturns() native; | 687 testNativeMethodReturns() native; |
| 681 | 688 |
| 682 @Native("NativeClass") | 689 @Native("NativeClass") |
| 683 class NativeClass { | 690 class NativeClass { |
| 684 @annotation_Creates_SerializedScriptValue | 691 @annotation_Creates_SerializedScriptValue |
| 685 final Object field; | 692 final Object field; |
| 686 | 693 |
| 687 factory NativeClass._() { throw new UnsupportedError("Not supported"); } | 694 factory NativeClass._() { throw new UnsupportedError("Not supported"); } |
| 688 } | 695 } |
| 689 testNativeField(NativeClass c) => c.field; | 696 testNativeField(NativeClass c) => c.field; |
| 690 testMixinInstantiation() => new Sub(); | 697 testMixinInstantiation() => new Sub(); |
| 691 testNamedMixinInstantiation() => new NamedMixin(); | 698 testNamedMixinInstantiation() => new NamedMixin(); |
| 692 testGenericMixinInstantiation() => new GenericSub<int, String>(); | 699 testGenericMixinInstantiation() => new GenericSub<int, String>(); |
| 693 testGenericNamedMixinInstantiation() => new GenericNamedMixin<int, String>(); | 700 testGenericNamedMixinInstantiation() => new GenericNamedMixin<int, String>(); |
| 701 |
| 702 @JS() |
| 703 external int testJsInteropMethod(); |
| 704 |
| 705 @JS() |
| 706 class JsInteropClass { |
| 707 @JS() |
| 708 external double method(); |
| 709 } |
| 710 |
| 711 testJsInteropClass() => new JsInteropClass().method(); |
| 694 ''', | 712 ''', |
| 695 'sdk/tests/compiler/dart2js_native/helper.dart': ''' | 713 'sdk/tests/compiler/dart2js_native/helper.dart': ''' |
| 696 import 'dart:_js_helper'; | 714 import 'dart:_js_helper'; |
| 697 class Class { | 715 class Class { |
| 698 const Class.generative(); | 716 const Class.generative(); |
| 699 factory Class.fact() => null; | 717 factory Class.fact() => null; |
| 700 const factory Class.redirect() = Class.generative; | 718 const factory Class.redirect() = Class.generative; |
| 701 } | 719 } |
| 702 class GenericClass<X, Y> { | 720 class GenericClass<X, Y> { |
| 703 const GenericClass.generative(); | 721 const GenericClass.generative(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 builder.registerFeature(Feature.THROW_EXPRESSION); | 904 builder.registerFeature(Feature.THROW_EXPRESSION); |
| 887 break; | 905 break; |
| 888 default: | 906 default: |
| 889 builder.registerFeature(feature); | 907 builder.registerFeature(feature); |
| 890 break; | 908 break; |
| 891 } | 909 } |
| 892 } | 910 } |
| 893 impact.nativeData.forEach(builder.registerNativeData); | 911 impact.nativeData.forEach(builder.registerNativeData); |
| 894 return builder; | 912 return builder; |
| 895 } | 913 } |
| OLD | NEW |