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

Side by Side Diff: pkg/analyzer/test/src/dart/element/element_test.dart

Issue 2647833002: fix #28008, fix #28009 implement FutureOr<T> (Closed)
Patch Set: add test Created 3 years, 10 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) 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 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 expect(VoidTypeImpl.instance == s.returnType, isTrue); 1812 expect(VoidTypeImpl.instance == s.returnType, isTrue);
1813 expect(t.isSubtypeOf(s), isTrue); 1813 expect(t.isSubtypeOf(s), isTrue);
1814 } 1814 }
1815 1815
1816 void test_isSubtypeOf_returnType_tAssignableToS() { 1816 void test_isSubtypeOf_returnType_tAssignableToS() {
1817 // B extends A 1817 // B extends A
1818 // () -> A <: () -> B 1818 // () -> A <: () -> B
1819 // () -> B <: () -> A 1819 // () -> B <: () -> A
1820 ClassElement a = ElementFactory.classElement2("A"); 1820 ClassElement a = ElementFactory.classElement2("A");
1821 ClassElement b = ElementFactory.classElement("B", a.type); 1821 ClassElement b = ElementFactory.classElement("B", a.type);
1822 FunctionType t = ElementFactory.functionElement2("t", a).type; 1822 FunctionType t = ElementFactory.functionElement2("t", a.type).type;
1823 FunctionType s = ElementFactory.functionElement2("s", b).type; 1823 FunctionType s = ElementFactory.functionElement2("s", b.type).type;
1824 expect(t.isSubtypeOf(s), isTrue); 1824 expect(t.isSubtypeOf(s), isTrue);
1825 expect(s.isSubtypeOf(t), isTrue); 1825 expect(s.isSubtypeOf(t), isTrue);
1826 } 1826 }
1827 1827
1828 void test_isSubtypeOf_returnType_tNotAssignableToS() { 1828 void test_isSubtypeOf_returnType_tNotAssignableToS() {
1829 // ! () -> A <: () -> B 1829 // ! () -> A <: () -> B
1830 FunctionType t = ElementFactory 1830 FunctionType t = ElementFactory
1831 .functionElement2("t", ElementFactory.classElement2("A")) 1831 .functionElement2("t", ElementFactory.classElement2("A").type)
1832 .type; 1832 .type;
1833 FunctionType s = ElementFactory 1833 FunctionType s = ElementFactory
1834 .functionElement2("s", ElementFactory.classElement2("B")) 1834 .functionElement2("s", ElementFactory.classElement2("B").type)
1835 .type; 1835 .type;
1836 expect(t.isSubtypeOf(s), isFalse); 1836 expect(t.isSubtypeOf(s), isFalse);
1837 } 1837 }
1838 1838
1839 void test_isSubtypeOf_typeParameters_matchesBounds() { 1839 void test_isSubtypeOf_typeParameters_matchesBounds() {
1840 TestTypeProvider provider = new TestTypeProvider(); 1840 TestTypeProvider provider = new TestTypeProvider();
1841 InterfaceType boolType = provider.boolType; 1841 InterfaceType boolType = provider.boolType;
1842 InterfaceType stringType = provider.stringType; 1842 InterfaceType stringType = provider.stringType;
1843 TypeParameterElementImpl parameterB = 1843 TypeParameterElementImpl parameterB =
1844 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("B")); 1844 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("B"));
(...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after
4444 } 4444 }
4445 4445
4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction 4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction
4447 extends InterfaceTypeImpl { 4447 extends InterfaceTypeImpl {
4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) 4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0)
4449 : super(arg0); 4449 : super(arg0);
4450 4450
4451 @override 4451 @override
4452 bool get isDartCoreFunction => true; 4452 bool get isDartCoreFunction => true;
4453 } 4453 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698