mirror of https://github.com/tc39/test262.git
Import tests from Google V8 (Symbol)
These tests are derived from the following files within the Google V8 project: test/mjsunit/harmony/private.js
This commit is contained in:
parent
2df6c4f219
commit
59e2a7ac57
|
@ -7,7 +7,7 @@ info: >
|
|||
es6id: 22.1.2.5
|
||||
author: Sam Mikes
|
||||
description: Array[Symbol.species] exists per spec
|
||||
includes:
|
||||
includes:
|
||||
- propertyHelper.js
|
||||
---*/
|
||||
|
|
@ -8,7 +8,7 @@ es6id: 24.1.3.3
|
|||
author: Sam Mikes
|
||||
description: ArrayBuffer[Symbol.species] exists per spec
|
||||
features: [ ArrayBuffer, Symbol.species ]
|
||||
includes:
|
||||
includes:
|
||||
- propertyHelper.js
|
||||
---*/
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 7.1.2
|
||||
description: >
|
||||
Boolean coercion operations on Symbols
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
|
||||
assert.sameValue(Boolean(sym).valueOf(), true, "`Boolean(sym).valueOf()` returns `true`");
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Symbol as Map key
|
||||
features: [Map]
|
||||
---*/
|
||||
var map = new Map();
|
||||
var sym = Symbol();
|
||||
|
||||
map.set(sym, 1);
|
||||
|
||||
assert.sameValue(map.size, 1, "The value of `map.size` is `1`, after executing `map.set(sym, 1)`");
|
||||
assert.sameValue(map.has(sym), true, "`map.has(sym)` returns `true`");
|
||||
assert.sameValue(map.get(sym), 1, "`map.get(sym)` returns `1`");
|
||||
assert.sameValue(map.delete(sym), true, "`map.delete(sym)` returns `true`");
|
||||
assert.sameValue(map.size, 0, "The value of `map.size` is `0`");
|
||||
|
|
@ -7,7 +7,7 @@ info: >
|
|||
es6id: 23.1.2.2
|
||||
author: Sam Mikes
|
||||
description: Map[Symbol.species] exists per spec
|
||||
includes:
|
||||
includes:
|
||||
- propertyHelper.js
|
||||
---*/
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 7.1.3
|
||||
description: >
|
||||
Number coercion operations on Symbols
|
||||
---*/
|
||||
assert.throws(TypeError, function() {
|
||||
Number(Symbol('66'));
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol('66') + 0;
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
+Symbol('66');
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol('66') >> 0;
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol('66') >>> 0;
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol('66') | 0;
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
new Uint16Array([Symbol('66')]);
|
||||
});
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.4
|
||||
description: >
|
||||
Symbol used as property for configurable data property definition
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
var obj = {};
|
||||
|
||||
|
||||
Object.defineProperty(obj, sym, {
|
||||
value: 1,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`");
|
||||
assert.sameValue(
|
||||
Object.hasOwnProperty.call(obj, sym),
|
||||
true,
|
||||
"`Object.hasOwnProperty.call(obj, sym)` returns `true`"
|
||||
);
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, sym);
|
||||
|
||||
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`");
|
||||
assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`");
|
||||
assert.sameValue(desc.writable, false, "The value of `desc.writable` is `false`");
|
||||
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`");
|
||||
assert.sameValue(
|
||||
Object.prototype.propertyIsEnumerable.call(obj, sym),
|
||||
false,
|
||||
"`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`"
|
||||
);
|
||||
|
||||
assert.sameValue(delete obj[sym], true, "The result of `delete obj[sym]` is `true`");
|
||||
|
||||
assert.sameValue(
|
||||
Object.getOwnPropertyDescriptor(obj, sym),
|
||||
undefined,
|
||||
"`Object.getOwnPropertyDescriptor(obj, sym)` returns `undefined`"
|
||||
);
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.4
|
||||
description: >
|
||||
Symbol used as property for configurable data property definition
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
var obj = {};
|
||||
|
||||
|
||||
Object.defineProperty(obj, sym, {
|
||||
value: 1,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`");
|
||||
assert.sameValue(
|
||||
Object.hasOwnProperty.call(obj, sym),
|
||||
true,
|
||||
"`Object.hasOwnProperty.call(obj, sym)` returns `true`"
|
||||
);
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, sym);
|
||||
|
||||
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`");
|
||||
assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`");
|
||||
assert.sameValue(desc.writable, false, "The value of `desc.writable` is `false`");
|
||||
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`");
|
||||
assert.sameValue(
|
||||
Object.prototype.propertyIsEnumerable.call(obj, sym),
|
||||
false,
|
||||
"`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`"
|
||||
);
|
||||
|
||||
assert.sameValue(delete obj[sym], true, "The result of `delete obj[sym]` is `true`");
|
||||
|
||||
assert.sameValue(
|
||||
Object.getOwnPropertyDescriptor(obj, sym),
|
||||
undefined,
|
||||
"`Object.getOwnPropertyDescriptor(obj, sym)` returns `undefined`"
|
||||
);
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.4
|
||||
description: >
|
||||
Symbol used as property for property definition
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
var obj = {};
|
||||
|
||||
|
||||
Object.defineProperty(obj, sym, {
|
||||
value: 1,
|
||||
});
|
||||
|
||||
assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`");
|
||||
assert.sameValue(
|
||||
Object.hasOwnProperty.call(obj, sym),
|
||||
true,
|
||||
"`Object.hasOwnProperty.call(obj, sym)` returns `true`"
|
||||
);
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, sym);
|
||||
|
||||
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`");
|
||||
assert.sameValue(desc.configurable, false, "The value of `desc.configurable` is `false`");
|
||||
assert.sameValue(desc.writable, false, "The value of `desc.writable` is `false`");
|
||||
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`");
|
||||
assert.sameValue(
|
||||
Object.prototype.propertyIsEnumerable.call(obj, sym),
|
||||
false,
|
||||
"`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`"
|
||||
);
|
||||
|
||||
assert.sameValue(delete obj[sym], false, "The result of `delete obj[sym]` is `false`");
|
||||
|
||||
assert.notSameValue(
|
||||
Object.getOwnPropertyDescriptor(obj, sym),
|
||||
undefined,
|
||||
"`Object.getOwnPropertyDescriptor(obj, sym)` does not return `undefined`"
|
||||
);
|
||||
|
||||
obj[sym] = 2;
|
||||
|
||||
assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`");
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.4
|
||||
description: >
|
||||
Symbol used as property for default data property definition
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
var obj = {};
|
||||
|
||||
|
||||
Object.defineProperty(obj, sym, {
|
||||
value: 1,
|
||||
});
|
||||
|
||||
assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`");
|
||||
assert.sameValue(
|
||||
Object.hasOwnProperty.call(obj, sym),
|
||||
true,
|
||||
"`Object.hasOwnProperty.call(obj, sym)` returns `true`"
|
||||
);
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, sym);
|
||||
|
||||
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`");
|
||||
assert.sameValue(desc.configurable, false, "The value of `desc.configurable` is `false`");
|
||||
assert.sameValue(desc.writable, false, "The value of `desc.writable` is `false`");
|
||||
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`");
|
||||
assert.sameValue(
|
||||
Object.prototype.propertyIsEnumerable.call(obj, sym),
|
||||
false,
|
||||
"`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`"
|
||||
);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
delete obj[sym];
|
||||
});
|
||||
|
||||
assert.notSameValue(
|
||||
Object.getOwnPropertyDescriptor(obj, sym),
|
||||
undefined,
|
||||
"`Object.getOwnPropertyDescriptor(obj, sym)` does not return `undefined`"
|
||||
);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
obj[sym] = 2;
|
||||
});
|
||||
|
||||
assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`");
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.4
|
||||
description: >
|
||||
Symbol used as property for writable data property definition
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
var obj = {};
|
||||
|
||||
|
||||
Object.defineProperty(obj, sym, {
|
||||
value: 1,
|
||||
writable: true
|
||||
});
|
||||
|
||||
assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`");
|
||||
assert.sameValue(
|
||||
Object.hasOwnProperty.call(obj, sym),
|
||||
true,
|
||||
"`Object.hasOwnProperty.call(obj, sym)` returns `true`"
|
||||
);
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, sym);
|
||||
|
||||
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`");
|
||||
assert.sameValue(desc.configurable, false, "The value of `desc.configurable` is `false`");
|
||||
assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`");
|
||||
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`");
|
||||
assert.sameValue(
|
||||
Object.prototype.propertyIsEnumerable.call(obj, sym),
|
||||
false,
|
||||
"`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`"
|
||||
);
|
||||
|
||||
obj[sym] = 2;
|
||||
|
||||
assert.sameValue(obj[sym], 2, "The value of `obj[sym]` is `2`");
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.4
|
||||
description: >
|
||||
Symbol used as property for writable data property definition
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
var obj = {};
|
||||
|
||||
|
||||
Object.defineProperty(obj, sym, {
|
||||
value: 1,
|
||||
writable: true
|
||||
});
|
||||
|
||||
assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`");
|
||||
assert.sameValue(
|
||||
Object.hasOwnProperty.call(obj, sym),
|
||||
true,
|
||||
"`Object.hasOwnProperty.call(obj, sym)` returns `true`"
|
||||
);
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, sym);
|
||||
|
||||
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`");
|
||||
assert.sameValue(desc.configurable, false, "The value of `desc.configurable` is `false`");
|
||||
assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`");
|
||||
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`");
|
||||
assert.sameValue(
|
||||
Object.prototype.propertyIsEnumerable.call(obj, sym),
|
||||
false,
|
||||
"`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`"
|
||||
);
|
||||
|
||||
obj[sym] = 2;
|
||||
|
||||
assert.sameValue(obj[sym], 2, "The value of `obj[sym]` is `2`");
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.5
|
||||
description: >
|
||||
Frozen object contains symbol properties.
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
var obj = {};
|
||||
obj[sym] = 1;
|
||||
Object.freeze(obj);
|
||||
obj[sym] = 2;
|
||||
assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`");
|
||||
assert.sameValue(delete obj[sym], false, "`delete obj[sym]` is `false`");
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.5
|
||||
description: >
|
||||
Frozen object contains symbol properties.
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
var sym = Symbol("66");
|
||||
var obj = {};
|
||||
obj[sym] = 1;
|
||||
Object.freeze(obj);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
obj[sym] = 2;
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.8
|
||||
description: >
|
||||
Object.getOwnPropertySymbols returns all symbol properties that have descriptions
|
||||
---*/
|
||||
|
||||
var sym = Symbol("description");
|
||||
|
||||
var obj = {};
|
||||
obj[sym] = 1;
|
||||
|
||||
var syms = Object.getOwnPropertySymbols(obj);
|
||||
|
||||
assert.sameValue(syms[0], sym, "Array of symbols returned by `Object.getOwnPropertySymbols(obj)` includes `sym`");
|
||||
assert.sameValue(syms.length, 1, "The value of `syms.length` is `1`");
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.2.8
|
||||
description: >
|
||||
Object.getOwnPropertySymbols returns all symbol properties that do not have descriptions
|
||||
---*/
|
||||
|
||||
var sym = Symbol();
|
||||
|
||||
var obj = {};
|
||||
obj[sym] = 1;
|
||||
|
||||
var syms = Object.getOwnPropertySymbols(obj);
|
||||
|
||||
assert.sameValue(syms[0], sym, "Array of symbols returned by `Object.getOwnPropertySymbols(obj)` includes `sym`");
|
||||
assert.sameValue(syms.length, 1, "The value of `syms.length` is `1`");
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 7.2.
|
||||
description: >
|
||||
Object.is/SameValue: Symbol
|
||||
---*/
|
||||
var symA = Symbol('66');
|
||||
var symB = Symbol('66');
|
||||
|
||||
|
||||
assert.sameValue(Object.is(symA, symA), true, "`Object.is(symA, symA)` returns `true`");
|
||||
assert.sameValue(Object.is(symB, symB), true, "`Object.is(symB, symB)` returns `true`");
|
||||
assert.sameValue(Object.is(symA, symB), false, "`Object.is(symA, symB)` returns `false`");
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Object.preventExtensions(obj) where obj contains symbol properties.
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
var symA = Symbol("A");
|
||||
var symB = Symbol("B");
|
||||
var obj = {};
|
||||
obj[symA] = 1;
|
||||
Object.preventExtensions(obj);
|
||||
obj[symA] = 2;
|
||||
obj[symB] = 1;
|
||||
|
||||
assert.sameValue(obj[symA], 2, "The value of `obj[symA]` is `2`");
|
||||
assert.sameValue(delete obj[symA], true, "`delete obj[symA]` is `true`");
|
||||
assert.sameValue(obj[symB], undefined, "The value of `obj[symB]` is `undefined`");
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Object.preventExtensions(obj) where obj contains symbol properties.
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
var symA = Symbol("A");
|
||||
var symB = Symbol("B");
|
||||
var symC = Symbol("C");
|
||||
var obj = {};
|
||||
obj[symA] = 1;
|
||||
Object.preventExtensions(obj);
|
||||
obj[symA] = 2;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
obj[symB] = 1;
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Object.defineProperty(obj, symC, { value: 1 });
|
||||
});
|
||||
|
||||
assert.sameValue(obj[symA], 2, "The value of `obj[symA]` is `2`");
|
||||
assert.sameValue(delete obj[symA], true, "`delete obj[symA]` is `true`");
|
||||
assert.sameValue(obj[symB], undefined, "The value of `obj[symB]` is `undefined`");
|
||||
assert.sameValue(obj[symC], undefined, "The value of `obj[symC]` is `undefined`");
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Object.seal(obj) where obj contains symbol properties.
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
var symA = Symbol("A");
|
||||
var symB = Symbol("B");
|
||||
var obj = {};
|
||||
obj[symA] = 1;
|
||||
Object.seal(obj);
|
||||
obj[symA] = 2;
|
||||
obj[symB] = 1;
|
||||
|
||||
assert.sameValue(obj[symA], 2, "The value of `obj[symA]` is `2`");
|
||||
assert.sameValue(delete obj[symA], false, "`delete obj[symA]` is `false`");
|
||||
assert.sameValue(obj[symB], undefined, "The value of `obj[symB]` is `undefined`");
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Object.seal(obj) where obj contains symbol properties.
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
var symA = Symbol("A");
|
||||
var symB = Symbol("B");
|
||||
var obj = {};
|
||||
obj[symA] = 1;
|
||||
Object.seal(obj);
|
||||
obj[symA] = 2;
|
||||
|
||||
assert.sameValue(obj[symA], 2, "The value of `obj[symA]` is `2`");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
delete obj[symA];
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
obj[symB] = 1;
|
||||
});
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.1.1.1_S3
|
||||
description: >
|
||||
Object(sym) returns a fresh Symbol object
|
||||
---*/
|
||||
var symA = Symbol('A');
|
||||
var symB = Symbol();
|
||||
|
||||
assert.notSameValue(Object(symA), symA, "The value of `Object(symA)` is not `symA`");
|
||||
assert.notSameValue(Object(symB), symB, "The value of `Object(symB)` is not `symB`");
|
|
@ -7,7 +7,7 @@ info: >
|
|||
es6id: 6.1.5.1
|
||||
author: Sam Mikes
|
||||
description: Promise[Symbol.species] exists per spec
|
||||
includes:
|
||||
includes:
|
||||
- propertyHelper.js
|
||||
---*/
|
||||
|
|
@ -7,7 +7,7 @@ info: >
|
|||
es6id: 21.2.4.2
|
||||
author: Sam Mikes
|
||||
description: RegExp[Symbol.species] exists per spec
|
||||
includes:
|
||||
includes:
|
||||
- propertyHelper.js
|
||||
---*/
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Symbol as Set entry
|
||||
features: [Set]
|
||||
---*/
|
||||
var set = new Set();
|
||||
var sym = Symbol();
|
||||
|
||||
set.add(sym);
|
||||
|
||||
assert.sameValue(set.size, 1, "The value of `set.size` is `1`, after executing `set.add(sym)`");
|
||||
assert.sameValue(set.has(sym), true, "`set.has(sym)` returns `true`");
|
||||
assert.sameValue(set.delete(sym), true, "`set.delete(sym)` returns `true`");
|
||||
assert.sameValue(set.size, 0, "The value of `set.size` is `0`");
|
|
@ -7,7 +7,7 @@ info: >
|
|||
es6id: 23.2.2.2
|
||||
author: Sam Mikes
|
||||
description: Set[Symbol.species] exists per spec
|
||||
includes:
|
||||
includes:
|
||||
- propertyHelper.js
|
||||
---*/
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4.3.2
|
||||
description: >
|
||||
String coercion operations on Symbols
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new String(Symbol('66'));
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol('66') + '';
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Symbol ToObject auto-boxing
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var sym = Symbol('66');
|
||||
|
||||
sym.a = 0;
|
||||
assert.sameValue(sym.a, undefined, "The value of `sym.a` is `undefined`, after executing `sym.a = 0;`");
|
||||
|
||||
sym['a' + 'b'] = 0;
|
||||
assert.sameValue(sym['a' + 'b'], undefined, "The value of `sym['a' + 'b']` is `undefined`, after executing `sym['a' + 'b'] = 0;`");
|
||||
|
||||
sym[62] = 0;
|
||||
assert.sameValue(sym[62], undefined, "The value of `sym[62]` is `undefined`, after executing `sym[62] = 0;`");
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Symbol ToObject auto-boxing
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var sym = Symbol('66');
|
||||
sym.a = 0;
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var sym = Symbol('66');
|
||||
sym['a' + 'b'] = 0;
|
||||
;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var sym = Symbol('66');
|
||||
sym[62] = 0;
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4.3.1
|
||||
description: >
|
||||
Symbol constructor
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Symbol('66')).constructor,
|
||||
Symbol,
|
||||
"The value of `Object.getPrototypeOf(Symbol('66')).constructor` is `Symbol`"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Object(Symbol('66'))).constructor,
|
||||
Symbol,
|
||||
"The value of `Object.getPrototypeOf(Object(Symbol('66'))).constructor` is `Symbol`"
|
||||
);
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4.3.2
|
||||
description: >
|
||||
toStringTag return value
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.prototype.toString.call(Symbol('66')),
|
||||
'[object Symbol]',
|
||||
"`Object.prototype.toString.call(Symbol('66'))` returns `'[object Symbol]'`"
|
||||
);
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4.3
|
||||
description: >
|
||||
Symbol prototype
|
||||
---*/
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Symbol('66')),
|
||||
Symbol.prototype,
|
||||
"`Object.getPrototypeOf(Symbol('66'))` returns `Symbol.prototype`"
|
||||
);
|
16
test/built-ins/Symbol/prototype/toString/toString-default-attributes-non-strict.js
vendored
Normal file
16
test/built-ins/Symbol/prototype/toString/toString-default-attributes-non-strict.js
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Symbol property get and set, non-strict
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var sym = Symbol('66');
|
||||
|
||||
sym.toString = 0;
|
||||
assert.sameValue(sym.toString(), 'Symbol(66)', "`sym.toString()` returns `'Symbol(66)'`, after executing `sym.toString = 0;`");
|
||||
|
||||
sym.valueOf = 0;
|
||||
assert.sameValue(sym, sym.valueOf(), "The value of `sym` is `sym.valueOf()`, after executing `sym.valueOf = 0;`");
|
18
test/built-ins/Symbol/prototype/toString/toString-default-attributes-strict.js
vendored
Normal file
18
test/built-ins/Symbol/prototype/toString/toString-default-attributes-strict.js
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4
|
||||
description: >
|
||||
Symbol property get and set, strict
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
|
||||
var sym = Symbol("66");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sym.toString = 0;
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sym.valueOf = 0;
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 19.4.3.2
|
||||
description: >
|
||||
toString operations on Symbols
|
||||
---*/
|
||||
assert.sameValue(
|
||||
String(Symbol('66')),
|
||||
'Symbol(66)',
|
||||
"`String(Symbol('66'))` returns `'Symbol(66)'`"
|
||||
)
|
||||
assert.sameValue(
|
||||
Symbol('66').toString(),
|
||||
'Symbol(66)',
|
||||
"`Symbol('66').toString()` returns `'Symbol(66)'`"
|
||||
);
|
||||
assert.sameValue(
|
||||
Object(Symbol('66')).toString(),
|
||||
'Symbol(66)',
|
||||
"`Object(Symbol('66')).toString()` returns `'Symbol(66)'`"
|
||||
);
|
||||
assert.sameValue(
|
||||
Symbol.prototype.toString.call(Symbol('66')),
|
||||
'Symbol(66)',
|
||||
"`Symbol.prototype.toString.call(Symbol('66'))` returns `'Symbol(66)'`"
|
||||
);
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.3.3.5_S2
|
||||
description: >
|
||||
Symbol may not be used as a WeakMap key
|
||||
features: [WeakMap]
|
||||
---*/
|
||||
var weakmap = new WeakMap();
|
||||
var sym = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
weakmap.set(sym, 1);
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 23.4.3.1_S2
|
||||
description: >
|
||||
Symbol may not be used as a WeakSet entry
|
||||
features: [WeakSet]
|
||||
---*/
|
||||
var weakset = new WeakSet();
|
||||
var sym = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
weakset.add(sym);
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 12.12.3
|
||||
description: >
|
||||
Conditional Symbol evaluation
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
|
||||
assert.sameValue(sym ? 1 : 2, 1, "`sym ? 1 : 2` is `1`");
|
||||
assert.sameValue(!sym ? 1 : 2, 2, "`!sym ? 1 : 2` is `2`");
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 7.2.12
|
||||
description: >
|
||||
Abstract Equality Comparison: Symbol
|
||||
---*/
|
||||
var symA = Symbol('66');
|
||||
var symB = Symbol('66');
|
||||
|
||||
assert.sameValue(symA == symA, true, "The result of `symA == symA` is `true`");
|
||||
assert.sameValue(symA == symA.valueOf(), true, "The result of `symA == symA.valueOf()` is `true`");
|
||||
assert.sameValue(symA.valueOf() == symA, true, "The result of `symA.valueOf() == symA` is `true`");
|
||||
|
||||
assert.sameValue(symB == symB, true, "The result of `symB == symB` is `true`");
|
||||
assert.sameValue(symB == symB.valueOf(), true, "The result of `symB == symB.valueOf()` is `true`");
|
||||
assert.sameValue(symB.valueOf() == symB, true, "The result of `symB.valueOf() == symB` is `true`");
|
||||
|
||||
assert.sameValue(symA == symB, false, "The result of `symA == symB` is `false`");
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 7.2.13
|
||||
description: >
|
||||
Strict Equality Comparison: Symbol
|
||||
---*/
|
||||
var symA = Symbol('66');
|
||||
var symB = Symbol('66');
|
||||
|
||||
assert.sameValue(symA === symA, true, "The result of `symA === symA` is `true`");
|
||||
assert.sameValue(symA === symA.valueOf(), true, "The result of `symA === symA.valueOf()` is `true`");
|
||||
assert.sameValue(symA.valueOf() === symA, true, "The result of `symA.valueOf() === symA` is `true`");
|
||||
|
||||
assert.sameValue(symB === symB, true, "The result of `symB === symB` is `true`");
|
||||
assert.sameValue(symB === symB.valueOf(), true, "The result of `symB === symB.valueOf()` is `true`");
|
||||
assert.sameValue(symB.valueOf() === symB, true, "The result of `symB.valueOf() === symB` is `true`");
|
||||
|
||||
assert.sameValue(symA === symB, false, "The result of `symA === symB` is `false`");
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 12.12.3
|
||||
description: >
|
||||
"Logical AND" Symbol evaluation
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
|
||||
assert.sameValue(sym && true, true, "`sym && true` is `true`");
|
||||
assert.sameValue(!sym && false, false, "`!sym && false` is `false`");
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 12.5.12.1
|
||||
description: >
|
||||
"Logical Not" coercion operation on Symbols
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
|
||||
assert.sameValue(!sym, false, "`!sym` is `false`");
|
||||
assert.sameValue(!!sym, true, "`!!sym` is `true`");
|
||||
|
||||
if (!sym) {
|
||||
$ERROR("ToBoolean(Symbol) always returns `true`");
|
||||
} else if (sym) {
|
||||
assert(true, "`sym` evaluates to `true`");
|
||||
} else {
|
||||
$ERROR("ToBoolean(Symbol) always returns `true`");
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 12.12.3
|
||||
description: >
|
||||
"Logical OR" Symbol evaluation
|
||||
---*/
|
||||
var sym = Symbol();
|
||||
|
||||
assert.sameValue(!sym || true, true, "`!sym || true` is `true`");
|
||||
assert.sameValue(sym || false, sym, "`sym || false` is `sym`");
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 12.5.6.1
|
||||
description: >
|
||||
typeof Symbol() returns 'symbol'.
|
||||
typeof Object(Symbol()) returns 'object'.
|
||||
---*/
|
||||
assert.sameValue(typeof Symbol('A'), 'symbol', "`typeof Symbol('A')` is `'symbol'`");
|
||||
assert.sameValue(typeof Symbol(), 'symbol', "`typeof Symbol()` is `'symbol'`");
|
||||
|
||||
var symA = Symbol();
|
||||
assert.sameValue(typeof symA, 'symbol', "`typeof symA` is `'symbol'`, after executing `var symA = Symbol();`");
|
||||
|
||||
var symB = Object(Symbol());
|
||||
assert.sameValue(typeof symB, 'object', "`typeof symB` is `'object'`, after executing `var symB = Object(Symbol());`");
|
||||
|
Loading…
Reference in New Issue