diff options
author | Ben Heidemann <56122437+bcheidemann@users.noreply.github.com> | 2022-04-26 12:04:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 13:04:28 +0200 |
commit | dc4ab1d9340a58f81beab24ef211e900acbb9ad8 (patch) | |
tree | ee341f04c26976129c113096a71ca49290b9a694 /cli/tests/unit/console_test.ts | |
parent | e24b8f075ead5ceab192eed67caaa9f3ba0fbfa4 (diff) |
feat(ext/console): Compact empty iterables when calling Deno.inspect with compact false (#14387)
Diffstat (limited to 'cli/tests/unit/console_test.ts')
-rw-r--r-- | cli/tests/unit/console_test.ts | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 39baaf1a3..4601281ff 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -1939,6 +1939,71 @@ Deno.test(function inspectColors() { assertStringIncludes(Deno.inspect(1, { colors: true }), "\x1b["); }); +Deno.test(function inspectEmptyArray() { + const arr: string[] = []; + + assertEquals( + Deno.inspect(arr, { + compact: false, + trailingComma: true, + }), + "[\n]", + ); +}); + +Deno.test(function inspectDeepEmptyArray() { + const obj = { + arr: [], + }; + + assertEquals( + Deno.inspect(obj, { + compact: false, + trailingComma: true, + }), + `{ + arr: [ + ], +}`, + ); +}); + +Deno.test(function inspectEmptyMap() { + const map = new Map(); + + assertEquals( + Deno.inspect(map, { + compact: false, + trailingComma: true, + }), + "Map {\n}", + ); +}); + +Deno.test(function inspectEmptyMap() { + const set = new Set(); + + assertEquals( + Deno.inspect(set, { + compact: false, + trailingComma: true, + }), + "Set {\n}", + ); +}); + +Deno.test(function inspectEmptyMap() { + const typedArray = new Uint8Array(0); + + assertEquals( + Deno.inspect(typedArray, { + compact: false, + trailingComma: true, + }), + "Uint8Array(0) [\n]", + ); +}); + Deno.test(function inspectStringAbbreviation() { const LONG_STRING = "This is a really long string which will be abbreviated with ellipsis."; |