Files
bun.sh/test/js/node/util/node-inspect-tests/parallel/util-inspect-getters-accessing-this.test.js
jhmaster e60b3607c1 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 2c27e16e7d.

* 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>
2023-09-27 23:51:49 -07:00

61 lines
1.1 KiB
JavaScript

// This test ensures that util.inspect logs getters which access this.
import assert from "assert";
import { inspect } from "util";
test("no assertion failures", () => {
{
class X {
constructor() {
this._y = 123;
}
get y() {
return this._y;
}
}
const result = inspect(new X(), {
getters: true,
showHidden: true,
});
assert.strictEqual(result, "X { _y: 123, [y]: [Getter: 123] }");
}
// Regression test for https://github.com/nodejs/node/issues/37054
{
class A {
constructor(B) {
this.B = B;
}
get b() {
return this.B;
}
}
class B {
constructor() {
this.A = new A(this);
}
get a() {
return this.A;
}
}
const result = inspect(new B(), {
depth: 1,
getters: true,
showHidden: true,
});
assert.strictEqual(
result,
"<ref *1> B {\n" +
" A: A { B: [Circular *1], [b]: [Getter] [Circular *1] },\n" +
" [a]: [Getter] A { B: [Circular *1], [b]: [Getter] [Circular *1] }\n" +
"}",
);
}
});