Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit fbfa0d5

Browse files
author
MikhailArkhipov
committed
Fix iterable description tests
1 parent a0b7a6d commit fbfa0d5

2 files changed

Lines changed: 31 additions & 13 deletions

File tree

src/Analysis/Engine/Impl/Values/IterableInfo.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -293,20 +293,20 @@ public override IEnumerable<KeyValuePair<string, string>> GetRichDescription() {
293293
}
294294

295295
yield return new KeyValuePair<string, string>(WellKnownRichDescriptionKinds.Misc, "[");
296-
if (indexTypes.Length < 6) {
297-
bool first = true;
298-
foreach (var i in indexTypes) {
299-
if (first) {
300-
first = false;
301-
} else {
302-
yield return new KeyValuePair<string, string>(WellKnownRichDescriptionKinds.Comma, ", ");
303-
}
304-
foreach (var kv in i.Types.GetRichDescriptions(unionPrefix: "[", unionSuffix: "]")) {
305-
yield return kv;
306-
}
296+
bool first = true;
297+
var i = 0;
298+
for (; i < Math.Min(indexTypes.Length, 6); i++) {
299+
if (first) {
300+
first = false;
301+
} else {
302+
yield return new KeyValuePair<string, string>(WellKnownRichDescriptionKinds.Comma, ", ");
307303
}
308-
} else {
309-
yield return new KeyValuePair<string, string>(WellKnownRichDescriptionKinds.Misc, "...");
304+
foreach (var kv in indexTypes[i].Types.GetRichDescriptions(unionPrefix: "[", unionSuffix: "]")) {
305+
yield return kv;
306+
}
307+
}
308+
if(i < indexTypes.Length){
309+
yield return new KeyValuePair<string, string>(WellKnownRichDescriptionKinds.Misc, ", ...");
310310
}
311311
yield return new KeyValuePair<string, string>(WellKnownRichDescriptionKinds.Misc, "]");
312312
}

src/Analysis/Engine/Test/AnalysisTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,24 @@ public async Task SequenceMultiply_2() {
26022602
}
26032603
}
26042604

2605+
[TestMethod, Priority(0)]
2606+
public async Task InterableTypesDescription_Long() {
2607+
var text = @"
2608+
x1 = (1,'2',3,4.,5,6,7,8)
2609+
y1 = 100 * x1
2610+
2611+
fob = [1,2,'3',4,5.,6,7,8]
2612+
oar = 100 * fob
2613+
";
2614+
2615+
using (var server = await CreateServerAsync(PythonVersions.LatestAvailable2X)) {
2616+
var analysis = await server.OpenDefaultDocumentAndGetAnalysisAsync(text);
2617+
analysis.Should()
2618+
.HaveVariable("y1").WithDescription("tuple[int, str, int, float, int, int, ...]")
2619+
.And.HaveVariable("oar").WithDescription("list[int, int, str, int, float, int, ...]");
2620+
}
2621+
}
2622+
26052623
[TestMethod, Priority(0)]
26062624
public async Task SequenceContains() {
26072625
var text = @"

0 commit comments

Comments
 (0)