Skip to content

Commit

Permalink
Fix bug in iterator test, modify attempt count, make more robust (#61242
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kg committed Nov 5, 2021
1 parent 8fbf206 commit e7c1bc8
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,31 @@ public static async Task Iterator()
return rangeIterator;
");

for (int attempt = 0; attempt < 100_000; attempt++)
const int count = 500;
for (int attempt = 0; attempt < 100; attempt++)
{
int index = 0;
try
{
using (var entriesIterator = (JSObject)makeRangeIterator.Call(null, 0, 500))
{
var cnt = entriesIterator.ToEnumerable().Count();
var entriesIterator = (JSObject)makeRangeIterator.Call(null, 0, count, 1);
Assert.NotNull(entriesIterator);
using (entriesIterator) {
var enumerable = entriesIterator.ToEnumerable();
var enumerator = enumerable.GetEnumerator();
Assert.NotNull(enumerator);

using (enumerator) {
while (enumerator.MoveNext()) {
Assert.NotNull(enumerator.Current);
index++;
}
}
}
Assert.Equal(count, index);
}
catch (Exception ex)
{
throw new Exception(ex.Message + " At attempt=" + attempt, ex);
throw new Exception($"At attempt={attempt}, index={index}: {ex.Message}", ex);
}
}
}
Expand Down

0 comments on commit e7c1bc8

Please sign in to comment.