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

Side by Side Diff: tests/compiler/dart2js/type_inference8_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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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:async_helper/async_helper.dart"; 5 import "package:async_helper/async_helper.dart";
6 import "package:compiler/src/constants/values.dart"; 6 import "package:compiler/src/constants/values.dart";
7 import "package:compiler/src/types/types.dart"; 7 import "package:compiler/src/types/types.dart";
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'compiler_helper.dart'; 9 import 'compiler_helper.dart';
10 import 'type_mask_test_helper.dart'; 10 import 'type_mask_test_helper.dart';
(...skipping 16 matching lines...) Expand all
27 main() { 27 main() {
28 bar(foo(false)); 28 bar(foo(false));
29 bar(foo(foo(false))); 29 bar(foo(foo(false)));
30 } 30 }
31 """; 31 """;
32 32
33 Future runTest1() { 33 Future runTest1() {
34 Uri uri = new Uri(scheme: 'source'); 34 Uri uri = new Uri(scheme: 'source');
35 var compiler = compilerFor(TEST1, uri); 35 var compiler = compilerFor(TEST1, uri);
36 return compiler.run(uri).then((_) { 36 return compiler.run(uri).then((_) {
37 var commonMasks = compiler.commonMasks; 37 var commonMasks = compiler.closedWorld.commonMasks;
38 var typesInferrer = compiler.globalInference.typesInferrer; 38 var typesInferrer = compiler.globalInference.typesInferrerInternal;
39 var element = findElement(compiler, "foo"); 39 var element = findElement(compiler, "foo");
40 var mask = typesInferrer.getReturnTypeOfElement(element); 40 var mask = typesInferrer.getReturnTypeOfElement(element);
41 var falseType = 41 var falseType =
42 new ValueTypeMask(commonMasks.boolType, new FalseConstantValue()); 42 new ValueTypeMask(commonMasks.boolType, new FalseConstantValue());
43 // 'foo' should always return false 43 // 'foo' should always return false
44 Expect.equals(falseType, mask); 44 Expect.equals(falseType, mask);
45 // the argument to 'bar' is always false 45 // the argument to 'bar' is always false
46 var bar = findElement(compiler, "bar"); 46 var bar = findElement(compiler, "bar");
47 var barArg = bar.parameters.first; 47 var barArg = bar.parameters.first;
48 var barArgMask = typesInferrer.getTypeOfElement(barArg); 48 var barArgMask = typesInferrer.getTypeOfElement(barArg);
(...skipping 21 matching lines...) Expand all
70 main() { 70 main() {
71 bar(foo(5)); 71 bar(foo(5));
72 bar(foo(6)); 72 bar(foo(6));
73 } 73 }
74 """; 74 """;
75 75
76 Future runTest2() { 76 Future runTest2() {
77 Uri uri = new Uri(scheme: 'source'); 77 Uri uri = new Uri(scheme: 'source');
78 var compiler = compilerFor(TEST2, uri); 78 var compiler = compilerFor(TEST2, uri);
79 return compiler.run(uri).then((_) { 79 return compiler.run(uri).then((_) {
80 var commonMasks = compiler.commonMasks; 80 var commonMasks = compiler.closedWorld.commonMasks;
81 var typesInferrer = compiler.globalInference.typesInferrer; 81 var typesInferrer = compiler.globalInference.typesInferrerInternal;
82 var element = findElement(compiler, "foo"); 82 var element = findElement(compiler, "foo");
83 var mask = typesInferrer.getReturnTypeOfElement(element); 83 var mask = typesInferrer.getReturnTypeOfElement(element);
84 // Can't infer value for foo's return type, it could be either true or false 84 // Can't infer value for foo's return type, it could be either true or false
85 Expect.identical(commonMasks.boolType, mask); 85 Expect.identical(commonMasks.boolType, mask);
86 var bar = findElement(compiler, "bar"); 86 var bar = findElement(compiler, "bar");
87 var barArg = bar.parameters.first; 87 var barArg = bar.parameters.first;
88 var barArgMask = typesInferrer.getTypeOfElement(barArg); 88 var barArgMask = typesInferrer.getTypeOfElement(barArg);
89 // The argument to bar should have the same type as the return type of foo 89 // The argument to bar should have the same type as the return type of foo
90 Expect.identical(commonMasks.boolType, barArgMask); 90 Expect.identical(commonMasks.boolType, barArgMask);
91 var barCode = compiler.backend.getGeneratedCode(bar); 91 var barCode = compiler.backend.getGeneratedCode(bar);
92 Expect.isTrue(barCode.contains('"bbb"')); 92 Expect.isTrue(barCode.contains('"bbb"'));
93 // Still must output the print for "aaa" 93 // Still must output the print for "aaa"
94 Expect.isTrue(barCode.contains('"aaa"')); 94 Expect.isTrue(barCode.contains('"aaa"'));
95 }); 95 });
96 } 96 }
97 97
98 main() { 98 main() {
99 asyncStart(); 99 asyncStart();
100 runTest1().then((_) { 100 runTest1().then((_) {
101 return runTest2(); 101 return runTest2();
102 }).whenComplete(asyncEnd); 102 }).whenComplete(asyncEnd);
103 } 103 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/type_inference7_test.dart ('k') | tests/compiler/dart2js/type_inference_switch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698