| 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.generated.non_error_resolver_test; | 5 library analyzer.test.generated.non_error_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 void test_exportOfNonLibrary_libraryNotDeclared() { | 1645 void test_exportOfNonLibrary_libraryNotDeclared() { |
| 1646 Source source = addSource(r''' | 1646 Source source = addSource(r''' |
| 1647 library L; | 1647 library L; |
| 1648 export 'lib1.dart';'''); | 1648 export 'lib1.dart';'''); |
| 1649 addNamedSource("/lib1.dart", ""); | 1649 addNamedSource("/lib1.dart", ""); |
| 1650 computeLibrarySourceErrors(source); | 1650 computeLibrarySourceErrors(source); |
| 1651 assertNoErrors(source); | 1651 assertNoErrors(source); |
| 1652 verify([source]); | 1652 verify([source]); |
| 1653 } | 1653 } |
| 1654 | 1654 |
| 1655 void test_extraPositionalArguments_Function() { | |
| 1656 Source source = addSource(r''' | |
| 1657 f(Function a) { | |
| 1658 a(1, 2); | |
| 1659 }'''); | |
| 1660 computeLibrarySourceErrors(source); | |
| 1661 assertNoErrors(source); | |
| 1662 verify([source]); | |
| 1663 } | |
| 1664 | |
| 1665 void test_extraPositionalArguments_function() { | 1655 void test_extraPositionalArguments_function() { |
| 1666 Source source = addSource(r''' | 1656 Source source = addSource(r''' |
| 1667 f(p1, p2) {} | 1657 f(p1, p2) {} |
| 1668 main() { | 1658 main() { |
| 1669 f(1, 2); | 1659 f(1, 2); |
| 1670 }'''); | 1660 }'''); |
| 1671 computeLibrarySourceErrors(source); | 1661 computeLibrarySourceErrors(source); |
| 1672 assertNoErrors(source); | 1662 assertNoErrors(source); |
| 1663 verify([source]); |
| 1664 } |
| 1665 |
| 1666 void test_extraPositionalArguments_Function() { |
| 1667 Source source = addSource(r''' |
| 1668 f(Function a) { |
| 1669 a(1, 2); |
| 1670 }'''); |
| 1671 computeLibrarySourceErrors(source); |
| 1672 assertNoErrors(source); |
| 1673 verify([source]); | 1673 verify([source]); |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 void test_extraPositionalArguments_implicitConstructor() { | 1676 void test_extraPositionalArguments_implicitConstructor() { |
| 1677 Source source = addSource(r''' | 1677 Source source = addSource(r''' |
| 1678 class A<E extends num> { | 1678 class A<E extends num> { |
| 1679 A(E x, E y); | 1679 A(E x, E y); |
| 1680 } | 1680 } |
| 1681 class M {} | 1681 class M {} |
| 1682 class B<E extends num> = A<E> with M; | 1682 class B<E extends num> = A<E> with M; |
| (...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3970 const A({this.a}); | 3970 const A({this.a}); |
| 3971 } | 3971 } |
| 3972 class B extends A { | 3972 class B extends A { |
| 3973 const B({b}) : super(a: b); | 3973 const B({b}) : super(a: b); |
| 3974 }'''); | 3974 }'''); |
| 3975 computeLibrarySourceErrors(source); | 3975 computeLibrarySourceErrors(source); |
| 3976 assertNoErrors(source); | 3976 assertNoErrors(source); |
| 3977 verify([source]); | 3977 verify([source]); |
| 3978 } | 3978 } |
| 3979 | 3979 |
| 3980 void test_nonConstCaseExpression() { | 3980 void test_nonConstCaseExpression_constField() { |
| 3981 Source source = addSource(r''' |
| 3982 f(double p) { |
| 3983 switch (p) { |
| 3984 case double.INFINITY: |
| 3985 return true; |
| 3986 default: |
| 3987 return false; |
| 3988 } |
| 3989 }'''); |
| 3990 computeLibrarySourceErrors(source); |
| 3991 assertErrors( |
| 3992 source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); |
| 3993 verify([source]); |
| 3994 } |
| 3995 |
| 3996 void test_nonConstCaseExpression_typeLiteral() { |
| 3981 Source source = addSource(r''' | 3997 Source source = addSource(r''' |
| 3982 f(Type t) { | 3998 f(Type t) { |
| 3983 switch (t) { | 3999 switch (t) { |
| 3984 case bool: | 4000 case bool: |
| 3985 case int: | 4001 case int: |
| 3986 return true; | 4002 return true; |
| 3987 default: | 4003 default: |
| 3988 return false; | 4004 return false; |
| 3989 } | 4005 } |
| 3990 }'''); | 4006 }'''); |
| 3991 computeLibrarySourceErrors(source); | 4007 computeLibrarySourceErrors(source); |
| 3992 assertNoErrors(source); | 4008 assertNoErrors(source); |
| 3993 verify([source]); | 4009 verify([source]); |
| 3994 } | 4010 } |
| 3995 | 4011 |
| 4012 void test_nonConstListElement_constField() { |
| 4013 Source source = addSource(r''' |
| 4014 main() { |
| 4015 const [double.INFINITY]; |
| 4016 }'''); |
| 4017 computeLibrarySourceErrors(source); |
| 4018 assertNoErrors(source); |
| 4019 verify([source]); |
| 4020 } |
| 4021 |
| 3996 void test_nonConstMapAsExpressionStatement_const() { | 4022 void test_nonConstMapAsExpressionStatement_const() { |
| 3997 Source source = addSource(r''' | 4023 Source source = addSource(r''' |
| 3998 f() { | 4024 f() { |
| 3999 const {'a' : 0, 'b' : 1}; | 4025 const {'a' : 0, 'b' : 1}; |
| 4000 }'''); | 4026 }'''); |
| 4001 computeLibrarySourceErrors(source); | 4027 computeLibrarySourceErrors(source); |
| 4002 assertNoErrors(source); | 4028 assertNoErrors(source); |
| 4003 verify([source]); | 4029 verify([source]); |
| 4004 } | 4030 } |
| 4005 | 4031 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4016 void test_nonConstMapAsExpressionStatement_typeArguments() { | 4042 void test_nonConstMapAsExpressionStatement_typeArguments() { |
| 4017 Source source = addSource(r''' | 4043 Source source = addSource(r''' |
| 4018 f() { | 4044 f() { |
| 4019 <String, int> {'a' : 0, 'b' : 1}; | 4045 <String, int> {'a' : 0, 'b' : 1}; |
| 4020 }'''); | 4046 }'''); |
| 4021 computeLibrarySourceErrors(source); | 4047 computeLibrarySourceErrors(source); |
| 4022 assertNoErrors(source); | 4048 assertNoErrors(source); |
| 4023 verify([source]); | 4049 verify([source]); |
| 4024 } | 4050 } |
| 4025 | 4051 |
| 4052 void test_nonConstMapKey_constField() { |
| 4053 Source source = addSource(r''' |
| 4054 main() { |
| 4055 const {double.INFINITY: 0}; |
| 4056 }'''); |
| 4057 computeLibrarySourceErrors(source); |
| 4058 assertErrors(source, |
| 4059 [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); |
| 4060 verify([source]); |
| 4061 } |
| 4062 |
| 4063 void test_nonConstMapValue_constField() { |
| 4064 Source source = addSource(r''' |
| 4065 main() { |
| 4066 const {0: double.INFINITY}; |
| 4067 }'''); |
| 4068 computeLibrarySourceErrors(source); |
| 4069 assertNoErrors(source); |
| 4070 verify([source]); |
| 4071 } |
| 4072 |
| 4026 void test_nonConstValueInInitializer_binary_bool() { | 4073 void test_nonConstValueInInitializer_binary_bool() { |
| 4027 Source source = addSource(r''' | 4074 Source source = addSource(r''' |
| 4028 class A { | 4075 class A { |
| 4029 final v; | 4076 final v; |
| 4030 const A.a1(bool p) : v = p && true; | 4077 const A.a1(bool p) : v = p && true; |
| 4031 const A.a2(bool p) : v = true && p; | 4078 const A.a2(bool p) : v = true && p; |
| 4032 const A.b1(bool p) : v = p || true; | 4079 const A.b1(bool p) : v = p || true; |
| 4033 const A.b2(bool p) : v = true || p; | 4080 const A.b2(bool p) : v = true || p; |
| 4034 }'''); | 4081 }'''); |
| 4035 computeLibrarySourceErrors(source); | 4082 computeLibrarySourceErrors(source); |
| (...skipping 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5982 reset(); | 6029 reset(); |
| 5983 } | 6030 } |
| 5984 | 6031 |
| 5985 void _check_wrongNumberOfParametersForOperator1(String name) { | 6032 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 5986 _check_wrongNumberOfParametersForOperator(name, "a"); | 6033 _check_wrongNumberOfParametersForOperator(name, "a"); |
| 5987 } | 6034 } |
| 5988 | 6035 |
| 5989 CompilationUnit _getResolvedLibraryUnit(Source source) => | 6036 CompilationUnit _getResolvedLibraryUnit(Source source) => |
| 5990 analysisContext.getResolvedCompilationUnit2(source, source); | 6037 analysisContext.getResolvedCompilationUnit2(source, source); |
| 5991 } | 6038 } |
| OLD | NEW |