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

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

Issue 552253002: Adapt TypeMask tests to new TypeMask interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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) 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/implementation/types/types.dart'; 8 import 'package:compiler/implementation/types/types.dart';
9 import 'package:compiler/implementation/inferrer/concrete_types_inferrer.dart'; 9 import 'package:compiler/implementation/inferrer/concrete_types_inferrer.dart';
10 10
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 1571
1572 final nullSingleton = 1572 final nullSingleton =
1573 result.compiler.typesTask.concreteTypesInferrer.singletonConcreteType( 1573 result.compiler.typesTask.concreteTypesInferrer.singletonConcreteType(
1574 new NullBaseType()); 1574 new NullBaseType());
1575 1575
1576 singleton(ClassElement element) { 1576 singleton(ClassElement element) {
1577 return result.compiler.typesTask.concreteTypesInferrer 1577 return result.compiler.typesTask.concreteTypesInferrer
1578 .singletonConcreteType(new ClassBaseType(element)); 1578 .singletonConcreteType(new ClassBaseType(element));
1579 } 1579 }
1580 1580
1581 var world = result.compiler.world;
1582
1581 ClassElement a = findElement(result.compiler, 'A'); 1583 ClassElement a = findElement(result.compiler, 'A');
1582 ClassElement b = findElement(result.compiler, 'B'); 1584 ClassElement b = findElement(result.compiler, 'B');
1583 ClassElement c = findElement(result.compiler, 'C'); 1585 ClassElement c = findElement(result.compiler, 'C');
1584 ClassElement d = findElement(result.compiler, 'D'); 1586 ClassElement d = findElement(result.compiler, 'D');
1585 1587
1586 for (ClassElement cls in [a, b, c, d]) { 1588 for (ClassElement cls in [a, b, c, d]) {
1587 Expect.equals(convert(singleton(cls)), 1589 Expect.equals(convert(singleton(cls)),
1588 new TypeMask.nonNullExact(cls)); 1590 new TypeMask.nonNullExact(cls, world));
1589 } 1591 }
1590 1592
1591 for (ClassElement cls in [a, b, c, d]) { 1593 for (ClassElement cls in [a, b, c, d]) {
1592 Expect.equals(convert(singleton(cls).union(nullSingleton)), 1594 Expect.equals(convert(singleton(cls).union(nullSingleton)),
1593 new TypeMask.exact(cls)); 1595 new TypeMask.exact(cls, world));
1594 } 1596 }
1595 1597
1596 Expect.equals(convert(singleton(a).union(singleton(b))), 1598 Expect.equals(convert(singleton(a).union(singleton(b))),
1597 new TypeMask.nonNullSubclass(a, result.compiler.world)); 1599 new TypeMask.nonNullSubclass(a, world));
1598 1600
1599 Expect.equals( 1601 Expect.equals(
1600 convert(singleton(a).union(singleton(b)).union(nullSingleton)), 1602 convert(singleton(a).union(singleton(b)).union(nullSingleton)),
1601 new TypeMask.subclass(a, result.compiler.world)); 1603 new TypeMask.subclass(a, world));
1602 1604
1603 Expect.equals( 1605 Expect.equals(
1604 simplify(convert(singleton(b).union(singleton(d))), result.compiler), 1606 simplify(convert(singleton(b).union(singleton(d))), result.compiler),
1605 new TypeMask.nonNullSubtype(a, result.compiler.world)); 1607 new TypeMask.nonNullSubtype(a, world));
1606 }); 1608 });
1607 } 1609 }
1608 1610
1609 testSelectors() { 1611 testSelectors() {
1610 final String source = r""" 1612 final String source = r"""
1611 // ABC <--- A 1613 // ABC <--- A
1612 // `- BC <--- B 1614 // `- BC <--- B
1613 // `- C 1615 // `- C
1614 1616
1615 class ABC {} 1617 class ABC {}
1616 class A extends ABC {} 1618 class A extends ABC {}
1617 class BC extends ABC {} 1619 class BC extends ABC {}
1618 class B extends BC {} 1620 class B extends BC {}
1619 class C extends BC {} 1621 class C extends BC {}
1620 1622
1621 class XY {} 1623 class XY {}
1622 class X extends XY { foo() => new B(); } 1624 class X extends XY { foo() => new B(); }
1623 class Y extends XY { foo() => new C(); } 1625 class Y extends XY { foo() => new C(); }
1624 class Z { foo() => new A(); } 1626 class Z { foo() => new A(); }
1625 1627
1626 main() { 1628 main() {
1627 new X().foo(); 1629 new X().foo();
1628 new Y().foo(); 1630 new Y().foo();
1629 new Z().foo(); 1631 new Z().foo();
1630 } 1632 }
1631 """; 1633 """;
1632 return analyze(source).then((result) { 1634 return analyze(source).then((result) {
1633 1635
1634 1636 var world = result.compiler.world;
1635 1637
1636 ClassElement a = findElement(result.compiler, 'A'); 1638 ClassElement a = findElement(result.compiler, 'A');
1637 ClassElement b = findElement(result.compiler, 'B'); 1639 ClassElement b = findElement(result.compiler, 'B');
1638 ClassElement c = findElement(result.compiler, 'C'); 1640 ClassElement c = findElement(result.compiler, 'C');
1639 ClassElement xy = findElement(result.compiler, 'XY'); 1641 ClassElement xy = findElement(result.compiler, 'XY');
1640 ClassElement x = findElement(result.compiler, 'X'); 1642 ClassElement x = findElement(result.compiler, 'X');
1641 ClassElement y = findElement(result.compiler, 'Y'); 1643 ClassElement y = findElement(result.compiler, 'Y');
1642 ClassElement z = findElement(result.compiler, 'Z'); 1644 ClassElement z = findElement(result.compiler, 'Z');
1643 1645
1644 Selector foo = new Selector.call("foo", null, 0); 1646 Selector foo = new Selector.call("foo", null, 0);
1645 1647
1646 result.checkSelectorHasType( 1648 result.checkSelectorHasType(
1647 foo, 1649 foo,
1648 new TypeMask.unionOf([a, b, c] 1650 new TypeMask.unionOf([a, b, c]
1649 .map((cls) => new TypeMask.nonNullExact(cls)), 1651 .map((cls) => new TypeMask.nonNullExact(cls, world)),
1650 result.compiler.world)); 1652 result.compiler.world));
1651 result.checkSelectorHasType( 1653 result.checkSelectorHasType(
1652 new TypedSelector.subclass(x, foo, result.compiler.world), 1654 new TypedSelector.subclass(x, foo, world),
1653 new TypeMask.nonNullExact(b)); 1655 new TypeMask.nonNullExact(b, world));
1654 result.checkSelectorHasType( 1656 result.checkSelectorHasType(
1655 new TypedSelector.subclass(y, foo, result.compiler.world), 1657 new TypedSelector.subclass(y, foo, world),
1656 new TypeMask.nonNullExact(c)); 1658 new TypeMask.nonNullExact(c, world));
1657 result.checkSelectorHasType( 1659 result.checkSelectorHasType(
1658 new TypedSelector.subclass(z, foo, result.compiler.world), 1660 new TypedSelector.subclass(z, foo, world),
1659 new TypeMask.nonNullExact(a)); 1661 new TypeMask.nonNullExact(a, world));
1660 result.checkSelectorHasType( 1662 result.checkSelectorHasType(
1661 new TypedSelector.subclass(xy, foo, result.compiler.world), 1663 new TypedSelector.subclass(xy, foo, world),
1662 new TypeMask.unionOf([b, c].map((cls) => 1664 new TypeMask.unionOf([b, c].map((cls) =>
1663 new TypeMask.nonNullExact(cls)), result.compiler.world)); 1665 new TypeMask.nonNullExact(cls, world)), world));
1664 1666
1665 result.checkSelectorHasType(new Selector.call("bar", null, 0), null); 1667 result.checkSelectorHasType(new Selector.call("bar", null, 0), null);
1666 }); 1668 });
1667 } 1669 }
1668 1670
1669 testEqualsNullSelector() { 1671 testEqualsNullSelector() {
1670 final String source = r""" 1672 final String source = r"""
1671 main() { 1673 main() {
1672 1 == null; 1674 1 == null;
1673 } 1675 }
1674 """; 1676 """;
1675 return analyze(source).then((result) { 1677 return analyze(source).then((result) {
1676 ClassElement bool = result.compiler.backend.boolImplementation; 1678 ClassElement bool = result.compiler.backend.boolImplementation;
1677 result.checkSelectorHasType(new Selector.binaryOperator('=='), 1679 result.checkSelectorHasType(new Selector.binaryOperator('=='),
1678 new TypeMask.nonNullExact(bool)); 1680 new TypeMask.nonNullExact(bool,
1681 result.compiler.world));
1679 }); 1682 });
1680 } 1683 }
1681 1684
1682 testMixins() { 1685 testMixins() {
1683 final String source = r""" 1686 final String source = r"""
1684 class A { 1687 class A {
1685 foo() => "abc"; 1688 foo() => "abc";
1686 get x => 42; 1689 get x => 42;
1687 } 1690 }
1688 class B extends Object with A { 1691 class B extends Object with A {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 testClosures10, 2134 testClosures10,
2132 testClosures11, 2135 testClosures11,
2133 testClosures12, 2136 testClosures12,
2134 testRefinement, 2137 testRefinement,
2135 testDefaultArguments, 2138 testDefaultArguments,
2136 testSuperConstructorCall, 2139 testSuperConstructorCall,
2137 testSuperConstructorCall2, 2140 testSuperConstructorCall2,
2138 testSuperConstructorCall3, 2141 testSuperConstructorCall3,
2139 ], (f) => f())); 2142 ], (f) => f()));
2140 } 2143 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/simple_inferrer_closure_test.dart » ('j') | tests/compiler/dart2js/union_type_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698