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

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

Issue 1182913003: Split TypedSelector into Selector and TypeMask. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 5 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 'dart:async'; 5 import 'dart:async';
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'package:compiler/src/types/types.dart'; 8 import 'package:compiler/src/types/types.dart';
9 import 'package:compiler/src/inferrer/concrete_types_inferrer.dart'; 9 import 'package:compiler/src/inferrer/concrete_types_inferrer.dart';
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 * Checks that [: className#fieldName :]'s inferred type is the unknown 137 * Checks that [: className#fieldName :]'s inferred type is the unknown
138 * concrete type. 138 * concrete type.
139 */ 139 */
140 void checkFieldHasUknownType(String className, String fieldName) { 140 void checkFieldHasUknownType(String className, String fieldName) {
141 Expect.isTrue( 141 Expect.isTrue(
142 inferrer.inferredFieldTypes[findField(className, fieldName)] 142 inferrer.inferredFieldTypes[findField(className, fieldName)]
143 .isUnknown()); 143 .isUnknown());
144 } 144 }
145 145
146 /** Checks that the inferred type for [selector] is [mask]. */ 146 /** Checks that the inferred type for [selector] is [mask]. */
147 void checkSelectorHasType(Selector selector, TypeMask mask) { 147 void checkSelectorHasType(Selector selector,
148 Expect.equals(mask, inferrer.getTypeOfSelector(selector)); 148 TypeMask mask,
149 TypeMask expectedMask) {
150 Expect.equals(expectedMask, inferrer.getTypeOfSelector(selector, mask));
149 } 151 }
150 } 152 }
151 153
152 const String DYNAMIC = '"__dynamic_for_test"'; 154 const String DYNAMIC = '"__dynamic_for_test"';
153 155
154 Future<AnalysisResult> analyze(String code, {int maxConcreteTypeSize: 1000}) { 156 Future<AnalysisResult> analyze(String code, {int maxConcreteTypeSize: 1000}) {
155 Uri uri = new Uri(scheme: 'dart', path: 'test'); 157 Uri uri = new Uri(scheme: 'dart', path: 'test');
156 MockCompiler compiler = new MockCompiler.internal( 158 MockCompiler compiler = new MockCompiler.internal(
157 enableConcreteTypeInference: true, 159 enableConcreteTypeInference: true,
158 maxConcreteTypeSize: maxConcreteTypeSize); 160 maxConcreteTypeSize: maxConcreteTypeSize);
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 ClassElement c = findElement(result.compiler, 'C'); 1643 ClassElement c = findElement(result.compiler, 'C');
1642 ClassElement xy = findElement(result.compiler, 'XY'); 1644 ClassElement xy = findElement(result.compiler, 'XY');
1643 ClassElement x = findElement(result.compiler, 'X'); 1645 ClassElement x = findElement(result.compiler, 'X');
1644 ClassElement y = findElement(result.compiler, 'Y'); 1646 ClassElement y = findElement(result.compiler, 'Y');
1645 ClassElement z = findElement(result.compiler, 'Z'); 1647 ClassElement z = findElement(result.compiler, 'Z');
1646 1648
1647 Selector foo = new Selector.call("foo", null, 0); 1649 Selector foo = new Selector.call("foo", null, 0);
1648 1650
1649 result.checkSelectorHasType( 1651 result.checkSelectorHasType(
1650 foo, 1652 foo,
1653 null,
1651 new TypeMask.unionOf([a, b, c] 1654 new TypeMask.unionOf([a, b, c]
1652 .map((cls) => new TypeMask.nonNullExact(cls, world)), 1655 .map((cls) => new TypeMask.nonNullExact(cls, world)),
1653 result.compiler.world)); 1656 result.compiler.world));
1654 result.checkSelectorHasType( 1657 result.checkSelectorHasType(
1655 new TypedSelector.subclass(x, foo, world), 1658 foo,
1659 new TypeMask.subclass(x, world),
1656 new TypeMask.nonNullExact(b, world)); 1660 new TypeMask.nonNullExact(b, world));
1657 result.checkSelectorHasType( 1661 result.checkSelectorHasType(
1658 new TypedSelector.subclass(y, foo, world), 1662 foo,
1663 new TypeMask.subclass(y, world),
1659 new TypeMask.nonNullExact(c, world)); 1664 new TypeMask.nonNullExact(c, world));
1660 result.checkSelectorHasType( 1665 result.checkSelectorHasType(
1661 new TypedSelector.subclass(z, foo, world), 1666 foo,
1667 new TypeMask.subclass(z, world),
1662 new TypeMask.nonNullExact(a, world)); 1668 new TypeMask.nonNullExact(a, world));
1663 result.checkSelectorHasType( 1669 result.checkSelectorHasType(
1664 new TypedSelector.subclass(xy, foo, world), 1670 foo,
1671 new TypeMask.subclass(xy, world),
1665 new TypeMask.unionOf([b, c].map((cls) => 1672 new TypeMask.unionOf([b, c].map((cls) =>
1666 new TypeMask.nonNullExact(cls, world)), world)); 1673 new TypeMask.nonNullExact(cls, world)), world));
1667 1674
1668 result.checkSelectorHasType(new Selector.call("bar", null, 0), null); 1675 result.checkSelectorHasType(new Selector.call("bar", null, 0), null, null);
1669 }); 1676 });
1670 } 1677 }
1671 1678
1672 testEqualsNullSelector() { 1679 testEqualsNullSelector() {
1673 final String source = r""" 1680 final String source = r"""
1674 main() { 1681 main() {
1675 1 == null; 1682 1 == null;
1676 } 1683 }
1677 """; 1684 """;
1678 return analyze(source).then((result) { 1685 return analyze(source).then((result) {
1679 ClassElement bool = result.compiler.backend.boolImplementation; 1686 ClassElement bool = result.compiler.backend.boolImplementation;
1680 result.checkSelectorHasType(new Selector.binaryOperator('=='), 1687 result.checkSelectorHasType(new Selector.binaryOperator('=='),
1688 null,
1681 new TypeMask.nonNullExact(bool, 1689 new TypeMask.nonNullExact(bool,
1682 result.compiler.world)); 1690 result.compiler.world));
1683 }); 1691 });
1684 } 1692 }
1685 1693
1686 testMixins() { 1694 testMixins() {
1687 final String source = r""" 1695 final String source = r"""
1688 class A { 1696 class A {
1689 foo() => "abc"; 1697 foo() => "abc";
1690 get x => 42; 1698 get x => 42;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 testClosures10, 2143 testClosures10,
2136 testClosures11, 2144 testClosures11,
2137 testClosures12, 2145 testClosures12,
2138 testRefinement, 2146 testRefinement,
2139 testDefaultArguments, 2147 testDefaultArguments,
2140 testSuperConstructorCall, 2148 testSuperConstructorCall,
2141 testSuperConstructorCall2, 2149 testSuperConstructorCall2,
2142 testSuperConstructorCall3, 2150 testSuperConstructorCall3,
2143 ], (f) => f())); 2151 ], (f) => f()));
2144 } 2152 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/compiler_helper.dart ('k') | tests/compiler/dart2js/gvn_dynamic_field_get_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698