Skip to content

Commit

Permalink
Use propertyHelper, add more tests, fix getter calls
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Jun 7, 2018
1 parent cc53f64 commit 28a66ce
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
14 changes: 10 additions & 4 deletions test/built-ins/Symbol/prototype/description/descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ description: >
info: |
`Symbol.prototype.description` is an accessor property whose
set accessor function is undefined.
includes: [propertyHelper.js]
features: [Symbol.prototype.description]
---*/

const desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description');
assert.sameValue(typeof desc.get, 'function');

var desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description');

assert.sameValue(desc.set, undefined);
assert.sameValue(desc.writable, undefined);
assert.sameValue(desc.enumerable, false);
assert.sameValue(desc.configurable, true);
assert.sameValue(typeof desc.get, 'function');

verifyProperty(Symbol.prototype, 'description', {
enumerable: false,
configurable: true,
});
8 changes: 8 additions & 0 deletions test/built-ins/Symbol/prototype/description/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ assert.sameValue(symbol.hasOwnProperty('description'), false);
const empty = Symbol();
assert.sameValue(empty.description, undefined);
assert.sameValue(empty.hasOwnProperty('description'), false);

const undef = Symbol(undefined);
assert.sameValue(undef.description, undefined);
assert.sameValue(undef.hasOwnProperty('description'), false);

const emptyStr = Symbol('');
assert.sameValue(emptyStr.description, '');
assert.sameValue(emptyStr.hasOwnProperty('description'), false);
18 changes: 11 additions & 7 deletions test/built-ins/Symbol/prototype/description/this-val-non-symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,34 @@ info: |
features: [Symbol.prototype.description]
---*/

const getter = Object.getOwnPropertyDescriptor(
Symbol.prototype, 'description'
).get;

assert.throws(TypeError, function() {
Symbol.prototype.description.call(null);
getter.call(null);
});

assert.throws(TypeError, function() {
Symbol.prototype.description.call(123);
getter.call(123);
});

assert.throws(TypeError, function() {
Symbol.prototype.description.call('test');
getter.call('test');
});

assert.throws(TypeError, function() {
Symbol.prototype.description.call(true);
getter.call(true);
});

assert.throws(TypeError, function() {
Symbol.prototype.description.call(undefined);
getter.call(undefined);
});

assert.throws(TypeError, function() {
Symbol.prototype.description.call(new Proxy({}, {}));
getter.call(new Proxy({}, {}));
});

assert.throws(TypeError, function() {
Symbol.prototype.description.call({});
getter.call({});
});
8 changes: 8 additions & 0 deletions test/built-ins/Symbol/prototype/description/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ assert.sameValue(symbol.hasOwnProperty('description'), false);
const empty = Object(Symbol());
assert.sameValue(empty.description, undefined);
assert.sameValue(empty.hasOwnProperty('description'), false);

const undef = Object(Symbol(undefined));
assert.sameValue(undef.description, undefined);
assert.sameValue(undef.hasOwnProperty('description'), false);

const emptyStr = Object(Symbol(''));
assert.sameValue(emptyStr.description, '');
assert.sameValue(emptyStr.hasOwnProperty('description'), false);

0 comments on commit 28a66ce

Please sign in to comment.