perf(ext/console): break on iterableLimit & better sparse array handling (#15935)

This commit is contained in:
Marcos Casagrande 2022-09-26 08:55:22 +02:00 committed by GitHub
parent 9a9dd12253
commit b73cb7bf9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 136 additions and 42 deletions

View file

@ -759,7 +759,54 @@ Deno.test(function consoleTestStringifyIterable() {
`[ <4 empty items>, 0, 0, <4 empty items> ]`,
);
/* TODO(ry) Fix this test
const emptyArray = Array(5000);
assertEquals(
stringify(emptyArray),
`[ <5000 empty items> ]`,
);
assertEquals(
stringify(Array(1)),
`[ <1 empty item> ]`,
);
const withEmptyElAndMoreItems = Array(500);
withEmptyElAndMoreItems.fill(0, 50, 80);
withEmptyElAndMoreItems.fill(2, 100, 120);
withEmptyElAndMoreItems.fill(3, 140, 160);
withEmptyElAndMoreItems.fill(4, 180);
assertEquals(
stringify(withEmptyElAndMoreItems),
`[
<50 empty items>, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, <20 empty items>,
2, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2,
2, 2, 2, 2,
<20 empty items>, 3, 3, 3,
3, 3, 3, 3,
3, 3, 3, 3,
3, 3, 3, 3,
3, 3, 3, 3,
3, <20 empty items>, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
... 294 more items
]`,
);
const lWithEmptyEl = Array(200);
lWithEmptyEl.fill(0, 50, 80);
assertEquals(
@ -776,9 +823,8 @@ Deno.test(function consoleTestStringifyIterable() {
0, 0, 0,
0, 0, 0,
0, <120 empty items>
]`
]`,
);
*/
});
Deno.test(function consoleTestStringifyIterableWhenGrouped() {