| 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 jsinterop.world_test; | 5 library jsinterop.world_test; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 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/elements/elements.dart' | 10 import 'package:compiler/src/elements/elements.dart' |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 List<String> indirectlyInstantiated: const <String>[]}) async { | 27 List<String> indirectlyInstantiated: const <String>[]}) async { |
| 28 TypeEnvironment env = await TypeEnvironment.create( | 28 TypeEnvironment env = await TypeEnvironment.create( |
| 29 r""" | 29 r""" |
| 30 @JS() | 30 @JS() |
| 31 class A { | 31 class A { |
| 32 get foo; | 32 get foo; |
| 33 | 33 |
| 34 external A(var foo); | 34 external A(var foo); |
| 35 } | 35 } |
| 36 | 36 |
| 37 @JS() | 37 @JS('BClass') |
| 38 class B { | 38 class B { |
| 39 get foo; | 39 get foo; |
| 40 | 40 |
| 41 external B(var foo); | 41 external B(var foo); |
| 42 } | 42 } |
| 43 | 43 |
| 44 @JS() | 44 @JS() |
| 45 @anonymous | 45 @anonymous |
| 46 class C { | 46 class C { |
| 47 final foo; | 47 final foo; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 Expect.equals(Interceptor.superclass, Object_); | 109 Expect.equals(Interceptor.superclass, Object_); |
| 110 Expect.equals(JavaScriptObject.superclass, Interceptor); | 110 Expect.equals(JavaScriptObject.superclass, Interceptor); |
| 111 | 111 |
| 112 Expect.equals(A.superclass, JavaScriptObject); | 112 Expect.equals(A.superclass, JavaScriptObject); |
| 113 Expect.equals(B.superclass, JavaScriptObject); | 113 Expect.equals(B.superclass, JavaScriptObject); |
| 114 Expect.equals(C.superclass, JavaScriptObject); | 114 Expect.equals(C.superclass, JavaScriptObject); |
| 115 Expect.equals(D.superclass, JavaScriptObject); | 115 Expect.equals(D.superclass, JavaScriptObject); |
| 116 Expect.equals(E.superclass, Object_); | 116 Expect.equals(E.superclass, Object_); |
| 117 Expect.equals(F.superclass, Object_); | 117 Expect.equals(F.superclass, Object_); |
| 118 | 118 |
| 119 Expect.isFalse(backend.nativeData.isJsInteropClass(Object_)); |
| 120 Expect.isTrue(backend.nativeData.isJsInteropClass(A)); |
| 121 Expect.isTrue(backend.nativeData.isJsInteropClass(B)); |
| 122 Expect.isTrue(backend.nativeData.isJsInteropClass(C)); |
| 123 Expect.isTrue(backend.nativeData.isJsInteropClass(D)); |
| 124 Expect.isFalse(backend.nativeData.isJsInteropClass(E)); |
| 125 Expect.isFalse(backend.nativeData.isJsInteropClass(F)); |
| 126 |
| 127 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(Object_)); |
| 128 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(A)); |
| 129 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(B)); |
| 130 Expect.isTrue(backend.nativeData.isAnonymousJsInteropClass(C)); |
| 131 Expect.isTrue(backend.nativeData.isAnonymousJsInteropClass(D)); |
| 132 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(E)); |
| 133 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(F)); |
| 134 |
| 135 Expect.equals('', backend.nativeData.getJsInteropClassName(A)); |
| 136 Expect.equals('BClass', backend.nativeData.getJsInteropClassName(B)); |
| 137 Expect.equals('', backend.nativeData.getJsInteropClassName(C)); |
| 138 Expect.equals('', backend.nativeData.getJsInteropClassName(D)); |
| 139 |
| 119 for (String name in classEnvironment.keys) { | 140 for (String name in classEnvironment.keys) { |
| 120 ClassElement cls = classEnvironment[name]; | 141 ClassElement cls = classEnvironment[name]; |
| 121 bool isInstantiated = false; | 142 bool isInstantiated = false; |
| 122 if (directlyInstantiated.contains(name)) { | 143 if (directlyInstantiated.contains(name)) { |
| 123 isInstantiated = true; | 144 isInstantiated = true; |
| 124 Expect.isTrue( | 145 Expect.isTrue( |
| 125 world.isDirectlyInstantiated(cls), | 146 world.isDirectlyInstantiated(cls), |
| 126 "Expected $name to be directly instantiated in `${mainSource}`:" | 147 "Expected $name to be directly instantiated in `${mainSource}`:" |
| 127 "\n${world.dump(cls)}"); | 148 "\n${world.dump(cls)}"); |
| 128 } | 149 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 199 |
| 179 await test('main() => newE();', directlyInstantiated: ['E']); | 200 await test('main() => newE();', directlyInstantiated: ['E']); |
| 180 | 201 |
| 181 await test('main() => newF();', directlyInstantiated: ['F']); | 202 await test('main() => newF();', directlyInstantiated: ['F']); |
| 182 | 203 |
| 183 await test('main() => [newD(), newE()];', | 204 await test('main() => [newD(), newE()];', |
| 184 directlyInstantiated: ['E'], | 205 directlyInstantiated: ['E'], |
| 185 abstractlyInstantiated: ['A', 'B', 'C', 'D'], | 206 abstractlyInstantiated: ['A', 'B', 'C', 'D'], |
| 186 indirectlyInstantiated: ['Object', 'Interceptor', 'JavaScriptObject']); | 207 indirectlyInstantiated: ['Object', 'Interceptor', 'JavaScriptObject']); |
| 187 } | 208 } |
| OLD | NEW |