| 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 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); | 3456 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
| 3457 expect(initializer.name, 'named'); | 3457 expect(initializer.name, 'named'); |
| 3458 expect(initializer.expression, isNull); | 3458 expect(initializer.expression, isNull); |
| 3459 expect(initializer.arguments, hasLength(2)); | 3459 expect(initializer.arguments, hasLength(2)); |
| 3460 _assertUnlinkedConst(initializer.arguments[0], | 3460 _assertUnlinkedConst(initializer.arguments[0], |
| 3461 operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 3461 operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 3462 _assertUnlinkedConst(initializer.arguments[1], | 3462 _assertUnlinkedConst(initializer.arguments[1], |
| 3463 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); | 3463 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); |
| 3464 } | 3464 } |
| 3465 | 3465 |
| 3466 test_constructor_initializers_thisInvocation_nameExpression() { | 3466 test_constructor_initializers_thisInvocation_namedExpression() { |
| 3467 UnlinkedExecutable executable = | 3467 UnlinkedExecutable executable = |
| 3468 findExecutable('', executables: serializeClassText(r''' | 3468 findExecutable('', executables: serializeClassText(r''' |
| 3469 class C { | 3469 class C { |
| 3470 const C() : this.named(a: 1, b: 2); | 3470 const C() : this.named(1, b: 2, c: 3); |
| 3471 const C.named({int a, int b}); | 3471 const C.named(a, {int b, int c}); |
| 3472 } | 3472 } |
| 3473 ''').executables); | 3473 ''').executables); |
| 3474 expect(executable.constantInitializers, hasLength(1)); | 3474 expect(executable.constantInitializers, hasLength(1)); |
| 3475 UnlinkedConstructorInitializer initializer = | 3475 UnlinkedConstructorInitializer initializer = |
| 3476 executable.constantInitializers[0]; | 3476 executable.constantInitializers[0]; |
| 3477 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); | 3477 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
| 3478 expect(initializer.name, 'named'); | 3478 expect(initializer.name, 'named'); |
| 3479 expect(initializer.expression, isNull); | 3479 expect(initializer.expression, isNull); |
| 3480 expect(initializer.arguments, hasLength(2)); | 3480 expect(initializer.arguments, hasLength(3)); |
| 3481 _assertUnlinkedConst(initializer.arguments[0], | 3481 _assertUnlinkedConst(initializer.arguments[0], |
| 3482 name: 'a', operators: [UnlinkedConstOperation.pushInt], ints: [1]); | 3482 operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 3483 _assertUnlinkedConst(initializer.arguments[1], | 3483 _assertUnlinkedConst(initializer.arguments[1], |
| 3484 name: 'b', operators: [UnlinkedConstOperation.pushInt], ints: [2]); | 3484 operators: [UnlinkedConstOperation.pushInt], ints: [2]); |
| 3485 _assertUnlinkedConst(initializer.arguments[2], |
| 3486 operators: [UnlinkedConstOperation.pushInt], ints: [3]); |
| 3487 expect(initializer.argumentNames, ['b', 'c']); |
| 3488 } |
| 3489 |
| 3490 test_constructor_initializers_superInvocation_namedExpression() { |
| 3491 UnlinkedExecutable executable = |
| 3492 findExecutable('', executables: serializeClassText(r''' |
| 3493 class A { |
| 3494 const A(a, {int b, int c}); |
| 3495 } |
| 3496 class C extends A { |
| 3497 const C() : super(1, b: 2, c: 3); |
| 3498 } |
| 3499 ''').executables); |
| 3500 expect(executable.constantInitializers, hasLength(1)); |
| 3501 UnlinkedConstructorInitializer initializer = |
| 3502 executable.constantInitializers[0]; |
| 3503 expect( |
| 3504 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); |
| 3505 expect(initializer.name, ''); |
| 3506 expect(initializer.expression, isNull); |
| 3507 expect(initializer.arguments, hasLength(3)); |
| 3508 _assertUnlinkedConst(initializer.arguments[0], |
| 3509 operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 3510 _assertUnlinkedConst(initializer.arguments[1], |
| 3511 operators: [UnlinkedConstOperation.pushInt], ints: [2]); |
| 3512 _assertUnlinkedConst(initializer.arguments[2], |
| 3513 operators: [UnlinkedConstOperation.pushInt], ints: [3]); |
| 3514 expect(initializer.argumentNames, ['b', 'c']); |
| 3485 } | 3515 } |
| 3486 | 3516 |
| 3487 test_constructor_initializers_thisInvocation_unnamed() { | 3517 test_constructor_initializers_thisInvocation_unnamed() { |
| 3488 UnlinkedExecutable executable = | 3518 UnlinkedExecutable executable = |
| 3489 findExecutable('named', executables: serializeClassText(r''' | 3519 findExecutable('named', executables: serializeClassText(r''' |
| 3490 class C { | 3520 class C { |
| 3491 const C.named() : this(1, 'bbb'); | 3521 const C.named() : this(1, 'bbb'); |
| 3492 const C(int a, String b); | 3522 const C(int a, String b); |
| 3493 } | 3523 } |
| 3494 ''').executables); | 3524 ''').executables); |
| (...skipping 6445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9940 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 9970 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
| 9941 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 9971 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 9942 ]); | 9972 ]); |
| 9943 } | 9973 } |
| 9944 | 9974 |
| 9945 /** | 9975 /** |
| 9946 * TODO(scheglov) rename "Const" to "Expr" everywhere | 9976 * TODO(scheglov) rename "Const" to "Expr" everywhere |
| 9947 */ | 9977 */ |
| 9948 void _assertUnlinkedConst(UnlinkedConst constExpr, | 9978 void _assertUnlinkedConst(UnlinkedConst constExpr, |
| 9949 {bool isValidConst: true, | 9979 {bool isValidConst: true, |
| 9950 String name: '', | |
| 9951 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[], | 9980 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[], |
| 9952 List<UnlinkedExprAssignOperator> assignmentOperators: | 9981 List<UnlinkedExprAssignOperator> assignmentOperators: |
| 9953 const <UnlinkedExprAssignOperator>[], | 9982 const <UnlinkedExprAssignOperator>[], |
| 9954 List<int> ints: const <int>[], | 9983 List<int> ints: const <int>[], |
| 9955 List<double> doubles: const <double>[], | 9984 List<double> doubles: const <double>[], |
| 9956 List<String> strings: const <String>[], | 9985 List<String> strings: const <String>[], |
| 9957 List<_EntityRefValidator> referenceValidators: | 9986 List<_EntityRefValidator> referenceValidators: |
| 9958 const <_EntityRefValidator>[]}) { | 9987 const <_EntityRefValidator>[]}) { |
| 9959 expect(constExpr, isNotNull); | 9988 expect(constExpr, isNotNull); |
| 9960 expect(constExpr.isValidConst, isValidConst); | 9989 expect(constExpr.isValidConst, isValidConst); |
| 9961 expect(constExpr.name, name); | |
| 9962 expect(constExpr.operations, operators); | 9990 expect(constExpr.operations, operators); |
| 9963 expect(constExpr.ints, ints); | 9991 expect(constExpr.ints, ints); |
| 9964 expect(constExpr.doubles, doubles); | 9992 expect(constExpr.doubles, doubles); |
| 9965 expect(constExpr.strings, strings); | 9993 expect(constExpr.strings, strings); |
| 9966 expect(constExpr.assignmentOperators, assignmentOperators); | 9994 expect(constExpr.assignmentOperators, assignmentOperators); |
| 9967 expect(constExpr.references, hasLength(referenceValidators.length)); | 9995 expect(constExpr.references, hasLength(referenceValidators.length)); |
| 9968 for (int i = 0; i < referenceValidators.length; i++) { | 9996 for (int i = 0; i < referenceValidators.length; i++) { |
| 9969 referenceValidators[i](constExpr.references[i]); | 9997 referenceValidators[i](constExpr.references[i]); |
| 9970 } | 9998 } |
| 9971 } | 9999 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9986 class _PrefixExpectation { | 10014 class _PrefixExpectation { |
| 9987 final ReferenceKind kind; | 10015 final ReferenceKind kind; |
| 9988 final String name; | 10016 final String name; |
| 9989 final String absoluteUri; | 10017 final String absoluteUri; |
| 9990 final String relativeUri; | 10018 final String relativeUri; |
| 9991 final int numTypeParameters; | 10019 final int numTypeParameters; |
| 9992 | 10020 |
| 9993 _PrefixExpectation(this.kind, this.name, | 10021 _PrefixExpectation(this.kind, this.name, |
| 9994 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 10022 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9995 } | 10023 } |
| OLD | NEW |