Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: pkg/analyzer/test/src/summary/index_unit_test.dart

Issue 1788673004: Index unqualified unresolved used names. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/summary/index_unit_test.dart
diff --git a/pkg/analyzer/test/src/summary/index_unit_test.dart b/pkg/analyzer/test/src/summary/index_unit_test.dart
index 90547ec654a056b7701bb658b0a10b4b77dc783d..d1dd94998abe438cdf38624ba1bbfd5c852b69b5 100644
--- a/pkg/analyzer/test/src/summary/index_unit_test.dart
+++ b/pkg/analyzer/test/src/summary/index_unit_test.dart
@@ -911,18 +911,35 @@ main(p) {
}
''');
assertThatName('x')
- ..isUsed('x;', IndexRelationKind.IS_READ_BY)
- ..isUsed('x = 1;', IndexRelationKind.IS_WRITTEN_BY)
- ..isUsed('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY)
- ..isUsed('x();', IndexRelationKind.IS_INVOKED_BY);
+ ..isUsedQ('x;', IndexRelationKind.IS_READ_BY)
+ ..isUsedQ('x = 1;', IndexRelationKind.IS_WRITTEN_BY)
+ ..isUsedQ('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY)
+ ..isUsedQ('x();', IndexRelationKind.IS_INVOKED_BY);
}
- void test_usedName_unqualified() {
+ void test_usedName_unqualified_resolved() {
verifyNoTestUnitErrors = false;
_indexTestUnit('''
class C {
var x;
+ m() {
+ x;
+ x = 1;
+ x += 2;
+ x();
+ }
}
+''');
+ assertThatName('x')
+ ..isNotUsed('x;', IndexRelationKind.IS_READ_BY)
+ ..isNotUsed('x = 1;', IndexRelationKind.IS_WRITTEN_BY)
+ ..isNotUsed('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY)
+ ..isNotUsed('x();', IndexRelationKind.IS_INVOKED_BY);
+ }
+
+ void test_usedName_unqualified_unresolved() {
+ verifyNoTestUnitErrors = false;
+ _indexTestUnit('''
main() {
x;
x = 1;
@@ -931,10 +948,10 @@ main() {
}
''');
assertThatName('x')
- ..isNotUsed('x;', IndexRelationKind.IS_READ_BY)
- ..isNotUsed('x = 1;', IndexRelationKind.IS_WRITTEN_BY)
- ..isNotUsed('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY)
- ..isNotUsed('x();', IndexRelationKind.IS_INVOKED_BY);
+ ..isUsed('x;', IndexRelationKind.IS_READ_BY)
+ ..isUsed('x = 1;', IndexRelationKind.IS_WRITTEN_BY)
+ ..isUsed('x += 2;', IndexRelationKind.IS_READ_WRITTEN_BY)
+ ..isUsed('x();', IndexRelationKind.IS_INVOKED_BY);
}
void _assertDefinedName(String name, IndexNameKind kind, String search) {
@@ -976,7 +993,9 @@ main() {
for (int i = 0; i < unitIndex.usedNames.length; i++) {
if (unitIndex.usedNames[i] == nameId &&
unitIndex.usedNameKinds[i] == kind &&
- unitIndex.usedNameOffsets[i] == expectedLocation.offset) {
+ unitIndex.usedNameOffsets[i] == expectedLocation.offset &&
+ unitIndex.usedNameIsQualifiedFlags[i] ==
+ expectedLocation.isQualified) {
if (isNot) {
_failWithIndexDump('Unexpected $name $kind at $expectedLocation');
}
@@ -1159,6 +1178,11 @@ class _NameIndexAssert {
void isUsed(String search, IndexRelationKind kind) {
test._assertUsedName(
+ name, kind, test._expectedLocation(search, false), false);
+ }
+
+ void isUsedQ(String search, IndexRelationKind kind) {
+ test._assertUsedName(
name, kind, test._expectedLocation(search, true), false);
}
}
« pkg/analyzer/lib/src/summary/index_unit.dart ('K') | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698