Skip to content

Commit 0006375

Browse files
committed
verify substring problem is fixed
1 parent f8604b2 commit 0006375

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

test/model_test.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ void main() {
718718
});
719719

720720
test('correctly finds all the classes', () {
721-
expect(classes, hasLength(26));
721+
expect(classes, hasLength(28));
722722
});
723723

724724
test('abstract', () {
@@ -1849,7 +1849,7 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
18491849
prettyColorsConstant,
18501850
deprecated;
18511851

1852-
Field aStaticConstField;
1852+
Field aStaticConstField, aName;
18531853

18541854
setUp(() {
18551855
greenConstant =
@@ -1861,9 +1861,16 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans,
18611861
cat = exLibrary.constants.firstWhere((c) => c.name == 'MY_CAT');
18621862
deprecated =
18631863
exLibrary.constants.firstWhere((c) => c.name == 'deprecated');
1864+
Class Dog = exLibrary.allClasses.firstWhere((c) => c.name == 'Dog');
18641865
aStaticConstField =
1865-
exLibrary.allClasses.firstWhere((c) => c.name == 'Dog')
1866-
.allFields.firstWhere((f) => f.name == 'aStaticConstField');
1866+
Dog.allFields.firstWhere((f) => f.name == 'aStaticConstField');
1867+
aName =
1868+
Dog.allFields.firstWhere((f) => f.name == 'aName');
1869+
});
1870+
1871+
test('substrings of the constant values type are not linked (#1535)', () {
1872+
expect(aName.constantValue,
1873+
'const ExtendedShortName("hello there")');
18671874
});
18681875

18691876
test('constant field values are escaped', () {

testing/test_package/lib/example.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ class TemplatedClass<X> {
9494
}
9595
}
9696

97+
class ShortName {
98+
final String aParameter;
99+
const ShortName(this.aParameter);
100+
}
101+
102+
class ExtendedShortName extends ShortName {
103+
const ExtendedShortName(String aParameter) : super(aParameter);
104+
}
105+
97106
/// Referencing [processMessage] (or other things) here should not break
98107
/// enum constants ala #1445
99108
enum Animal {
@@ -273,6 +282,9 @@ class Dog implements Cat, E {
273282
final int aFinalField;
274283
static const String aStaticConstField = "A Constant Dog";
275284

285+
/// Verify link substitution in constants (#1535)
286+
static const ShortName aName = const ExtendedShortName("hello there");
287+
276288
@protected
277289
final int aProtectedFinalField;
278290

0 commit comments

Comments
 (0)