diff options
author | 2023-09-28 03:51:49 -0300 | |
---|---|---|
committer | 2023-09-27 23:51:49 -0700 | |
commit | e60b3607c12c91959ec795228cc299703d5b09d0 (patch) | |
tree | 2b4e8115501077adef7dc5d35a3627cc588ae63a /test/js/node/util/node-inspect-tests/internal-inspect.test.js | |
parent | 31d96a1b7f8a72a1976bee92e6c3f08faade8c31 (diff) | |
download | bun-e60b3607c12c91959ec795228cc299703d5b09d0.tar.gz bun-e60b3607c12c91959ec795228cc299703d5b09d0.tar.zst bun-e60b3607c12c91959ec795228cc299703d5b09d0.zip |
Complete rework of the majority of `node:util`, primarily `util.inspect` (#4493)
* 1st revision of new util.inspect impl. (not done)
* fix util.types.isArrayBuffer
* fix some utl tests and bugs
* fix node:tty missing primordials
* fix utl stackoverflow handling & some tests
* narrow down diff. context test
* util.inspect indirect circulars optimization
* temp workaround for buggy is...Function checks
* impl. Map/Set/Iterator entries inspection
* fix bigint & symbol objects inspection
* error inspection fixes
* misc util tests stuff
* inline getExternalValue stub
* leftovers
* util.inspect promise internals
* run bun fmt
* commit make js changes
* cut out unnecessary utl files
* reorganize utl folder structure
* remove browserify buffer check
* Try to revert git messing up uws somehow
This reverts commit 2c27e16e7d361657b9c3a7dc7892117cf31e15ee.
* commit src/js/out files again
* redo this edit too
* refresh js/out files
* Removed uws submodule
* tidy up
* unused primordials
* run fmt
---------
Co-authored-by: dave caruso <me@paperdave.net>
Diffstat (limited to 'test/js/node/util/node-inspect-tests/internal-inspect.test.js')
-rw-r--r-- | test/js/node/util/node-inspect-tests/internal-inspect.test.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/js/node/util/node-inspect-tests/internal-inspect.test.js b/test/js/node/util/node-inspect-tests/internal-inspect.test.js new file mode 100644 index 000000000..6e7a76e0d --- /dev/null +++ b/test/js/node/util/node-inspect-tests/internal-inspect.test.js @@ -0,0 +1,57 @@ +import assert from "assert"; +import util from "util"; + +test("no assertion failures", () => { + // Errors in accessors are not triggered + const obj = new Proxy( + { x: 5 }, + { + get() { + throw new Error("Error message"); + }, + }, + ); + assert.strictEqual(util.format(obj), "{ x: 5 }"); + + assert.strictEqual(util.formatWithOptions({ numericSeparator: true }, "%d", 4000), "4_000"); + + const a = {}; + a.b = a; + assert.strictEqual(util.inspect(a, { compact: false }), "<ref *1> {\n b: [Circular *1]\n}"); + assert.strictEqual(util.inspect(a, { compact: true }), "<ref *1> { b: [Circular *1] }"); + + const cause = new Error("cause"); + const e2 = new Error("wrapper", { cause }); + assert.match(util.inspect(e2), /\[cause\]: Error: cause\n/); +}); + +//! non-standard property, should this be kept? +test.skip("util.stylizeWithHTML", () => { + assert.strictEqual( + util.inspect( + { + a: 1, + b: "<p>\xA0\u{1F4A9}</p>", + "<": NaN, + [Symbol("<br>")]: false, + buf: new Uint8Array([1, 2, 3, 4]), + }, + { + compact: false, + stylize: util.stylizeWithHTML, + }, + ), + "{\n" + + ' a: <span style="color:yellow;">1</span>,\n' + + ' b: <span style="color:green;">'<p> \u{1F4A9}</p>'</span>,\n' + + ' <span style="color:green;">'&lt;'</span>: <span style="color:yellow;">NaN</span>,\n' + + " buf: Uint8Array(4) [\n" + + ' <span style="color:yellow;">1</span>,\n' + + ' <span style="color:yellow;">2</span>,\n' + + ' <span style="color:yellow;">3</span>,\n' + + ' <span style="color:yellow;">4</span>\n' + + " ],\n" + + ' [<span style="color:green;">Symbol(<br>)</span>]: <span style="color:yellow;">false</span>\n' + + "}", + ); +}); |