11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// This test ensures that util.inspect logs getters 61cb0ef41Sopenharmony_ci// which access this. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst assert = require('assert'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst { inspect } = require('util'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci{ 131cb0ef41Sopenharmony_ci class X { 141cb0ef41Sopenharmony_ci constructor() { 151cb0ef41Sopenharmony_ci this._y = 123; 161cb0ef41Sopenharmony_ci } 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci get y() { 191cb0ef41Sopenharmony_ci return this._y; 201cb0ef41Sopenharmony_ci } 211cb0ef41Sopenharmony_ci } 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci const result = inspect(new X(), { 241cb0ef41Sopenharmony_ci getters: true, 251cb0ef41Sopenharmony_ci showHidden: true 261cb0ef41Sopenharmony_ci }); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci assert.strictEqual( 291cb0ef41Sopenharmony_ci result, 301cb0ef41Sopenharmony_ci 'X { _y: 123, [y]: [Getter: 123] }' 311cb0ef41Sopenharmony_ci ); 321cb0ef41Sopenharmony_ci} 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node/issues/37054 351cb0ef41Sopenharmony_ci{ 361cb0ef41Sopenharmony_ci class A { 371cb0ef41Sopenharmony_ci constructor(B) { 381cb0ef41Sopenharmony_ci this.B = B; 391cb0ef41Sopenharmony_ci } 401cb0ef41Sopenharmony_ci get b() { 411cb0ef41Sopenharmony_ci return this.B; 421cb0ef41Sopenharmony_ci } 431cb0ef41Sopenharmony_ci } 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci class B { 461cb0ef41Sopenharmony_ci constructor() { 471cb0ef41Sopenharmony_ci this.A = new A(this); 481cb0ef41Sopenharmony_ci } 491cb0ef41Sopenharmony_ci get a() { 501cb0ef41Sopenharmony_ci return this.A; 511cb0ef41Sopenharmony_ci } 521cb0ef41Sopenharmony_ci } 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci const result = inspect(new B(), { 551cb0ef41Sopenharmony_ci depth: 1, 561cb0ef41Sopenharmony_ci getters: true, 571cb0ef41Sopenharmony_ci showHidden: true 581cb0ef41Sopenharmony_ci }); 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci assert.strictEqual( 611cb0ef41Sopenharmony_ci result, 621cb0ef41Sopenharmony_ci '<ref *1> B {\n' + 631cb0ef41Sopenharmony_ci ' A: A { B: [Circular *1], [b]: [Getter] [Circular *1] },\n' + 641cb0ef41Sopenharmony_ci ' [a]: [Getter] A { B: [Circular *1], [b]: [Getter] [Circular *1] }\n' + 651cb0ef41Sopenharmony_ci '}', 661cb0ef41Sopenharmony_ci ); 671cb0ef41Sopenharmony_ci} 68