| 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 engine.non_error_resolver_test; | 5 library engine.non_error_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/source_io.dart'; | 7 import 'package:analyzer/src/generated/source_io.dart'; |
| 8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 r''' | 732 r''' |
| 733 library lib1; | 733 library lib1; |
| 734 class A { | 734 class A { |
| 735 const A.b(); | 735 const A.b(); |
| 736 }''', | 736 }''', |
| 737 r''' | 737 r''' |
| 738 library root; | 738 library root; |
| 739 import 'lib1.dart' deferred as a; | 739 import 'lib1.dart' deferred as a; |
| 740 main() { | 740 main() { |
| 741 new a.A.b(); | 741 new a.A.b(); |
| 742 }'''], <ErrorCode> [ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED], <ErrorCode>
[]); | 742 }'''], <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED], <ErrorCode>[
]); |
| 743 } | 743 } |
| 744 | 744 |
| 745 void test_constEval_functionTypeLiteral() { | 745 void test_constEval_functionTypeLiteral() { |
| 746 Source source = addSource(r''' | 746 Source source = addSource(r''' |
| 747 typedef F(); | 747 typedef F(); |
| 748 const C = F;'''); | 748 const C = F;'''); |
| 749 resolve(source); | 749 resolve(source); |
| 750 assertNoErrors(source); | 750 assertNoErrors(source); |
| 751 verify([source]); | 751 verify([source]); |
| 752 } | 752 } |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 import 'lib.dart'; | 1791 import 'lib.dart'; |
| 1792 class B extends A { | 1792 class B extends A { |
| 1793 _m() {} | 1793 _m() {} |
| 1794 }'''); | 1794 }'''); |
| 1795 addNamedSource("/lib.dart", r''' | 1795 addNamedSource("/lib.dart", r''' |
| 1796 library L; | 1796 library L; |
| 1797 class A { | 1797 class A { |
| 1798 static _m() {} | 1798 static _m() {} |
| 1799 }'''); | 1799 }'''); |
| 1800 resolve(source); | 1800 resolve(source); |
| 1801 assertErrors(source, []); | 1801 assertNoErrors(source); |
| 1802 verify([source]); | 1802 verify([source]); |
| 1803 } | 1803 } |
| 1804 | 1804 |
| 1805 void test_invalidAnnotation_constantVariable_field() { | 1805 void test_invalidAnnotation_constantVariable_field() { |
| 1806 Source source = addSource(r''' | 1806 Source source = addSource(r''' |
| 1807 @A.C | 1807 @A.C |
| 1808 class A { | 1808 class A { |
| 1809 static const C = 0; | 1809 static const C = 0; |
| 1810 }'''); | 1810 }'''); |
| 1811 resolve(source); | 1811 resolve(source); |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2421 class Functor implements Function { | 2421 class Functor implements Function { |
| 2422 noSuchMethod(inv) { | 2422 noSuchMethod(inv) { |
| 2423 return 42; | 2423 return 42; |
| 2424 } | 2424 } |
| 2425 } | 2425 } |
| 2426 main() { | 2426 main() { |
| 2427 Functor f = new Functor(); | 2427 Functor f = new Functor(); |
| 2428 f(); | 2428 f(); |
| 2429 }'''); | 2429 }'''); |
| 2430 resolve(source); | 2430 resolve(source); |
| 2431 assertErrors(source, []); | 2431 assertNoErrors(source); |
| 2432 verify([source]); | 2432 verify([source]); |
| 2433 } | 2433 } |
| 2434 | 2434 |
| 2435 void test_listElementTypeNotAssignable() { | 2435 void test_listElementTypeNotAssignable() { |
| 2436 Source source = addSource(r''' | 2436 Source source = addSource(r''' |
| 2437 var v1 = <int> [42]; | 2437 var v1 = <int> [42]; |
| 2438 var v2 = const <int> [42];'''); | 2438 var v2 = const <int> [42];'''); |
| 2439 resolve(source); | 2439 resolve(source); |
| 2440 assertNoErrors(source); | 2440 assertNoErrors(source); |
| 2441 verify([source]); | 2441 verify([source]); |
| 2442 } | 2442 } |
| 2443 | 2443 |
| 2444 void test_loadLibraryDefined() { | 2444 void test_loadLibraryDefined() { |
| 2445 resolveWithAndWithoutExperimental(<String> [ | 2445 resolveWithAndWithoutExperimental(<String> [ |
| 2446 r''' | 2446 r''' |
| 2447 library lib1; | 2447 library lib1; |
| 2448 foo() => 22;''', | 2448 foo() => 22;''', |
| 2449 r''' | 2449 r''' |
| 2450 import 'lib1.dart' deferred as other; | 2450 import 'lib1.dart' deferred as other; |
| 2451 main() { | 2451 main() { |
| 2452 other.loadLibrary().then((_) => other.foo()); | 2452 other.loadLibrary().then((_) => other.foo()); |
| 2453 }'''], <ErrorCode> [ | 2453 }'''], <ErrorCode>[ |
| 2454 ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED, | 2454 ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED, |
| 2455 StaticTypeWarningCode.UNDEFINED_FUNCTION], <ErrorCode> []); | 2455 StaticTypeWarningCode.UNDEFINED_FUNCTION], <ErrorCode>[]); |
| 2456 } | 2456 } |
| 2457 | 2457 |
| 2458 void test_mapKeyTypeNotAssignable() { | 2458 void test_mapKeyTypeNotAssignable() { |
| 2459 Source source = addSource("var v = <String, int > {'a' : 1};"); | 2459 Source source = addSource("var v = <String, int > {'a' : 1};"); |
| 2460 resolve(source); | 2460 resolve(source); |
| 2461 assertNoErrors(source); | 2461 assertNoErrors(source); |
| 2462 verify([source]); | 2462 verify([source]); |
| 2463 } | 2463 } |
| 2464 | 2464 |
| 2465 void test_memberWithClassName_setter() { | 2465 void test_memberWithClassName_setter() { |
| (...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3848 // core, this particular test case comes from issue 18468. | 3848 // core, this particular test case comes from issue 18468. |
| 3849 // | 3849 // |
| 3850 // A test cannot be added to TypeParameterTypeImplTest since the types retur
ned out of the | 3850 // A test cannot be added to TypeParameterTypeImplTest since the types retur
ned out of the |
| 3851 // TestTypeProvider don't have a mock 'dart.core' enclosing library element. | 3851 // TestTypeProvider don't have a mock 'dart.core' enclosing library element. |
| 3852 // See TypeParameterTypeImpl.isMoreSpecificThan(). | 3852 // See TypeParameterTypeImpl.isMoreSpecificThan(). |
| 3853 Source source = addSource(r''' | 3853 Source source = addSource(r''' |
| 3854 class Foo<T> { | 3854 class Foo<T> { |
| 3855 Type get t => T; | 3855 Type get t => T; |
| 3856 }'''); | 3856 }'''); |
| 3857 resolve(source); | 3857 resolve(source); |
| 3858 assertErrors(source, []); | 3858 assertErrors(source); |
| 3859 verify([source]); | 3859 verify([source]); |
| 3860 } | 3860 } |
| 3861 | 3861 |
| 3862 void test_returnOfInvalidType_void() { | 3862 void test_returnOfInvalidType_void() { |
| 3863 Source source = addSource(r''' | 3863 Source source = addSource(r''' |
| 3864 void f1() {} | 3864 void f1() {} |
| 3865 void f2() { return; } | 3865 void f2() { return; } |
| 3866 void f3() { return null; } | 3866 void f3() { return null; } |
| 3867 void f4() { return g1(); } | 3867 void f4() { return g1(); } |
| 3868 void f5() { return g2(); } | 3868 void f5() { return g2(); } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3910 library lib2; | 3910 library lib2; |
| 3911 f2() {}''', | 3911 f2() {}''', |
| 3912 r''' | 3912 r''' |
| 3913 library lib3; | 3913 library lib3; |
| 3914 f3() {}''', | 3914 f3() {}''', |
| 3915 r''' | 3915 r''' |
| 3916 library root; | 3916 library root; |
| 3917 import 'lib1.dart' deferred as lib1; | 3917 import 'lib1.dart' deferred as lib1; |
| 3918 import 'lib2.dart' as lib; | 3918 import 'lib2.dart' as lib; |
| 3919 import 'lib3.dart' as lib; | 3919 import 'lib3.dart' as lib; |
| 3920 main() { lib1.f1(); lib.f2(); lib.f3(); }'''], <ErrorCode> [ParserErrorCode.DEFE
RRED_IMPORTS_NOT_SUPPORTED], <ErrorCode> []); | 3920 main() { lib1.f1(); lib.f2(); lib.f3(); }'''], <ErrorCode>[ParserErrorCode.DEFER
RED_IMPORTS_NOT_SUPPORTED], <ErrorCode>[]); |
| 3921 } | 3921 } |
| 3922 | 3922 |
| 3923 void test_staticAccessToInstanceMember_annotation() { | 3923 void test_staticAccessToInstanceMember_annotation() { |
| 3924 Source source = addSource(r''' | 3924 Source source = addSource(r''' |
| 3925 class A { | 3925 class A { |
| 3926 const A.name(); | 3926 const A.name(); |
| 3927 } | 3927 } |
| 3928 @A.name() | 3928 @A.name() |
| 3929 main() { | 3929 main() { |
| 3930 }'''); | 3930 }'''); |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4740 | 4740 |
| 4741 void _check_wrongNumberOfParametersForOperator1(String name) { | 4741 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 4742 _check_wrongNumberOfParametersForOperator(name, "a"); | 4742 _check_wrongNumberOfParametersForOperator(name, "a"); |
| 4743 } | 4743 } |
| 4744 } | 4744 } |
| 4745 | 4745 |
| 4746 main() { | 4746 main() { |
| 4747 _ut.groupSep = ' | '; | 4747 _ut.groupSep = ' | '; |
| 4748 runReflectiveTests(NonErrorResolverTest); | 4748 runReflectiveTests(NonErrorResolverTest); |
| 4749 } | 4749 } |
| OLD | NEW |