OLD | NEW |
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 library analyzer.test.src.dart.element.element_test; | 5 library analyzer.test.src.dart.element.element_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/constant/value.dart'; | 8 import 'package:analyzer/dart/constant/value.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 expect(VoidTypeImpl.instance == s.returnType, isTrue); | 1813 expect(VoidTypeImpl.instance == s.returnType, isTrue); |
1814 expect(t.isSubtypeOf(s), isTrue); | 1814 expect(t.isSubtypeOf(s), isTrue); |
1815 } | 1815 } |
1816 | 1816 |
1817 void test_isSubtypeOf_returnType_tAssignableToS() { | 1817 void test_isSubtypeOf_returnType_tAssignableToS() { |
1818 // B extends A | 1818 // B extends A |
1819 // () -> A <: () -> B | 1819 // () -> A <: () -> B |
1820 // () -> B <: () -> A | 1820 // () -> B <: () -> A |
1821 ClassElement a = ElementFactory.classElement2("A"); | 1821 ClassElement a = ElementFactory.classElement2("A"); |
1822 ClassElement b = ElementFactory.classElement("B", a.type); | 1822 ClassElement b = ElementFactory.classElement("B", a.type); |
1823 FunctionType t = ElementFactory.functionElement2("t", a).type; | 1823 FunctionType t = ElementFactory.functionElement2("t", a.type).type; |
1824 FunctionType s = ElementFactory.functionElement2("s", b).type; | 1824 FunctionType s = ElementFactory.functionElement2("s", b.type).type; |
1825 expect(t.isSubtypeOf(s), isTrue); | 1825 expect(t.isSubtypeOf(s), isTrue); |
1826 expect(s.isSubtypeOf(t), isTrue); | 1826 expect(s.isSubtypeOf(t), isTrue); |
1827 } | 1827 } |
1828 | 1828 |
1829 void test_isSubtypeOf_returnType_tNotAssignableToS() { | 1829 void test_isSubtypeOf_returnType_tNotAssignableToS() { |
1830 // ! () -> A <: () -> B | 1830 // ! () -> A <: () -> B |
1831 FunctionType t = ElementFactory | 1831 FunctionType t = ElementFactory |
1832 .functionElement2("t", ElementFactory.classElement2("A")) | 1832 .functionElement2("t", ElementFactory.classElement2("A").type) |
1833 .type; | 1833 .type; |
1834 FunctionType s = ElementFactory | 1834 FunctionType s = ElementFactory |
1835 .functionElement2("s", ElementFactory.classElement2("B")) | 1835 .functionElement2("s", ElementFactory.classElement2("B").type) |
1836 .type; | 1836 .type; |
1837 expect(t.isSubtypeOf(s), isFalse); | 1837 expect(t.isSubtypeOf(s), isFalse); |
1838 } | 1838 } |
1839 | 1839 |
1840 void test_isSubtypeOf_typeParameters_matchesBounds() { | 1840 void test_isSubtypeOf_typeParameters_matchesBounds() { |
1841 TestTypeProvider provider = new TestTypeProvider(); | 1841 TestTypeProvider provider = new TestTypeProvider(); |
1842 InterfaceType boolType = provider.boolType; | 1842 InterfaceType boolType = provider.boolType; |
1843 InterfaceType stringType = provider.stringType; | 1843 InterfaceType stringType = provider.stringType; |
1844 TypeParameterElementImpl parameterB = | 1844 TypeParameterElementImpl parameterB = |
1845 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("B")); | 1845 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("B")); |
(...skipping 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4488 } | 4488 } |
4489 | 4489 |
4490 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4490 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
4491 extends InterfaceTypeImpl { | 4491 extends InterfaceTypeImpl { |
4492 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4492 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
4493 : super(arg0); | 4493 : super(arg0); |
4494 | 4494 |
4495 @override | 4495 @override |
4496 bool get isDartCoreFunction => true; | 4496 bool get isDartCoreFunction => true; |
4497 } | 4497 } |
OLD | NEW |