| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 3416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3427 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); | 3427 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
| 3428 expect(initializer.name, 'named'); | 3428 expect(initializer.name, 'named'); |
| 3429 expect(initializer.expression, isNull); | 3429 expect(initializer.expression, isNull); |
| 3430 expect(initializer.arguments, hasLength(2)); | 3430 expect(initializer.arguments, hasLength(2)); |
| 3431 _assertUnlinkedConst(initializer.arguments[0], | 3431 _assertUnlinkedConst(initializer.arguments[0], |
| 3432 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 3432 operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 3433 _assertUnlinkedConst(initializer.arguments[1], | 3433 _assertUnlinkedConst(initializer.arguments[1], |
| 3434 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); | 3434 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); |
| 3435 } | 3435 } |
| 3436 | 3436 |
| 3437 test_constructor_initializers_thisInvocation_nameExpression() { |
| 3438 UnlinkedExecutable executable = |
| 3439 findExecutable('', executables: serializeClassText(r''' |
| 3440 class C { |
| 3441 const C() : this.named(a: 1, b: 2); |
| 3442 const C.named({int a, int b}); |
| 3443 } |
| 3444 ''').executables); |
| 3445 expect(executable.constantInitializers, hasLength(1)); |
| 3446 UnlinkedConstructorInitializer initializer = |
| 3447 executable.constantInitializers[0]; |
| 3448 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
| 3449 expect(initializer.name, 'named'); |
| 3450 expect(initializer.expression, isNull); |
| 3451 expect(initializer.arguments, hasLength(2)); |
| 3452 _assertUnlinkedConst(initializer.arguments[0], |
| 3453 name: 'a', operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 3454 _assertUnlinkedConst(initializer.arguments[1], |
| 3455 name: 'b', operators: [UnlinkedConstOperation.pushInt], ints: [2]); |
| 3456 } |
| 3457 |
| 3437 test_constructor_initializers_thisInvocation_unnamed() { | 3458 test_constructor_initializers_thisInvocation_unnamed() { |
| 3438 UnlinkedExecutable executable = | 3459 UnlinkedExecutable executable = |
| 3439 findExecutable('named', executables: serializeClassText(r''' | 3460 findExecutable('named', executables: serializeClassText(r''' |
| 3440 class C { | 3461 class C { |
| 3441 const C.named() : this(1, 'bbb'); | 3462 const C.named() : this(1, 'bbb'); |
| 3442 const C(int a, String b); | 3463 const C(int a, String b); |
| 3443 } | 3464 } |
| 3444 ''').executables); | 3465 ''').executables); |
| 3445 expect(executable.constantInitializers, hasLength(1)); | 3466 expect(executable.constantInitializers, hasLength(1)); |
| 3446 UnlinkedConstructorInitializer initializer = | 3467 UnlinkedConstructorInitializer initializer = |
| (...skipping 6259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9706 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 9727 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
| 9707 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 9728 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 9708 ]); | 9729 ]); |
| 9709 } | 9730 } |
| 9710 | 9731 |
| 9711 /** | 9732 /** |
| 9712 * TODO(scheglov) rename "Const" to "Expr" everywhere | 9733 * TODO(scheglov) rename "Const" to "Expr" everywhere |
| 9713 */ | 9734 */ |
| 9714 void _assertUnlinkedConst(UnlinkedConst constExpr, | 9735 void _assertUnlinkedConst(UnlinkedConst constExpr, |
| 9715 {bool isValidConst: true, | 9736 {bool isValidConst: true, |
| 9737 String name: '', |
| 9716 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[], | 9738 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[], |
| 9717 List<UnlinkedExprAssignOperator> assignmentOperators: | 9739 List<UnlinkedExprAssignOperator> assignmentOperators: |
| 9718 const <UnlinkedExprAssignOperator>[], | 9740 const <UnlinkedExprAssignOperator>[], |
| 9719 List<int> ints: const <int>[], | 9741 List<int> ints: const <int>[], |
| 9720 List<double> doubles: const <double>[], | 9742 List<double> doubles: const <double>[], |
| 9721 List<String> strings: const <String>[], | 9743 List<String> strings: const <String>[], |
| 9722 List<_EntityRefValidator> referenceValidators: | 9744 List<_EntityRefValidator> referenceValidators: |
| 9723 const <_EntityRefValidator>[]}) { | 9745 const <_EntityRefValidator>[]}) { |
| 9724 expect(constExpr, isNotNull); | 9746 expect(constExpr, isNotNull); |
| 9725 expect(constExpr.isValidConst, isValidConst); | 9747 expect(constExpr.isValidConst, isValidConst); |
| 9748 expect(constExpr.name, name); |
| 9726 expect(constExpr.operations, operators); | 9749 expect(constExpr.operations, operators); |
| 9727 expect(constExpr.ints, ints); | 9750 expect(constExpr.ints, ints); |
| 9728 expect(constExpr.doubles, doubles); | 9751 expect(constExpr.doubles, doubles); |
| 9729 expect(constExpr.strings, strings); | 9752 expect(constExpr.strings, strings); |
| 9730 expect(constExpr.assignmentOperators, assignmentOperators); | 9753 expect(constExpr.assignmentOperators, assignmentOperators); |
| 9731 expect(constExpr.references, hasLength(referenceValidators.length)); | 9754 expect(constExpr.references, hasLength(referenceValidators.length)); |
| 9732 for (int i = 0; i < referenceValidators.length; i++) { | 9755 for (int i = 0; i < referenceValidators.length; i++) { |
| 9733 referenceValidators[i](constExpr.references[i]); | 9756 referenceValidators[i](constExpr.references[i]); |
| 9734 } | 9757 } |
| 9735 } | 9758 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9750 class _PrefixExpectation { | 9773 class _PrefixExpectation { |
| 9751 final ReferenceKind kind; | 9774 final ReferenceKind kind; |
| 9752 final String name; | 9775 final String name; |
| 9753 final String absoluteUri; | 9776 final String absoluteUri; |
| 9754 final String relativeUri; | 9777 final String relativeUri; |
| 9755 final int numTypeParameters; | 9778 final int numTypeParameters; |
| 9756 | 9779 |
| 9757 _PrefixExpectation(this.kind, this.name, | 9780 _PrefixExpectation(this.kind, this.name, |
| 9758 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9781 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9759 } | 9782 } |
| OLD | NEW |