Skip to content

Commit e717f53

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Tests for constants referencing fields.
Change-Id: I908d2965e3adad0468d44d23ebcb29918a7529dc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422322 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 7c9ded3 commit e717f53

File tree

1 file changed

+125
-30
lines changed

1 file changed

+125
-30
lines changed

pkg/analyzer/test/src/dart/analysis/driver_test.dart

Lines changed: 125 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17253,8 +17253,103 @@ const b = B;
1725317253
);
1725417254
}
1725517255

17256-
test_manifest_constInitializer_prefixedIdentifier_importPrefix() async {
17257-
// TODO(scheglov): also test ClassName.field
17256+
test_manifest_constInitializer_prefixedIdentifier_className_fieldName() async {
17257+
await _runLibraryManifestScenario(
17258+
initialCode: r'''
17259+
class A {
17260+
static const a = 0;
17261+
static const b = 0;
17262+
}
17263+
17264+
const c = A.a;
17265+
const d = A.b;
17266+
''',
17267+
expectedInitialEvents: r'''
17268+
[operation] linkLibraryCycle SDK
17269+
[operation] linkLibraryCycle
17270+
package:test/test.dart
17271+
manifest
17272+
A: #M0
17273+
declaredMembers
17274+
a: #M1
17275+
b: #M2
17276+
c: #M3
17277+
d: #M4
17278+
''',
17279+
updatedCode: r'''
17280+
class A {
17281+
static const a = 0;
17282+
static const b = 1;
17283+
}
17284+
17285+
const c = A.a;
17286+
const d = A.b;
17287+
''',
17288+
expectedUpdatedEvents: r'''
17289+
[operation] linkLibraryCycle
17290+
package:test/test.dart
17291+
manifest
17292+
A: #M0
17293+
declaredMembers
17294+
a: #M1
17295+
b: #M5
17296+
c: #M3
17297+
d: #M6
17298+
''',
17299+
);
17300+
}
17301+
17302+
test_manifest_constInitializer_prefixedIdentifier_importPrefix_className_fieldName() async {
17303+
await _runLibraryManifestScenario(
17304+
initialCode: r'''
17305+
import '' as self;
17306+
17307+
class A {
17308+
static const a = 0;
17309+
static const b = 0;
17310+
}
17311+
17312+
const c = self.A.a;
17313+
const d = self.A.b;
17314+
''',
17315+
expectedInitialEvents: r'''
17316+
[operation] linkLibraryCycle SDK
17317+
[operation] linkLibraryCycle
17318+
package:test/test.dart
17319+
manifest
17320+
A: #M0
17321+
declaredMembers
17322+
a: #M1
17323+
b: #M2
17324+
c: #M3
17325+
d: #M4
17326+
''',
17327+
updatedCode: r'''
17328+
import '' as self;
17329+
17330+
class A {
17331+
static const a = 0;
17332+
static const b = 1;
17333+
}
17334+
17335+
const c = self.A.a;
17336+
const d = self.A.b;
17337+
''',
17338+
expectedUpdatedEvents: r'''
17339+
[operation] linkLibraryCycle
17340+
package:test/test.dart
17341+
manifest
17342+
A: #M0
17343+
declaredMembers
17344+
a: #M1
17345+
b: #M5
17346+
c: #M3
17347+
d: #M6
17348+
''',
17349+
);
17350+
}
17351+
17352+
test_manifest_constInitializer_prefixedIdentifier_importPrefix_topVariable() async {
1725817353
await _runLibraryManifestScenario(
1725917354
initialCode: r'''
1726017355
import '' as self;
@@ -17292,74 +17387,74 @@ const d = self.b;
1729217387
);
1729317388
}
1729417389

17295-
test_manifest_constInitializer_prefixedIdentifier_importPrefix2() async {
17296-
newFile('$testPackageLibPath/a.dart', r'''
17297-
const x = 0;
17298-
''');
17299-
17300-
newFile('$testPackageLibPath/b.dart', r'''
17301-
const x = 0;
17302-
''');
17390+
test_manifest_constInitializer_prefixedIdentifier_importPrefix_topVariable_changePrefix() async {
17391+
newFile('$testPackageLibPath/a.dart', '');
1730317392

1730417393
await _runLibraryManifestScenario(
1730517394
initialCode: r'''
17306-
import 'a.dart' as p;
17307-
const z = p.x;
17395+
import 'a.dart' as x;
17396+
const z = x.x + y.y;
1730817397
''',
1730917398
expectedInitialEvents: r'''
1731017399
[operation] linkLibraryCycle SDK
1731117400
[operation] linkLibraryCycle
1731217401
package:test/a.dart
17313-
manifest
17314-
x: #M0
1731517402
[operation] linkLibraryCycle
1731617403
package:test/test.dart
1731717404
manifest
17318-
z: #M1
17405+
z: #M0
1731917406
''',
1732017407
updatedCode: r'''
17321-
import 'b.dart' as p;
17322-
const z = p.x;
17408+
import 'a.dart' as y;
17409+
const z = x.x + y.y;
1732317410
''',
1732417411
expectedUpdatedEvents: r'''
17325-
[operation] linkLibraryCycle
17326-
package:test/b.dart
17327-
manifest
17328-
x: #M2
1732917412
[operation] linkLibraryCycle
1733017413
package:test/test.dart
1733117414
manifest
17332-
z: #M3
17415+
z: #M1
1733317416
''',
1733417417
);
1733517418
}
1733617419

17337-
test_manifest_constInitializer_prefixedIdentifier_importPrefix3() async {
17338-
newFile('$testPackageLibPath/a.dart', '');
17420+
test_manifest_constInitializer_prefixedIdentifier_importPrefix_topVariable_changeUri() async {
17421+
newFile('$testPackageLibPath/a.dart', r'''
17422+
const x = 0;
17423+
''');
17424+
17425+
newFile('$testPackageLibPath/b.dart', r'''
17426+
const x = 0;
17427+
''');
1733917428

1734017429
await _runLibraryManifestScenario(
1734117430
initialCode: r'''
17342-
import 'a.dart' as x;
17343-
const z = x.x + y.y;
17431+
import 'a.dart' as p;
17432+
const z = p.x;
1734417433
''',
1734517434
expectedInitialEvents: r'''
1734617435
[operation] linkLibraryCycle SDK
1734717436
[operation] linkLibraryCycle
1734817437
package:test/a.dart
17438+
manifest
17439+
x: #M0
1734917440
[operation] linkLibraryCycle
1735017441
package:test/test.dart
1735117442
manifest
17352-
z: #M0
17443+
z: #M1
1735317444
''',
1735417445
updatedCode: r'''
17355-
import 'a.dart' as y;
17356-
const z = x.x + y.y;
17446+
import 'b.dart' as p;
17447+
const z = p.x;
1735717448
''',
1735817449
expectedUpdatedEvents: r'''
17450+
[operation] linkLibraryCycle
17451+
package:test/b.dart
17452+
manifest
17453+
x: #M2
1735917454
[operation] linkLibraryCycle
1736017455
package:test/test.dart
1736117456
manifest
17362-
z: #M1
17457+
z: #M3
1736317458
''',
1736417459
);
1736517460
}

0 commit comments

Comments
 (0)