| 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/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 text.substring(commentStart, commentEnd).replaceAll('\r\n', '\n'); | 229 text.substring(commentStart, commentEnd).replaceAll('\r\n', '\n'); |
| 230 expect(documentationComment.text, expectedCommentText); | 230 expect(documentationComment.text, expectedCommentText); |
| 231 expect(documentationComment.offset, commentStart); | 231 expect(documentationComment.offset, commentStart); |
| 232 expect(documentationComment.length, commentEnd - commentStart); | 232 expect(documentationComment.length, commentEnd - commentStart); |
| 233 } | 233 } |
| 234 | 234 |
| 235 /** | 235 /** |
| 236 * Verify that the given [typeRef] represents the type `dynamic`. | 236 * Verify that the given [typeRef] represents the type `dynamic`. |
| 237 */ | 237 */ |
| 238 void checkDynamicTypeRef(EntityRef typeRef) { | 238 void checkDynamicTypeRef(EntityRef typeRef) { |
| 239 checkTypeRef(typeRef, null, null, null); | 239 checkTypeRef(typeRef, null, null, 'dynamic'); |
| 240 } | 240 } |
| 241 | 241 |
| 242 /** | 242 /** |
| 243 * Verify that the given [exportName] represents a reference to an entity | 243 * Verify that the given [exportName] represents a reference to an entity |
| 244 * declared in a file reachable via [absoluteUri] and [relativeUri], having | 244 * declared in a file reachable via [absoluteUri] and [relativeUri], having |
| 245 * name [expectedName]. [expectedKind] is the kind of object referenced. | 245 * name [expectedName]. [expectedKind] is the kind of object referenced. |
| 246 * [expectedTargetUnit] is the index of the compilation unit in which the | 246 * [expectedTargetUnit] is the index of the compilation unit in which the |
| 247 * target of the [exportName] is expected to appear; if not specified it is | 247 * target of the [exportName] is expected to appear; if not specified it is |
| 248 * assumed to be the defining compilation unit. | 248 * assumed to be the defining compilation unit. |
| 249 */ | 249 */ |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 if (reference.prefixReference != 0) { | 499 if (reference.prefixReference != 0) { |
| 500 // Prefixes should appear in the references table before any reference | 500 // Prefixes should appear in the references table before any reference |
| 501 // that uses them. | 501 // that uses them. |
| 502 expect(reference.prefixReference, lessThan(referenceIndex)); | 502 expect(reference.prefixReference, lessThan(referenceIndex)); |
| 503 } | 503 } |
| 504 } else { | 504 } else { |
| 505 // This is an implicit reference, so its name should be in | 505 // This is an implicit reference, so its name should be in |
| 506 // [LinkedUnit.references]. | 506 // [LinkedUnit.references]. |
| 507 name = referenceResolution.name; | 507 name = referenceResolution.name; |
| 508 } | 508 } |
| 509 if (referenceIndex == 0) { | 509 // Index 0 is reserved. |
| 510 // Index 0 is reserved for "dynamic". | 510 expect(referenceIndex, isNot(0)); |
| 511 expect(name, isEmpty); | |
| 512 } | |
| 513 if (absoluteUri == null) { | 511 if (absoluteUri == null) { |
| 514 expect(referenceResolution.dependency, 0); | 512 expect(referenceResolution.dependency, 0); |
| 515 } else { | 513 } else { |
| 516 checkDependency(referenceResolution.dependency, absoluteUri, relativeUri); | 514 checkDependency(referenceResolution.dependency, absoluteUri, relativeUri); |
| 517 } | 515 } |
| 518 if (expectedKind == ReferenceKind.unresolved && !checkAstDerivedData) { | 516 if (expectedKind == ReferenceKind.unresolved && !checkAstDerivedData) { |
| 519 // summarize_elements.dart isn't yet able to record the name of | 517 // summarize_elements.dart isn't yet able to record the name of |
| 520 // unresolved references. TODO(paulberry): fix this. | 518 // unresolved references. TODO(paulberry): fix this. |
| 521 expect(name, '*unresolved*'); | 519 expect(name, '*unresolved*'); |
| 522 } else { | 520 } else { |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 UnlinkedConstOperation.pushInt, | 1585 UnlinkedConstOperation.pushInt, |
| 1588 UnlinkedConstOperation.pushInt, | 1586 UnlinkedConstOperation.pushInt, |
| 1589 UnlinkedConstOperation.pushInt, | 1587 UnlinkedConstOperation.pushInt, |
| 1590 UnlinkedConstOperation.makeList | 1588 UnlinkedConstOperation.makeList |
| 1591 ], ints: [ | 1589 ], ints: [ |
| 1592 11, | 1590 11, |
| 1593 22, | 1591 22, |
| 1594 33, | 1592 33, |
| 1595 3 | 1593 3 |
| 1596 ], referenceValidators: [ | 1594 ], referenceValidators: [ |
| 1597 (EntityRef r) => checkTypeRef(r, null, null, '', | 1595 (EntityRef r) => checkDynamicTypeRef(r) |
| 1598 expectedKind: ReferenceKind.classOrEnum) | |
| 1599 ]); | 1596 ]); |
| 1600 } | 1597 } |
| 1601 | 1598 |
| 1602 test_constExpr_makeMap_typed() { | 1599 test_constExpr_makeMap_typed() { |
| 1603 UnlinkedVariable variable = serializeVariableText( | 1600 UnlinkedVariable variable = serializeVariableText( |
| 1604 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};'); | 1601 'const v = const <int, String>{11: "aaa", 22: "bbb", 33: "ccc"};'); |
| 1605 _assertUnlinkedConst(variable.constExpr, operators: [ | 1602 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1606 UnlinkedConstOperation.pushInt, | 1603 UnlinkedConstOperation.pushInt, |
| 1607 UnlinkedConstOperation.pushString, | 1604 UnlinkedConstOperation.pushString, |
| 1608 UnlinkedConstOperation.pushInt, | 1605 UnlinkedConstOperation.pushInt, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 ], ints: [ | 1638 ], ints: [ |
| 1642 11, | 1639 11, |
| 1643 22, | 1640 22, |
| 1644 33, | 1641 33, |
| 1645 3 | 1642 3 |
| 1646 ], strings: [ | 1643 ], strings: [ |
| 1647 'aaa', | 1644 'aaa', |
| 1648 'bbb', | 1645 'bbb', |
| 1649 'ccc' | 1646 'ccc' |
| 1650 ], referenceValidators: [ | 1647 ], referenceValidators: [ |
| 1651 (EntityRef r) => checkTypeRef(r, null, null, '', | 1648 (EntityRef r) => checkDynamicTypeRef(r), |
| 1652 expectedKind: ReferenceKind.classOrEnum), | 1649 (EntityRef r) => checkDynamicTypeRef(r) |
| 1653 (EntityRef r) => checkTypeRef(r, null, null, '', | |
| 1654 expectedKind: ReferenceKind.classOrEnum) | |
| 1655 ]); | 1650 ]); |
| 1656 } | 1651 } |
| 1657 | 1652 |
| 1658 test_constExpr_makeSymbol() { | 1653 test_constExpr_makeSymbol() { |
| 1659 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;'); | 1654 UnlinkedVariable variable = serializeVariableText('const v = #a.bb.ccc;'); |
| 1660 _assertUnlinkedConst(variable.constExpr, operators: [ | 1655 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 1661 UnlinkedConstOperation.pushString, | 1656 UnlinkedConstOperation.pushString, |
| 1662 UnlinkedConstOperation.makeSymbol | 1657 UnlinkedConstOperation.makeSymbol |
| 1663 ], strings: [ | 1658 ], strings: [ |
| 1664 'a.bb.ccc' | 1659 'a.bb.ccc' |
| (...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4225 expect(constExpr.operations, operators); | 4220 expect(constExpr.operations, operators); |
| 4226 expect(constExpr.ints, ints); | 4221 expect(constExpr.ints, ints); |
| 4227 expect(constExpr.doubles, doubles); | 4222 expect(constExpr.doubles, doubles); |
| 4228 expect(constExpr.strings, strings); | 4223 expect(constExpr.strings, strings); |
| 4229 expect(constExpr.references, hasLength(referenceValidators.length)); | 4224 expect(constExpr.references, hasLength(referenceValidators.length)); |
| 4230 for (int i = 0; i < referenceValidators.length; i++) { | 4225 for (int i = 0; i < referenceValidators.length; i++) { |
| 4231 referenceValidators[i](constExpr.references[i]); | 4226 referenceValidators[i](constExpr.references[i]); |
| 4232 } | 4227 } |
| 4233 } | 4228 } |
| 4234 } | 4229 } |
| OLD | NEW |