diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-09-18 21:28:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-18 09:28:30 -0400 |
commit | 38196f7850d7498e98f5ec7c66801deadabe09cf (patch) | |
tree | 268759120f366d4ce0ef38b441c81e51fd6037dc /std/testing | |
parent | 7845740637eb646c0b13dc541f043fd65136fc03 (diff) |
fix(cli/console): always quote and escape inspected strings (#7546)
Diffstat (limited to 'std/testing')
-rw-r--r-- | std/testing/asserts.ts | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index a3f0c1338..9796c9d31 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -20,7 +20,7 @@ export class AssertionError extends Error { } export function _format(v: unknown): string { - let string = globalThis.Deno + return globalThis.Deno ? stripColor(Deno.inspect(v, { depth: Infinity, sorted: true, @@ -28,11 +28,7 @@ export function _format(v: unknown): string { compact: false, iterableLimit: Infinity, })) - : String(v); - if (typeof v == "string") { - string = `"${string.replace(/(?=["\\])/g, "\\")}"`; - } - return string; + : `"${String(v).replace(/(?=["\\])/g, "\\")}"`; } function createColor(diffType: DiffType): (s: string) => string { |