Skip to content
Snippets Groups Projects
Unverified Commit 28a66ceb authored by Joyee Cheung's avatar Joyee Cheung
Browse files

Use propertyHelper, add more tests, fix getter calls

parent cc53f643
No related branches found
No related tags found
No related merge requests found
......@@ -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,
});
......@@ -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);
......@@ -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({});
});
......@@ -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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment