Browse Source

Rename "Dynamic Property" to "Getter/Setter" in sys.inspect.

v0.7.4-release
Tim Caswell 15 years ago
committed by Ryan Dahl
parent
commit
fd184ee2fa
  1. 6
      lib/sys.js
  2. 6
      test/mjsunit/test-sys.js

6
lib/sys.js

@ -101,13 +101,13 @@ var formatter = function(value, indent, parents) {
var child; var child;
if (value.__lookupGetter__(x)) { if (value.__lookupGetter__(x)) {
if (value.__lookupSetter__(x)) { if (value.__lookupSetter__(x)) {
child = "[Dynamic Property]"; child = "[Getter/Setter]";
} else { } else {
child = "[Dynamic Property Read-only]"; child = "[Getter]";
} }
} else { } else {
if (value.__lookupSetter__(x)) { if (value.__lookupSetter__(x)) {
child = "[Dynamic Property Write-only]"; child = "[Setter]";
} else { } else {
child = f(value[x]); child = f(value[x]);
} }

6
test/mjsunit/test-sys.js

@ -26,8 +26,8 @@ assert.equal('{\n "a": {\n "b": 2\n }\n}', inspect({'a': {'b': 2}}));
// Dynamic properties // Dynamic properties
assert.equal( assert.equal(
"{\n \"readonly\": [Dynamic Property Read-only],\n \"readwrite\": [Dynamic Property],\n \"writeonly\": [Dynamic Property Write-only]\n}", "{\n \"readonly\": [Getter],\n \"readwrite\": [Getter/Setter],\n \"writeonly\": [Setter]\n}",
inspect({get readonly() {return 1;},get readwrite(){return 2;},set readwrite(value){},set writeonly(val){}}) inspect({get readonly(){},get readwrite(){},set readwrite(val){},set writeonly(val){}})
); );
var value = {}; var value = {};
@ -41,6 +41,6 @@ assert.equal('{\n "0": 1,\n "length": 1\n}', inspect(value));
value = [1,2,3]; value = [1,2,3];
value.__defineGetter__('growingLength', function () { this.push(true); return this.length; }); value.__defineGetter__('growingLength', function () { this.push(true); return this.length; });
assert.equal( assert.equal(
"{\n \"0\": 1,\n \"1\": 2,\n \"2\": 3,\n \"growingLength\": [Dynamic Property Read-only]\n}", "{\n \"0\": 1,\n \"1\": 2,\n \"2\": 3,\n \"growingLength\": [Getter]\n}",
inspect(value) inspect(value)
); );
Loading…
Cancel
Save