| Index: pkg/analyzer/test/generated/all_the_rest_test.dart
|
| diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| index f8ca1dc42782e9ee4fd2aec7bb6ced010718bd08..342682dffa6f99c5c3576f9d09294458d1877d8b 100644
|
| --- a/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| +++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| @@ -575,19 +575,22 @@ class ConstantFinderTest {
|
| expect(_findConstants(), contains(field.element));
|
| }
|
|
|
| - void test_visitVariableDeclaration_static_const_inClassWithConstConstructor() {
|
| + void
|
| + test_visitVariableDeclaration_static_const_inClassWithConstConstructor() {
|
| VariableDeclaration field = _setupFieldDeclaration('C', 'f', Keyword.CONST,
|
| isStatic: true, hasConstConstructor: true);
|
| expect(_findConstants(), contains(field.element));
|
| }
|
|
|
| - void test_visitVariableDeclaration_static_final_inClassWithConstConstructor() {
|
| + void
|
| + test_visitVariableDeclaration_static_final_inClassWithConstConstructor() {
|
| VariableDeclaration field = _setupFieldDeclaration('C', 'f', Keyword.FINAL,
|
| isStatic: true, hasConstConstructor: true);
|
| expect(_findConstants(), isNot(contains(field.element)));
|
| }
|
|
|
| - void test_visitVariableDeclaration_uninitialized_final_inClassWithConstConstructor() {
|
| + void
|
| + test_visitVariableDeclaration_uninitialized_final_inClassWithConstConstructor() {
|
| VariableDeclaration field = _setupFieldDeclaration('C', 'f', Keyword.FINAL,
|
| isInitialized: false, hasConstConstructor: true);
|
| expect(_findConstants(), isNot(contains(field.element)));
|
| @@ -621,8 +624,8 @@ class ConstantFinderTest {
|
|
|
| ConstructorElement _setupConstructorDeclaration(String name, bool isConst) {
|
| Keyword constKeyword = isConst ? Keyword.CONST : null;
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration2(
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration2(
|
| constKeyword,
|
| null,
|
| null,
|
| @@ -663,8 +666,8 @@ class ConstantFinderTest {
|
| classElement.fields = <FieldElement>[fieldElement];
|
| classDeclaration.name.staticElement = classElement;
|
| if (hasConstConstructor) {
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration2(
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration2(
|
| Keyword.CONST,
|
| null,
|
| AstFactory.identifier3(className),
|
| @@ -1333,19 +1336,23 @@ class A {
|
| _assertIntField(fields, "k", 13);
|
| }
|
|
|
| - void test_instanceCreationExpression_computedField_namedOptionalWithDefault() {
|
| + void
|
| + test_instanceCreationExpression_computedField_namedOptionalWithDefault() {
|
| _checkInstanceCreationOptionalParams(false, true, true);
|
| }
|
|
|
| - void test_instanceCreationExpression_computedField_namedOptionalWithoutDefault() {
|
| + void
|
| + test_instanceCreationExpression_computedField_namedOptionalWithoutDefault() {
|
| _checkInstanceCreationOptionalParams(false, true, false);
|
| }
|
|
|
| - void test_instanceCreationExpression_computedField_unnamedOptionalWithDefault() {
|
| + void
|
| + test_instanceCreationExpression_computedField_unnamedOptionalWithDefault() {
|
| _checkInstanceCreationOptionalParams(false, false, true);
|
| }
|
|
|
| - void test_instanceCreationExpression_computedField_unnamedOptionalWithoutDefault() {
|
| + void
|
| + test_instanceCreationExpression_computedField_unnamedOptionalWithoutDefault() {
|
| _checkInstanceCreationOptionalParams(false, false, false);
|
| }
|
|
|
| @@ -1438,19 +1445,23 @@ class A {
|
| _assertIntField(fields, "x", 42);
|
| }
|
|
|
| - void test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithDefault() {
|
| + void
|
| + test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithDefault() {
|
| _checkInstanceCreationOptionalParams(true, true, true);
|
| }
|
|
|
| - void test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithoutDefault() {
|
| + void
|
| + test_instanceCreationExpression_fieldFormalParameter_namedOptionalWithoutDefault() {
|
| _checkInstanceCreationOptionalParams(true, true, false);
|
| }
|
|
|
| - void test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithDefault() {
|
| + void
|
| + test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithDefault() {
|
| _checkInstanceCreationOptionalParams(true, false, true);
|
| }
|
|
|
| - void test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithoutDefault() {
|
| + void
|
| + test_instanceCreationExpression_fieldFormalParameter_unnamedOptionalWithoutDefault() {
|
| _checkInstanceCreationOptionalParams(true, false, false);
|
| }
|
|
|
| @@ -2008,6 +2019,53 @@ class A {
|
|
|
| @reflectiveTest
|
| class ConstantVisitorTest extends ResolverTestCase {
|
| + void test_visitBinaryExpression_questionQuestion_notNull_notNull() {
|
| + Expression left = AstFactory.string2('a');
|
| + Expression right = AstFactory.string2('b');
|
| + Expression expression =
|
| + AstFactory.binaryExpression(left, TokenType.QUESTION_QUESTION, right);
|
| +
|
| + GatheringErrorListener errorListener = new GatheringErrorListener();
|
| + ErrorReporter errorReporter =
|
| + new ErrorReporter(errorListener, _dummySource());
|
| + DartObjectImpl result = _evaluate(expression, errorReporter);
|
| + expect(result, isNotNull);
|
| + expect(result.isNull, isFalse);
|
| + expect(result.toStringValue(), 'a');
|
| + errorListener.assertNoErrors();
|
| + }
|
| +
|
| + void test_visitBinaryExpression_questionQuestion_null_notNull() {
|
| + Expression left = AstFactory.nullLiteral();
|
| + Expression right = AstFactory.string2('b');
|
| + Expression expression =
|
| + AstFactory.binaryExpression(left, TokenType.QUESTION_QUESTION, right);
|
| +
|
| + GatheringErrorListener errorListener = new GatheringErrorListener();
|
| + ErrorReporter errorReporter =
|
| + new ErrorReporter(errorListener, _dummySource());
|
| + DartObjectImpl result = _evaluate(expression, errorReporter);
|
| + expect(result, isNotNull);
|
| + expect(result.isNull, isFalse);
|
| + expect(result.toStringValue(), 'b');
|
| + errorListener.assertNoErrors();
|
| + }
|
| +
|
| + void test_visitBinaryExpression_questionQuestion_null_null() {
|
| + Expression left = AstFactory.nullLiteral();
|
| + Expression right = AstFactory.nullLiteral();
|
| + Expression expression =
|
| + AstFactory.binaryExpression(left, TokenType.QUESTION_QUESTION, right);
|
| +
|
| + GatheringErrorListener errorListener = new GatheringErrorListener();
|
| + ErrorReporter errorReporter =
|
| + new ErrorReporter(errorListener, _dummySource());
|
| + DartObjectImpl result = _evaluate(expression, errorReporter);
|
| + expect(result, isNotNull);
|
| + expect(result.isNull, isTrue);
|
| + errorListener.assertNoErrors();
|
| + }
|
| +
|
| void test_visitConditionalExpression_false() {
|
| Expression thenExpression = AstFactory.integer(1);
|
| Expression elseExpression = AstFactory.integer(0);
|
| @@ -2016,13 +2074,7 @@ class ConstantVisitorTest extends ResolverTestCase {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(errorListener, _dummySource());
|
| - _assertValue(
|
| - 0,
|
| - expression.accept(new ConstantVisitor(
|
| - new ConstantEvaluationEngine(
|
| - new TestTypeProvider(), new DeclaredVariables(),
|
| - typeSystem: new TypeSystemImpl()),
|
| - errorReporter)));
|
| + _assertValue(0, _evaluate(expression, errorReporter));
|
| errorListener.assertNoErrors();
|
| }
|
|
|
| @@ -2035,11 +2087,7 @@ class ConstantVisitorTest extends ResolverTestCase {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(errorListener, _dummySource());
|
| - DartObjectImpl result = expression.accept(new ConstantVisitor(
|
| - new ConstantEvaluationEngine(
|
| - new TestTypeProvider(), new DeclaredVariables(),
|
| - typeSystem: new TypeSystemImpl()),
|
| - errorReporter));
|
| + DartObjectImpl result = _evaluate(expression, errorReporter);
|
| expect(result, isNull);
|
| errorListener
|
| .assertErrorsWithCodes([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
|
| @@ -2053,11 +2101,7 @@ class ConstantVisitorTest extends ResolverTestCase {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(errorListener, _dummySource());
|
| - DartObjectImpl result = expression.accept(new ConstantVisitor(
|
| - new ConstantEvaluationEngine(
|
| - new TestTypeProvider(), new DeclaredVariables(),
|
| - typeSystem: new TypeSystemImpl()),
|
| - errorReporter));
|
| + DartObjectImpl result = _evaluate(expression, errorReporter);
|
| expect(result, isNull);
|
| errorListener
|
| .assertErrorsWithCodes([CompileTimeErrorCode.INVALID_CONSTANT]);
|
| @@ -2071,11 +2115,7 @@ class ConstantVisitorTest extends ResolverTestCase {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(errorListener, _dummySource());
|
| - DartObjectImpl result = expression.accept(new ConstantVisitor(
|
| - new ConstantEvaluationEngine(
|
| - new TestTypeProvider(), new DeclaredVariables(),
|
| - typeSystem: new TypeSystemImpl()),
|
| - errorReporter));
|
| + DartObjectImpl result = _evaluate(expression, errorReporter);
|
| expect(result, isNull);
|
| errorListener
|
| .assertErrorsWithCodes([CompileTimeErrorCode.INVALID_CONSTANT]);
|
| @@ -2089,13 +2129,7 @@ class ConstantVisitorTest extends ResolverTestCase {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(errorListener, _dummySource());
|
| - _assertValue(
|
| - 1,
|
| - expression.accept(new ConstantVisitor(
|
| - new ConstantEvaluationEngine(
|
| - new TestTypeProvider(), new DeclaredVariables(),
|
| - typeSystem: new TypeSystemImpl()),
|
| - errorReporter)));
|
| + _assertValue(1, _evaluate(expression, errorReporter));
|
| errorListener.assertNoErrors();
|
| }
|
|
|
| @@ -2158,6 +2192,14 @@ const b = 3;''');
|
| return new NonExistingSource(path, toUri(path), UriKind.FILE_URI);
|
| }
|
|
|
| + DartObjectImpl _evaluate(Expression expression, ErrorReporter errorReporter) {
|
| + return expression.accept(new ConstantVisitor(
|
| + new ConstantEvaluationEngine(
|
| + new TestTypeProvider(), new DeclaredVariables(),
|
| + typeSystem: new TypeSystemImpl()),
|
| + errorReporter));
|
| + }
|
| +
|
| DartObjectImpl _evaluateConstant(CompilationUnit compilationUnit, String name,
|
| Map<String, DartObjectImpl> lexicalEnvironment) {
|
| Source source = compilationUnit.element.source;
|
| @@ -4857,8 +4899,8 @@ class ElementBuilderTest extends EngineTestCase {
|
| ElementHolder holder = new ElementHolder();
|
| ElementBuilder builder = new ElementBuilder(holder);
|
| String className = "A";
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration2(
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration2(
|
| null,
|
| null,
|
| AstFactory.identifier3(className),
|
| @@ -4886,8 +4928,8 @@ class ElementBuilderTest extends EngineTestCase {
|
| ElementHolder holder = new ElementHolder();
|
| ElementBuilder builder = new ElementBuilder(holder);
|
| String className = "A";
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration2(
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration2(
|
| null,
|
| Keyword.FACTORY,
|
| AstFactory.identifier3(className),
|
| @@ -4913,8 +4955,8 @@ class ElementBuilderTest extends EngineTestCase {
|
| ElementHolder holder = new ElementHolder();
|
| ElementBuilder builder = new ElementBuilder(holder);
|
| String className = "A";
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration2(
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration2(
|
| null,
|
| null,
|
| AstFactory.identifier3(className),
|
| @@ -4946,8 +4988,8 @@ class ElementBuilderTest extends EngineTestCase {
|
| ElementBuilder builder = new ElementBuilder(holder);
|
| String className = "A";
|
| String constructorName = "c";
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration2(
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration2(
|
| null,
|
| null,
|
| AstFactory.identifier3(className),
|
| @@ -4975,8 +5017,8 @@ class ElementBuilderTest extends EngineTestCase {
|
| ElementHolder holder = new ElementHolder();
|
| ElementBuilder builder = new ElementBuilder(holder);
|
| String className = "A";
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration2(
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration2(
|
| null,
|
| null,
|
| AstFactory.identifier3(className),
|
| @@ -5056,8 +5098,8 @@ class ElementBuilderTest extends EngineTestCase {
|
| ElementHolder holder = new ElementHolder();
|
| ElementBuilder builder = new ElementBuilder(holder);
|
| String parameterName = 'p';
|
| - DefaultFormalParameter formalParameter = AstFactory
|
| - .positionalFormalParameter(
|
| + DefaultFormalParameter formalParameter =
|
| + AstFactory.positionalFormalParameter(
|
| AstFactory.simpleFormalParameter3(parameterName),
|
| AstFactory.integer(0));
|
| formalParameter.accept(builder);
|
| @@ -6462,7 +6504,8 @@ class A {
|
| (obj) => obj is FunctionElement, FunctionElement, element);
|
| }
|
|
|
| - void test_locate_Identifier_annotationClass_namedConstructor_forSimpleFormalParameter() {
|
| + void
|
| + test_locate_Identifier_annotationClass_namedConstructor_forSimpleFormalParameter() {
|
| AstNode id = _findNodeIndexedIn(
|
| "Class",
|
| 2,
|
| @@ -6477,7 +6520,8 @@ void main(@Class.name() parameter) {
|
| (obj) => obj is ClassElement, ClassElement, element);
|
| }
|
|
|
| - void test_locate_Identifier_annotationClass_unnamedConstructor_forSimpleFormalParameter() {
|
| + void
|
| + test_locate_Identifier_annotationClass_unnamedConstructor_forSimpleFormalParameter() {
|
| AstNode id = _findNodeIndexedIn(
|
| "Class",
|
| 2,
|
| @@ -6584,8 +6628,8 @@ void main() {
|
| SimpleIdentifier identifier = AstFactory.identifier3("A");
|
| PrefixedIdentifier prefixedIdentifier =
|
| AstFactory.identifier4("pref", identifier);
|
| - InstanceCreationExpression creation = AstFactory
|
| - .instanceCreationExpression2(
|
| + InstanceCreationExpression creation =
|
| + AstFactory.instanceCreationExpression2(
|
| Keyword.NEW, AstFactory.typeName3(prefixedIdentifier));
|
| // set ClassElement
|
| ClassElement classElement = ElementFactory.classElement2("A");
|
| @@ -6602,8 +6646,8 @@ void main() {
|
| void test_locate_InstanceCreationExpression_type_simpleIdentifier() {
|
| // prepare: new A()
|
| SimpleIdentifier identifier = AstFactory.identifier3("A");
|
| - InstanceCreationExpression creation = AstFactory
|
| - .instanceCreationExpression2(
|
| + InstanceCreationExpression creation =
|
| + AstFactory.instanceCreationExpression2(
|
| Keyword.NEW, AstFactory.typeName3(identifier));
|
| // set ClassElement
|
| ClassElement classElement = ElementFactory.classElement2("A");
|
| @@ -8108,8 +8152,8 @@ class ReferenceFinderTest {
|
| String name, bool isConst) {
|
| List<ConstructorInitializer> initializers =
|
| new List<ConstructorInitializer>();
|
| - ConstructorDeclaration constructorDeclaration = AstFactory
|
| - .constructorDeclaration(AstFactory.identifier3(name), null,
|
| + ConstructorDeclaration constructorDeclaration =
|
| + AstFactory.constructorDeclaration(AstFactory.identifier3(name), null,
|
| AstFactory.formalParameterList(), initializers);
|
| if (isConst) {
|
| constructorDeclaration.constKeyword = new KeywordToken(Keyword.CONST, 0);
|
|
|