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

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

Issue 2488353004: Remove Compiler access from ResolutionEnqueuer (Closed)
Patch Set: Updated cf. comments. Created 4 years, 1 month 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import "package:async_helper/async_helper.dart"; 6 import "package:async_helper/async_helper.dart";
7 import 'compiler_helper.dart'; 7 import 'compiler_helper.dart';
8 8
9 const String TEST = """ 9 const String TEST = """
10 class A { 10 class A {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Test trusting types of tear off closures. 43 // Test trusting types of tear off closures.
44 print(a.tear("42")); 44 print(a.tear("42"));
45 print(a.tear(42)); 45 print(a.tear(42));
46 } 46 }
47 """; 47 """;
48 48
49 void main() { 49 void main() {
50 Uri uri = new Uri(scheme: 'source'); 50 Uri uri = new Uri(scheme: 'source');
51 var compiler = compilerFor(TEST, uri, trustTypeAnnotations: true); 51 var compiler = compilerFor(TEST, uri, trustTypeAnnotations: true);
52 asyncTest(() => compiler.run(uri).then((_) { 52 asyncTest(() => compiler.run(uri).then((_) {
53 var typesInferrer = compiler.globalInference.typesInferrer; 53 var typesInferrer = compiler.globalInference.typesInferrerInternal;
54 54
55 ClassElement classA = findElement(compiler, "A"); 55 ClassElement classA = findElement(compiler, "A");
56 56
57 checkReturn(String name, TypeMask type) { 57 checkReturn(String name, TypeMask type) {
58 var element = classA.lookupMember(name); 58 var element = classA.lookupMember(name);
59 var mask = typesInferrer.getReturnTypeOfElement(element); 59 var mask = typesInferrer.getReturnTypeOfElement(element);
60 Expect.isTrue(type.containsMask( 60 Expect.isTrue(type.containsMask(
61 typesInferrer.getReturnTypeOfElement(element), 61 typesInferrer.getReturnTypeOfElement(element),
62 compiler.closedWorld)); 62 compiler.closedWorld));
63 } 63 }
64 64
65 checkType(String name, type) { 65 checkType(String name, type) {
66 var element = classA.lookupMember(name); 66 var element = classA.lookupMember(name);
67 Expect.isTrue(type.containsMask( 67 Expect.isTrue(type.containsMask(
68 typesInferrer.getTypeOfElement(element), compiler.closedWorld)); 68 typesInferrer.getTypeOfElement(element), compiler.closedWorld));
69 } 69 }
70 70
71 var intMask = new TypeMask.subtype( 71 var intMask = new TypeMask.subtype(
72 compiler.coreClasses.intClass, compiler.closedWorld); 72 compiler.coreClasses.intClass, compiler.closedWorld);
73 73
74 checkReturn('foo', intMask); 74 checkReturn('foo', intMask);
75 checkReturn('faa', intMask); 75 checkReturn('faa', intMask);
76 checkType('aField', intMask); 76 checkType('aField', intMask);
77 checkReturn('bar', intMask); 77 checkReturn('bar', intMask);
78 checkReturn('baz', intMask); 78 checkReturn('baz', intMask);
79 checkReturn('tear', intMask); 79 checkReturn('tear', intMask);
80 })); 80 }));
81 } 81 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/simple_inferrer_unregister_call_test.dart ('k') | tests/compiler/dart2js/type_combination_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698