mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 13:04:39 +02:00
Symbol.prototype.description: Assertion messages and additional tests
This commit is contained in:
parent
5d58479827
commit
cd4371b5a7
32
test/built-ins/Symbol/prototype/description/description-symboldescriptivestring.js
vendored
Normal file
32
test/built-ins/Symbol/prototype/description/description-symboldescriptivestring.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||||
|
// Copyright (C) 2018 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-symbol.prototype.description
|
||||||
|
description: >
|
||||||
|
SymbolDescriptiveString(sym) via Symbol.prototype.toString()
|
||||||
|
info: |
|
||||||
|
SymbolDescriptiveString ( sym )
|
||||||
|
|
||||||
|
Assert: Type(sym) is Symbol.
|
||||||
|
Let desc be sym's [[Description]] value.
|
||||||
|
If desc is undefined, let desc be the empty string.
|
||||||
|
Assert: Type(desc) is String.
|
||||||
|
Return the string-concatenation of "Symbol(", desc, and ")".
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.prototype.description]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const symbol = Symbol('foo');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
symbol.description,
|
||||||
|
'foo',
|
||||||
|
'The value of symbol.description is "foo"'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
symbol.toString(),
|
||||||
|
`Symbol(${symbol.description})`,
|
||||||
|
`symbol.toString() returns "Symbol(${symbol.description})"`
|
||||||
|
);
|
@ -15,9 +15,23 @@ features: [Symbol.prototype.description]
|
|||||||
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description');
|
var desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description');
|
||||||
|
|
||||||
assert.sameValue(desc.set, undefined);
|
assert.sameValue(
|
||||||
assert.sameValue(desc.writable, undefined);
|
desc.set,
|
||||||
assert.sameValue(typeof desc.get, 'function');
|
undefined,
|
||||||
|
'The value of desc.set is `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
desc.writable,
|
||||||
|
undefined,
|
||||||
|
'The value of desc.writable is `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof desc.get,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof desc.get` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
verifyProperty(Symbol.prototype, 'description', {
|
verifyProperty(Symbol.prototype, 'description', {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
|
@ -13,17 +13,29 @@ features: [Symbol.prototype.description]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
const symbol = Symbol('test');
|
const symbol = Symbol('test');
|
||||||
assert.sameValue(symbol.description, 'test');
|
assert.sameValue(
|
||||||
assert.sameValue(symbol.hasOwnProperty('description'), false);
|
symbol.description,
|
||||||
|
'test',
|
||||||
|
'The value of symbol.description is "test"'
|
||||||
|
);
|
||||||
|
|
||||||
const empty = Symbol();
|
const empty = Symbol();
|
||||||
assert.sameValue(empty.description, undefined);
|
assert.sameValue(
|
||||||
assert.sameValue(empty.hasOwnProperty('description'), false);
|
empty.description,
|
||||||
|
undefined,
|
||||||
|
'The value of empty.description is `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
const undef = Symbol(undefined);
|
const undef = Symbol(undefined);
|
||||||
assert.sameValue(undef.description, undefined);
|
assert.sameValue(
|
||||||
assert.sameValue(undef.hasOwnProperty('description'), false);
|
undef.description,
|
||||||
|
undefined,
|
||||||
|
'The value of undef.description is `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
const emptyStr = Symbol('');
|
const emptyStr = Symbol('');
|
||||||
assert.sameValue(emptyStr.description, '');
|
assert.sameValue(
|
||||||
assert.sameValue(emptyStr.hasOwnProperty('description'), false);
|
emptyStr.description,
|
||||||
|
'',
|
||||||
|
'The value of emptyStr.description is ""'
|
||||||
|
);
|
||||||
|
14
test/built-ins/Symbol/prototype/description/is-not-own-property.js
vendored
Normal file
14
test/built-ins/Symbol/prototype/description/is-not-own-property.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-symbol.prototype.description
|
||||||
|
description: Ensure that 'description' is not an own property of Symbols
|
||||||
|
features: [Symbol.prototype.description]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Symbol().hasOwnProperty('description'),
|
||||||
|
false,
|
||||||
|
'Symbol().hasOwnProperty("description") returns false'
|
||||||
|
);
|
@ -4,7 +4,7 @@
|
|||||||
/*---
|
/*---
|
||||||
esid: sec-symbol.prototype.description
|
esid: sec-symbol.prototype.description
|
||||||
description: >
|
description: >
|
||||||
Behavior when `this` value is an object without a [[SymbolData]] internal
|
Behavior when "this" value is an object without a [[SymbolData]] internal
|
||||||
slot.
|
slot.
|
||||||
info: |
|
info: |
|
||||||
1. Let s be the this value.
|
1. Let s be the this value.
|
||||||
@ -19,28 +19,28 @@ const getter = Object.getOwnPropertyDescriptor(
|
|||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
getter.call(null);
|
getter.call(null);
|
||||||
});
|
}, 'getter.call(null) throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
getter.call(123);
|
getter.call(123);
|
||||||
});
|
}, 'getter.call(123) throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
getter.call('test');
|
getter.call('test');
|
||||||
});
|
}, 'getter.call("test") throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
getter.call(true);
|
getter.call(true);
|
||||||
});
|
}, 'getter.call(true) throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
getter.call(undefined);
|
getter.call(undefined);
|
||||||
});
|
}, 'getter.call(undefined) throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
getter.call(new Proxy({}, {}));
|
getter.call(new Proxy({}, {}));
|
||||||
});
|
}, 'getter.call(new Proxy({}, {})) throws TypeError');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
getter.call({});
|
getter.call({});
|
||||||
});
|
}, 'getter.call({}) throws TypeError');
|
||||||
|
@ -17,17 +17,49 @@ const getter = Object.getOwnPropertyDescriptor(
|
|||||||
).get;
|
).get;
|
||||||
|
|
||||||
const symbol = Symbol('test');
|
const symbol = Symbol('test');
|
||||||
assert.sameValue(getter.call(symbol), 'test');
|
assert.sameValue(
|
||||||
assert.sameValue(getter.call(Object(symbol)), 'test');
|
getter.call(symbol),
|
||||||
|
'test',
|
||||||
|
'getter.call(symbol) returns "test"'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
getter.call(Object(symbol)),
|
||||||
|
'test',
|
||||||
|
'getter.call(Object(symbol)) returns "test"'
|
||||||
|
);
|
||||||
|
|
||||||
const empty = Symbol();
|
const empty = Symbol();
|
||||||
assert.sameValue(getter.call(empty), undefined);
|
assert.sameValue(
|
||||||
assert.sameValue(getter.call(Object(empty)), undefined);
|
getter.call(empty),
|
||||||
|
undefined,
|
||||||
|
'getter.call(empty) returns `undefined`'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
getter.call(Object(empty)),
|
||||||
|
undefined,
|
||||||
|
'getter.call(Object(empty)) returns `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
const undef = Symbol(undefined);
|
const undef = Symbol(undefined);
|
||||||
assert.sameValue(getter.call(undef), undefined);
|
assert.sameValue(
|
||||||
assert.sameValue(getter.call(Object(undef)), undefined);
|
getter.call(undef),
|
||||||
|
undefined,
|
||||||
|
'getter.call(undef) returns `undefined`'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
getter.call(Object(undef)),
|
||||||
|
undefined,
|
||||||
|
'getter.call(Object(undef)) returns `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
const emptyStr = Symbol('');
|
const emptyStr = Symbol('');
|
||||||
assert.sameValue(getter.call(emptyStr), '');
|
assert.sameValue(
|
||||||
assert.sameValue(getter.call(Object(emptyStr)), '');
|
getter.call(emptyStr),
|
||||||
|
'',
|
||||||
|
'getter.call(emptyStr) returns ""'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
getter.call(Object(emptyStr)),
|
||||||
|
'',
|
||||||
|
'getter.call(Object(emptyStr)) returns ""'
|
||||||
|
);
|
||||||
|
@ -13,17 +13,29 @@ features: [Symbol.prototype.description]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
const symbol = Object(Symbol('test'));
|
const symbol = Object(Symbol('test'));
|
||||||
assert.sameValue(symbol.description, 'test');
|
assert.sameValue(
|
||||||
assert.sameValue(symbol.hasOwnProperty('description'), false);
|
symbol.description,
|
||||||
|
'test',
|
||||||
|
'The value of symbol.description is "test"'
|
||||||
|
);
|
||||||
|
|
||||||
const empty = Object(Symbol());
|
const empty = Object(Symbol());
|
||||||
assert.sameValue(empty.description, undefined);
|
assert.sameValue(
|
||||||
assert.sameValue(empty.hasOwnProperty('description'), false);
|
empty.description,
|
||||||
|
undefined,
|
||||||
|
'The value of empty.description is `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
const undef = Object(Symbol(undefined));
|
const undef = Object(Symbol(undefined));
|
||||||
assert.sameValue(undef.description, undefined);
|
assert.sameValue(
|
||||||
assert.sameValue(undef.hasOwnProperty('description'), false);
|
undef.description,
|
||||||
|
undefined,
|
||||||
|
'The value of undef.description is `undefined`'
|
||||||
|
);
|
||||||
|
|
||||||
const emptyStr = Object(Symbol(''));
|
const emptyStr = Object(Symbol(''));
|
||||||
assert.sameValue(emptyStr.description, '');
|
assert.sameValue(
|
||||||
assert.sameValue(emptyStr.hasOwnProperty('description'), false);
|
emptyStr.description,
|
||||||
|
'',
|
||||||
|
'The value of emptyStr.description is ""'
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user