summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/rt/02_console.js8
-rw-r--r--cli/tests/seed_random.js.out16
-rw-r--r--cli/tests/unit/console_test.ts78
3 files changed, 90 insertions, 12 deletions
diff --git a/cli/rt/02_console.js b/cli/rt/02_console.js
index 5a9dd4186..1cf47afbe 100644
--- a/cli/rt/02_console.js
+++ b/cli/rt/02_console.js
@@ -371,14 +371,14 @@
let str = "";
let j = i;
for (; j < max - 1; j++) {
- // In future, colors should be taken here into the account
- const padding = maxLineLength[j - i];
+ const lengthOfColorCodes = entries[j].length - dataLen[j];
+ const padding = maxLineLength[j - i] + lengthOfColorCodes;
str += `${entries[j]}, `[order](padding, " ");
}
if (order === "padStart") {
+ const lengthOfColorCodes = entries[j].length - dataLen[j];
const padding = maxLineLength[j - i] +
- entries[j].length -
- dataLen[j] -
+ lengthOfColorCodes -
separatorSpace;
str += entries[j].padStart(padding, " ");
} else {
diff --git a/cli/tests/seed_random.js.out b/cli/tests/seed_random.js.out
index f51b858ff..2b5551c83 100644
--- a/cli/tests/seed_random.js.out
+++ b/cli/tests/seed_random.js.out
@@ -9,15 +9,15 @@
0.5950178237266042
0.22440633214343908
Uint8Array(32) [
- 116, 125, 169, 69, 106, 231, 99,
- 39, 148, 188, 211, 41, 46, 211,
- 236, 141, 55, 10, 214, 63, 118,
+ 116, 125, 169, 69, 106, 231, 99,
+ 39, 148, 188, 211, 41, 46, 211,
+ 236, 141, 55, 10, 214, 63, 118,
230, 218, 249, 125, 161, 137, 110,
- 214, 36, 159, 154
+ 214, 36, 159, 154
]
Uint8Array(32) [
- 248, 21, 21, 9, 41, 0, 71, 124,
- 244, 209, 252, 151, 7, 10, 168, 250,
- 84, 170, 243, 140, 53, 47, 99, 212,
- 18, 146, 68, 48, 66, 222, 67, 112
+ 248, 21, 21, 9, 41, 0, 71, 124,
+ 244, 209, 252, 151, 7, 10, 168, 250,
+ 84, 170, 243, 140, 53, 47, 99, 212,
+ 18, 146, 68, 48, 66, 222, 67, 112
]
diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts
index e20a91555..c36db8f4e 100644
--- a/cli/tests/unit/console_test.ts
+++ b/cli/tests/unit/console_test.ts
@@ -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> {
const pendingPromise = new Promise((_res, _rej) => {});
assertEquals(stringify(pendingPromise), "Promise { <pending> }");