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

Side by Side Diff: tests/compiler/dart2js/jsinterop/world_test.dart

Issue 2863073003: Access NativeData only through ClosedWorld (Closed)
Patch Set: 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
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 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_)); 119 Expect.isFalse(world.nativeData.isJsInteropClass(Object_));
120 Expect.isTrue(backend.nativeData.isJsInteropClass(A)); 120 Expect.isTrue(world.nativeData.isJsInteropClass(A));
121 Expect.isTrue(backend.nativeData.isJsInteropClass(B)); 121 Expect.isTrue(world.nativeData.isJsInteropClass(B));
122 Expect.isTrue(backend.nativeData.isJsInteropClass(C)); 122 Expect.isTrue(world.nativeData.isJsInteropClass(C));
123 Expect.isTrue(backend.nativeData.isJsInteropClass(D)); 123 Expect.isTrue(world.nativeData.isJsInteropClass(D));
124 Expect.isFalse(backend.nativeData.isJsInteropClass(E)); 124 Expect.isFalse(world.nativeData.isJsInteropClass(E));
125 Expect.isFalse(backend.nativeData.isJsInteropClass(F)); 125 Expect.isFalse(world.nativeData.isJsInteropClass(F));
126 126
127 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(Object_)); 127 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(Object_));
128 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(A)); 128 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(A));
129 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(B)); 129 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(B));
130 Expect.isTrue(backend.nativeData.isAnonymousJsInteropClass(C)); 130 Expect.isTrue(world.nativeData.isAnonymousJsInteropClass(C));
131 Expect.isTrue(backend.nativeData.isAnonymousJsInteropClass(D)); 131 Expect.isTrue(world.nativeData.isAnonymousJsInteropClass(D));
132 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(E)); 132 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(E));
133 Expect.isFalse(backend.nativeData.isAnonymousJsInteropClass(F)); 133 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(F));
134 134
135 Expect.equals('', backend.nativeData.getJsInteropClassName(A)); 135 Expect.equals('', world.nativeData.getJsInteropClassName(A));
136 Expect.equals('BClass', backend.nativeData.getJsInteropClassName(B)); 136 Expect.equals('BClass', world.nativeData.getJsInteropClassName(B));
137 Expect.equals('', backend.nativeData.getJsInteropClassName(C)); 137 Expect.equals('', world.nativeData.getJsInteropClassName(C));
138 Expect.equals('', backend.nativeData.getJsInteropClassName(D)); 138 Expect.equals('', world.nativeData.getJsInteropClassName(D));
139 139
140 for (String name in classEnvironment.keys) { 140 for (String name in classEnvironment.keys) {
141 ClassElement cls = classEnvironment[name]; 141 ClassElement cls = classEnvironment[name];
142 bool isInstantiated = false; 142 bool isInstantiated = false;
143 if (directlyInstantiated.contains(name)) { 143 if (directlyInstantiated.contains(name)) {
144 isInstantiated = true; 144 isInstantiated = true;
145 Expect.isTrue( 145 Expect.isTrue(
146 world.isDirectlyInstantiated(cls), 146 world.isDirectlyInstantiated(cls),
147 "Expected $name to be directly instantiated in `${mainSource}`:" 147 "Expected $name to be directly instantiated in `${mainSource}`:"
148 "\n${world.dump(cls)}"); 148 "\n${world.dump(cls)}");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 await test('main() => newE();', directlyInstantiated: ['E']); 200 await test('main() => newE();', directlyInstantiated: ['E']);
201 201
202 await test('main() => newF();', directlyInstantiated: ['F']); 202 await test('main() => newF();', directlyInstantiated: ['F']);
203 203
204 await test('main() => [newD(), newE()];', 204 await test('main() => [newD(), newE()];',
205 directlyInstantiated: ['E'], 205 directlyInstantiated: ['E'],
206 abstractlyInstantiated: ['A', 'B', 'C', 'D'], 206 abstractlyInstantiated: ['A', 'B', 'C', 'D'],
207 indirectlyInstantiated: ['Object', 'Interceptor', 'JavaScriptObject']); 207 indirectlyInstantiated: ['Object', 'Interceptor', 'JavaScriptObject']);
208 } 208 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/universe/element_world_builder.dart ('k') | tests/compiler/dart2js/serialization/native_data_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698