mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 13:14:48 +00:00
fix: console.log should see color codes when grouping occurs (#7000)
This commit is contained in:
parent
732a437352
commit
67fe8cd848
3 changed files with 90 additions and 12 deletions
|
@ -371,14 +371,14 @@
|
||||||
let str = "";
|
let str = "";
|
||||||
let j = i;
|
let j = i;
|
||||||
for (; j < max - 1; j++) {
|
for (; j < max - 1; j++) {
|
||||||
// In future, colors should be taken here into the account
|
const lengthOfColorCodes = entries[j].length - dataLen[j];
|
||||||
const padding = maxLineLength[j - i];
|
const padding = maxLineLength[j - i] + lengthOfColorCodes;
|
||||||
str += `${entries[j]}, `[order](padding, " ");
|
str += `${entries[j]}, `[order](padding, " ");
|
||||||
}
|
}
|
||||||
if (order === "padStart") {
|
if (order === "padStart") {
|
||||||
|
const lengthOfColorCodes = entries[j].length - dataLen[j];
|
||||||
const padding = maxLineLength[j - i] +
|
const padding = maxLineLength[j - i] +
|
||||||
entries[j].length -
|
lengthOfColorCodes -
|
||||||
dataLen[j] -
|
|
||||||
separatorSpace;
|
separatorSpace;
|
||||||
str += entries[j].padStart(padding, " ");
|
str += entries[j].padStart(padding, " ");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -590,6 +590,84 @@ unitTest(function consoleTestStringifyIterable() {
|
||||||
*/
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
|
unitTest(function consoleTestStringifyIterableWhenGrouped(): void {
|
||||||
|
const withOddNumberOfEls = new Float64Array(
|
||||||
|
[
|
||||||
|
2.1,
|
||||||
|
2.01,
|
||||||
|
2.001,
|
||||||
|
2.0001,
|
||||||
|
2.00001,
|
||||||
|
2.000001,
|
||||||
|
2.0000001,
|
||||||
|
2.00000001,
|
||||||
|
2.000000001,
|
||||||
|
2.0000000001,
|
||||||
|
2,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
stringify(withOddNumberOfEls),
|
||||||
|
`Float64Array(11) [
|
||||||
|
2.1, 2.01,
|
||||||
|
2.001, 2.0001,
|
||||||
|
2.00001, 2.000001,
|
||||||
|
2.0000001, 2.00000001,
|
||||||
|
2.000000001, 2.0000000001,
|
||||||
|
2
|
||||||
|
]`,
|
||||||
|
);
|
||||||
|
const withEvenNumberOfEls = new Float64Array(
|
||||||
|
[
|
||||||
|
2.1,
|
||||||
|
2.01,
|
||||||
|
2.001,
|
||||||
|
2.0001,
|
||||||
|
2.00001,
|
||||||
|
2.000001,
|
||||||
|
2.0000001,
|
||||||
|
2.00000001,
|
||||||
|
2.000000001,
|
||||||
|
2.0000000001,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
stringify(withEvenNumberOfEls),
|
||||||
|
`Float64Array(12) [
|
||||||
|
2.1, 2.01,
|
||||||
|
2.001, 2.0001,
|
||||||
|
2.00001, 2.000001,
|
||||||
|
2.0000001, 2.00000001,
|
||||||
|
2.000000001, 2.0000000001,
|
||||||
|
2, 2
|
||||||
|
]`,
|
||||||
|
);
|
||||||
|
const withThreeColumns = [
|
||||||
|
2,
|
||||||
|
2.1,
|
||||||
|
2.11,
|
||||||
|
2,
|
||||||
|
2.111,
|
||||||
|
2.1111,
|
||||||
|
2,
|
||||||
|
2.1,
|
||||||
|
2.11,
|
||||||
|
2,
|
||||||
|
2.1,
|
||||||
|
];
|
||||||
|
assertEquals(
|
||||||
|
stringify(withThreeColumns),
|
||||||
|
`[
|
||||||
|
2, 2.1, 2.11,
|
||||||
|
2, 2.111, 2.1111,
|
||||||
|
2, 2.1, 2.11,
|
||||||
|
2, 2.1
|
||||||
|
]`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
unitTest(async function consoleTestStringifyPromises(): Promise<void> {
|
unitTest(async function consoleTestStringifyPromises(): Promise<void> {
|
||||||
const pendingPromise = new Promise((_res, _rej) => {});
|
const pendingPromise = new Promise((_res, _rej) => {});
|
||||||
assertEquals(stringify(pendingPromise), "Promise { <pending> }");
|
assertEquals(stringify(pendingPromise), "Promise { <pending> }");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue