diff options
author | 2022-12-28 11:21:21 +0200 | |
---|---|---|
committer | 2022-12-28 01:21:21 -0800 | |
commit | 092b86321c3210b5435deef1d283648eb8ea5a90 (patch) | |
tree | afe3e9f5642a6942ee7dd3895c22b12d246481cb /test/bun.js | |
parent | da07811427cc10754414c0f1064c4158b8941fa2 (diff) | |
download | bun-092b86321c3210b5435deef1d283648eb8ea5a90.tar.gz bun-092b86321c3210b5435deef1d283648eb8ea5a90.tar.zst bun-092b86321c3210b5435deef1d283648eb8ea5a90.zip |
log object string correctly (#1674)
use `Symbol.toStringTag` of the object or that of its `.prototype`
fixes #1584
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/console/console-iterator-run.js (renamed from test/bun.js/console-iterator-run.js) | 0 | ||||
-rw-r--r-- | test/bun.js/console/console-iterator.test.js (renamed from test/bun.js/console-iterator.test.js) | 0 | ||||
-rw-r--r-- | test/bun.js/console/console-log.expected.txt | 46 | ||||
-rw-r--r-- | test/bun.js/console/console-log.js (renamed from test/bun.js/console-log.js) | 8 | ||||
-rw-r--r-- | test/bun.js/console/console-log.test.ts | 18 |
5 files changed, 70 insertions, 2 deletions
diff --git a/test/bun.js/console-iterator-run.js b/test/bun.js/console/console-iterator-run.js index 7664c85a1..7664c85a1 100644 --- a/test/bun.js/console-iterator-run.js +++ b/test/bun.js/console/console-iterator-run.js diff --git a/test/bun.js/console-iterator.test.js b/test/bun.js/console/console-iterator.test.js index 533f084e1..533f084e1 100644 --- a/test/bun.js/console-iterator.test.js +++ b/test/bun.js/console/console-iterator.test.js diff --git a/test/bun.js/console/console-log.expected.txt b/test/bun.js/console/console-log.expected.txt new file mode 100644 index 000000000..69fb3eeba --- /dev/null +++ b/test/bun.js/console/console-log.expected.txt @@ -0,0 +1,46 @@ +Hello World! +123 +-123 +123.567 +-123.567 +true +false +null +undefined +Symbol(Symbol Description) +2022-02-27T05:11:48.999Z +[ 123, 456, 789 ] +{ + name: "foo" +} +{ + a: 123, + b: 456, + c: 789 +} +{ + a: { + b: { + c: 123 + }, + bacon: true + }, + name: "bar" +} +Promise { <pending> } +[Function] +[Function: Foo] +{} +[Function: foooo] +/FooRegex/ +Is it a bug or a feature that formatting numbers like 123 is colored +String 123 should be 2nd word, 456 == 456 and percent s %s == What okay +{ + foo: { + name: "baz" + }, + bar: [Circular] +} am +[ + {}, {}, {}, {} +] diff --git a/test/bun.js/console-log.js b/test/bun.js/console/console-log.js index 6252d6773..c22303371 100644 --- a/test/bun.js/console-log.js +++ b/test/bun.js/console/console-log.js @@ -10,6 +10,7 @@ console.log(undefined); console.log(Symbol("Symbol Description")); console.log(new Date(2021, 12, 30, 666, 777, 888, 999)); console.log([123, 456, 789]); +console.log({ name: "foo" }); console.log({ a: 123, b: 456, c: 789 }); console.log({ a: { @@ -18,6 +19,7 @@ console.log({ }, bacon: true, }, + name: "bar", }); console.log(new Promise(() => {})); @@ -38,7 +40,7 @@ console.log( "Is it a bug or a feature that formatting numbers like %d is colored", 123, ); -console.log(globalThis); +//console.log(globalThis); console.log( "String %s should be 2nd word, 456 == %s and percent s %s == %s", @@ -50,7 +52,9 @@ console.log( ); const infinteLoop = { - foo: {}, + foo: { + name: "baz", + }, bar: {}, }; diff --git a/test/bun.js/console/console-log.test.ts b/test/bun.js/console/console-log.test.ts new file mode 100644 index 000000000..1365e174d --- /dev/null +++ b/test/bun.js/console/console-log.test.ts @@ -0,0 +1,18 @@ +import { file, spawn } from "bun"; +import { expect, it } from "bun:test"; +import { bunExe } from "bunExe"; + +it("should log to console correctly", async () => { + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), import.meta.dir + "/console-log.js"], + stdin: null, + stdout: "pipe", + stderr: "pipe", + env: { + BUN_DEBUG_QUIET_LOGS: "1", + }, + }); + expect(await exited).toBe(0); + expect(await new Response(stderr).text()).toBe("uh oh\n"); + expect(await new Response(stdout).text()).toBe(await new Response(file(import.meta.dir + "/console-log.expected.txt")).text()); +}); |