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

Side by Side Diff: tests/compiler/dart2js/lookup_member_test.dart

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 subtype_test; 5 library subtype_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 'type_test_helper.dart'; 9 import 'type_test_helper.dart';
9 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; 10 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t" 11 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"
11 show Element, ClassElement; 12 show Element, ClassElement;
12 13
13 void main() { 14 void main() {
14 test(); 15 test();
15 } 16 }
16 17
17 void test() { 18 void test() {
18 var env = new TypeEnvironment(r""" 19 asyncTest(() => TypeEnvironment.create(r"""
19 class A<T> { 20 class A<T> {
20 T foo; 21 T foo;
21 } 22 }
22 class B<S> extends A<A<S>> { 23 class B<S> extends A<A<S>> {
23 S bar; 24 S bar;
24 } 25 }
25 class C<U> extends B<String> with D<B<U>> { 26 class C<U> extends B<String> with D<B<U>> {
26 U baz; 27 U baz;
27 } 28 }
28 class D<V> { 29 class D<V> {
29 V boz; 30 V boz;
30 } 31 }
31 """); 32 """).then((env) {
33 void expect(DartType receiverType, String memberName,
34 DartType expectedType) {
35 Member member = receiverType.lookupMember(env.sourceString(memberName));
36 Expect.isNotNull(member);
37 DartType memberType = member.computeType(env.compiler);
38 Expect.equals(expectedType, memberType,
39 'Wrong member type for $receiverType.$memberName.');
40 }
32 41
33 void expect(DartType receiverType, String memberName, DartType expectedType) { 42 DartType int_ = env['int'];
34 Member member = receiverType.lookupMember(env.sourceString(memberName)); 43 DartType String_ = env['String'];
35 Expect.isNotNull(member);
36 DartType memberType = member.computeType(env.compiler);
37 Expect.equals(expectedType, memberType,
38 'Wrong member type for $receiverType.$memberName.');
39 }
40 44
41 DartType int_ = env['int']; 45 ClassElement A = env.getElement('A');
42 DartType String_ = env['String']; 46 DartType T = A.typeVariables.head;
47 DartType A_T = A.thisType;
48 expect(A_T, 'foo', T);
43 49
44 ClassElement A = env.getElement('A'); 50 DartType A_int = instantiate(A, [int_]);
45 DartType T = A.typeVariables.head; 51 expect(A_int, 'foo', int_);
46 DartType A_T = A.thisType;
47 expect(A_T, 'foo', T);
48 52
49 DartType A_int = instantiate(A, [int_]); 53 ClassElement B = env.getElement('B');
50 expect(A_int, 'foo', int_); 54 DartType S = B.typeVariables.head;
55 DartType B_S = B.thisType;
56 expect(B_S, 'foo', instantiate(A, [S]));
57 expect(B_S, 'bar', S);
51 58
52 ClassElement B = env.getElement('B'); 59 DartType B_int = instantiate(B, [int_]);
53 DartType S = B.typeVariables.head; 60 expect(B_int, 'foo', A_int);
54 DartType B_S = B.thisType; 61 expect(B_int, 'bar', int_);
55 expect(B_S, 'foo', instantiate(A, [S]));
56 expect(B_S, 'bar', S);
57 62
58 DartType B_int = instantiate(B, [int_]); 63 ClassElement C = env.getElement('C');
59 expect(B_int, 'foo', A_int); 64 DartType U = C.typeVariables.head;
60 expect(B_int, 'bar', int_); 65 DartType C_U = C.thisType;
66 expect(C_U, 'foo', instantiate(A, [String_]));
67 expect(C_U, 'bar', String_);
68 expect(C_U, 'baz', U);
69 expect(C_U, 'boz', instantiate(B, [U]));
61 70
62 ClassElement C = env.getElement('C'); 71 DartType C_int = instantiate(C, [int_]);
63 DartType U = C.typeVariables.head; 72 expect(C_int, 'foo', instantiate(A, [String_]));
64 DartType C_U = C.thisType; 73 expect(C_int, 'bar', String_);
65 expect(C_U, 'foo', instantiate(A, [String_])); 74 expect(C_int, 'baz', int_);
66 expect(C_U, 'bar', String_); 75 expect(C_int, 'boz', instantiate(B, [int_]));
67 expect(C_U, 'baz', U); 76 }));
68 expect(C_U, 'boz', instantiate(B, [U]));
69
70 DartType C_int = instantiate(C, [int_]);
71 expect(C_int, 'foo', instantiate(A, [String_]));
72 expect(C_int, 'bar', String_);
73 expect(C_int, 'baz', int_);
74 expect(C_int, 'boz', instantiate(B, [int_]));
75 } 77 }
76 78
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/list_tracer_test.dart ('k') | tests/compiler/dart2js/memory_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698