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

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

Issue 2992383002: Support use of dill in TypeEnv tests (Closed)
Patch Set: Created 3 years, 4 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/elements/elements.dart' show ClassElement; 9 import 'package:compiler/src/common_elements.dart';
10 import 'package:compiler/src/elements/entities.dart' show ClassEntity;
10 import 'package:compiler/src/elements/names.dart'; 11 import 'package:compiler/src/elements/names.dart';
11 import 'package:compiler/src/universe/selector.dart'; 12 import 'package:compiler/src/universe/selector.dart';
12 import 'package:compiler/src/world.dart'; 13 import 'package:compiler/src/world.dart';
13 import '../type_test_helper.dart'; 14 import '../type_test_helper.dart';
14 15
15 void main() { 16 void main() {
16 asyncTest(() async { 17 asyncTest(() async {
17 await testClasses(); 18 await testClasses();
18 }); 19 });
19 } 20 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 newA() => new A(0); 70 newA() => new A(0);
70 newB() => new B(1); 71 newB() => new B(1);
71 newC() => new C(foo: 2); 72 newC() => new C(foo: 2);
72 newD() => new D(foo: 3); 73 newD() => new D(foo: 3);
73 newE() => new E(4); 74 newE() => new E(4);
74 newF() => new F(5); 75 newF() => new F(5);
75 """, mainSource: """ 76 """, mainSource: """
76 import 'package:js/js.dart'; 77 import 'package:js/js.dart';
77 78
78 $mainSource 79 $mainSource
79 """, useMockCompiler: false); 80 """, compileMode: CompileMode.memory);
80 Map<String, ClassElement> classEnvironment = <String, ClassElement>{}; 81 Map<String, ClassEntity> classEnvironment = <String, ClassEntity>{};
81 82
82 ClassElement registerClass(ClassElement cls) { 83 ClassEntity registerClass(ClassEntity cls) {
83 classEnvironment[cls.name] = cls; 84 classEnvironment[cls.name] = cls;
84 return cls; 85 return cls;
85 } 86 }
86 87
87 ClosedWorld world = env.closedWorld; 88 ClosedWorld world = env.closedWorld;
88 ClassElement Object_ = registerClass(world.commonElements.objectClass); 89 ElementEnvironment elementEnvironment = world.elementEnvironment;
89 ClassElement Interceptor = 90 ClassEntity Object_ = registerClass(world.commonElements.objectClass);
91 ClassEntity Interceptor =
90 registerClass(world.commonElements.jsInterceptorClass); 92 registerClass(world.commonElements.jsInterceptorClass);
91 ClassElement JavaScriptObject = 93 ClassEntity JavaScriptObject =
92 registerClass(world.commonElements.jsJavaScriptObjectClass); 94 registerClass(world.commonElements.jsJavaScriptObjectClass);
93 ClassElement A = registerClass(env.getElement('A')); 95 ClassEntity A = registerClass(env.getClass('A'));
94 ClassElement B = registerClass(env.getElement('B')); 96 ClassEntity B = registerClass(env.getClass('B'));
95 ClassElement C = registerClass(env.getElement('C')); 97 ClassEntity C = registerClass(env.getClass('C'));
96 ClassElement D = registerClass(env.getElement('D')); 98 ClassEntity D = registerClass(env.getClass('D'));
97 ClassElement E = registerClass(env.getElement('E')); 99 ClassEntity E = registerClass(env.getClass('E'));
98 ClassElement F = registerClass(env.getElement('F')); 100 ClassEntity F = registerClass(env.getClass('F'));
99 101
100 Selector nonExisting = new Selector.getter(const PublicName('nonExisting')); 102 Selector nonExisting = new Selector.getter(const PublicName('nonExisting'));
101 103
102 Expect.equals(Interceptor.superclass, Object_); 104 Expect.equals(elementEnvironment.getSuperClass(Interceptor), Object_);
103 Expect.equals(JavaScriptObject.superclass, Interceptor); 105 Expect.equals(
106 elementEnvironment.getSuperClass(JavaScriptObject), Interceptor);
104 107
105 Expect.equals(A.superclass, JavaScriptObject); 108 Expect.equals(elementEnvironment.getSuperClass(A), JavaScriptObject);
106 Expect.equals(B.superclass, JavaScriptObject); 109 Expect.equals(elementEnvironment.getSuperClass(B), JavaScriptObject);
107 Expect.equals(C.superclass, JavaScriptObject); 110 Expect.equals(elementEnvironment.getSuperClass(C), JavaScriptObject);
108 Expect.equals(D.superclass, JavaScriptObject); 111 Expect.equals(elementEnvironment.getSuperClass(D), JavaScriptObject);
109 Expect.equals(E.superclass, Object_); 112 Expect.equals(elementEnvironment.getSuperClass(E), Object_);
110 Expect.equals(F.superclass, Object_); 113 Expect.equals(elementEnvironment.getSuperClass(F), Object_);
111 114
112 Expect.isFalse(world.nativeData.isJsInteropClass(Object_)); 115 Expect.isFalse(world.nativeData.isJsInteropClass(Object_));
113 Expect.isTrue(world.nativeData.isJsInteropClass(A)); 116 Expect.isTrue(world.nativeData.isJsInteropClass(A));
114 Expect.isTrue(world.nativeData.isJsInteropClass(B)); 117 Expect.isTrue(world.nativeData.isJsInteropClass(B));
115 Expect.isTrue(world.nativeData.isJsInteropClass(C)); 118 Expect.isTrue(world.nativeData.isJsInteropClass(C));
116 Expect.isTrue(world.nativeData.isJsInteropClass(D)); 119 Expect.isTrue(world.nativeData.isJsInteropClass(D));
117 Expect.isFalse(world.nativeData.isJsInteropClass(E)); 120 Expect.isFalse(world.nativeData.isJsInteropClass(E));
118 Expect.isFalse(world.nativeData.isJsInteropClass(F)); 121 Expect.isFalse(world.nativeData.isJsInteropClass(F));
119 122
120 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(Object_)); 123 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(Object_));
121 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(A)); 124 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(A));
122 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(B)); 125 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(B));
123 Expect.isTrue(world.nativeData.isAnonymousJsInteropClass(C)); 126 Expect.isTrue(world.nativeData.isAnonymousJsInteropClass(C));
124 Expect.isTrue(world.nativeData.isAnonymousJsInteropClass(D)); 127 Expect.isTrue(world.nativeData.isAnonymousJsInteropClass(D));
125 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(E)); 128 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(E));
126 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(F)); 129 Expect.isFalse(world.nativeData.isAnonymousJsInteropClass(F));
127 130
128 Expect.equals('', world.nativeData.getJsInteropClassName(A)); 131 Expect.equals('', world.nativeData.getJsInteropClassName(A));
129 Expect.equals('BClass', world.nativeData.getJsInteropClassName(B)); 132 Expect.equals('BClass', world.nativeData.getJsInteropClassName(B));
130 Expect.equals('', world.nativeData.getJsInteropClassName(C)); 133 Expect.equals('', world.nativeData.getJsInteropClassName(C));
131 Expect.equals('', world.nativeData.getJsInteropClassName(D)); 134 Expect.equals('', world.nativeData.getJsInteropClassName(D));
132 135
133 for (String name in classEnvironment.keys) { 136 for (String name in classEnvironment.keys) {
134 ClassElement cls = classEnvironment[name]; 137 ClassEntity cls = classEnvironment[name];
135 bool isInstantiated = false; 138 bool isInstantiated = false;
136 if (directlyInstantiated.contains(name)) { 139 if (directlyInstantiated.contains(name)) {
137 isInstantiated = true; 140 isInstantiated = true;
138 Expect.isTrue( 141 Expect.isTrue(
139 world.isDirectlyInstantiated(cls), 142 world.isDirectlyInstantiated(cls),
140 "Expected $name to be directly instantiated in `${mainSource}`:" 143 "Expected $name to be directly instantiated in `${mainSource}`:"
141 "\n${world.dump(cls)}"); 144 "\n${world.dump(cls)}");
142 } 145 }
143 if (abstractlyInstantiated.contains(name)) { 146 if (abstractlyInstantiated.contains(name)) {
144 isInstantiated = true; 147 isInstantiated = true;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 195
193 await test('main() => newE();', directlyInstantiated: ['E']); 196 await test('main() => newE();', directlyInstantiated: ['E']);
194 197
195 await test('main() => newF();', directlyInstantiated: ['F']); 198 await test('main() => newF();', directlyInstantiated: ['F']);
196 199
197 await test('main() => [newD(), newE()];', 200 await test('main() => [newD(), newE()];',
198 directlyInstantiated: ['E'], 201 directlyInstantiated: ['E'],
199 abstractlyInstantiated: ['A', 'B', 'C', 'D'], 202 abstractlyInstantiated: ['A', 'B', 'C', 'D'],
200 indirectlyInstantiated: ['Object', 'Interceptor', 'JavaScriptObject']); 203 indirectlyInstantiated: ['Object', 'Interceptor', 'JavaScriptObject']);
201 } 204 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/instantiated_classes_test.dart ('k') | tests/compiler/dart2js/kernel/closed_world_from_dill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698