diff --git a/test/built-ins/Symbol/species/Symbol.species.in_Array.js b/test/built-ins/Array/symbol-species.js similarity index 97% rename from test/built-ins/Symbol/species/Symbol.species.in_Array.js rename to test/built-ins/Array/symbol-species.js index 93c13d5ac7..1d62c861bc 100644 --- a/test/built-ins/Symbol/species/Symbol.species.in_Array.js +++ b/test/built-ins/Array/symbol-species.js @@ -7,7 +7,7 @@ info: > es6id: 22.1.2.5 author: Sam Mikes description: Array[Symbol.species] exists per spec -includes: +includes: - propertyHelper.js ---*/ diff --git a/test/built-ins/Symbol/species/Symbol.species.in_ArrayBuffer.js b/test/built-ins/ArrayBuffer/symbol-species.js similarity index 98% rename from test/built-ins/Symbol/species/Symbol.species.in_ArrayBuffer.js rename to test/built-ins/ArrayBuffer/symbol-species.js index 2e31d914fe..ed22d4a006 100644 --- a/test/built-ins/Symbol/species/Symbol.species.in_ArrayBuffer.js +++ b/test/built-ins/ArrayBuffer/symbol-species.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 ---*/ diff --git a/test/built-ins/Boolean/symbol-coercion.js b/test/built-ins/Boolean/symbol-coercion.js new file mode 100644 index 0000000000..59e953df0e --- /dev/null +++ b/test/built-ins/Boolean/symbol-coercion.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`"); diff --git a/test/built-ins/Map/symbol-as-entry-key.js b/test/built-ins/Map/symbol-as-entry-key.js new file mode 100644 index 0000000000..cf82d615a1 --- /dev/null +++ b/test/built-ins/Map/symbol-as-entry-key.js @@ -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`"); + diff --git a/test/built-ins/Symbol/species/Symbol.species.in_Map.js b/test/built-ins/Map/symbol-species.js similarity index 97% rename from test/built-ins/Symbol/species/Symbol.species.in_Map.js rename to test/built-ins/Map/symbol-species.js index b2c4344998..ca9742b710 100644 --- a/test/built-ins/Symbol/species/Symbol.species.in_Map.js +++ b/test/built-ins/Map/symbol-species.js @@ -7,7 +7,7 @@ info: > es6id: 23.1.2.2 author: Sam Mikes description: Map[Symbol.species] exists per spec -includes: +includes: - propertyHelper.js ---*/ diff --git a/test/built-ins/Number/symbol-number-coercion.js b/test/built-ins/Number/symbol-number-coercion.js new file mode 100644 index 0000000000..38938100b3 --- /dev/null +++ b/test/built-ins/Number/symbol-number-coercion.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')]); +}); diff --git a/test/built-ins/Object/defineProperty/symbol-data-property-configurable-non-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-configurable-non-strict.js new file mode 100644 index 0000000000..622f6787c6 --- /dev/null +++ b/test/built-ins/Object/defineProperty/symbol-data-property-configurable-non-strict.js @@ -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`" +); diff --git a/test/built-ins/Object/defineProperty/symbol-data-property-configurable-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-configurable-strict.js new file mode 100644 index 0000000000..4e8be2295c --- /dev/null +++ b/test/built-ins/Object/defineProperty/symbol-data-property-configurable-strict.js @@ -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`" +); diff --git a/test/built-ins/Object/defineProperty/symbol-data-property-default-non-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-default-non-strict.js new file mode 100644 index 0000000000..433a9c0a13 --- /dev/null +++ b/test/built-ins/Object/defineProperty/symbol-data-property-default-non-strict.js @@ -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`"); diff --git a/test/built-ins/Object/defineProperty/symbol-data-property-default-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-default-strict.js new file mode 100644 index 0000000000..0b0bcdd6d8 --- /dev/null +++ b/test/built-ins/Object/defineProperty/symbol-data-property-default-strict.js @@ -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`"); diff --git a/test/built-ins/Object/defineProperty/symbol-data-property-writable-non-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-writable-non-strict.js new file mode 100644 index 0000000000..5156206a65 --- /dev/null +++ b/test/built-ins/Object/defineProperty/symbol-data-property-writable-non-strict.js @@ -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`"); diff --git a/test/built-ins/Object/defineProperty/symbol-data-property-writable-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-writable-strict.js new file mode 100644 index 0000000000..d76388ad62 --- /dev/null +++ b/test/built-ins/Object/defineProperty/symbol-data-property-writable-strict.js @@ -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`"); diff --git a/test/built-ins/Object/freeze/frozen-object-contains-symbol-properties-non-strict.js b/test/built-ins/Object/freeze/frozen-object-contains-symbol-properties-non-strict.js new file mode 100644 index 0000000000..34b01bd550 --- /dev/null +++ b/test/built-ins/Object/freeze/frozen-object-contains-symbol-properties-non-strict.js @@ -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`"); diff --git a/test/built-ins/Object/freeze/frozen-object-contains-symbol-properties-strict.js b/test/built-ins/Object/freeze/frozen-object-contains-symbol-properties-strict.js new file mode 100644 index 0000000000..f3c6d9747b --- /dev/null +++ b/test/built-ins/Object/freeze/frozen-object-contains-symbol-properties-strict.js @@ -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; +}); diff --git a/test/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-with-description.js b/test/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-with-description.js new file mode 100644 index 0000000000..62c7be891c --- /dev/null +++ b/test/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-with-description.js @@ -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`"); + + diff --git a/test/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-without-description.js b/test/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-without-description.js new file mode 100644 index 0000000000..90ead35aa0 --- /dev/null +++ b/test/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-without-description.js @@ -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`"); + + diff --git a/test/built-ins/Object/is/symbol-object-is-same-value.js b/test/built-ins/Object/is/symbol-object-is-same-value.js new file mode 100644 index 0000000000..6af4d4d3ce --- /dev/null +++ b/test/built-ins/Object/is/symbol-object-is-same-value.js @@ -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`"); + + diff --git a/test/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-non-strict.js b/test/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-non-strict.js new file mode 100644 index 0000000000..62557ccc61 --- /dev/null +++ b/test/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-non-strict.js @@ -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`"); diff --git a/test/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-strict.js b/test/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-strict.js new file mode 100644 index 0000000000..979fe67ff7 --- /dev/null +++ b/test/built-ins/Object/preventExtensions/symbol-object-contains-symbol-properties-strict.js @@ -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`"); + + + diff --git a/test/built-ins/Object/seal/symbol-object-contains-symbol-properties-non-strict.js b/test/built-ins/Object/seal/symbol-object-contains-symbol-properties-non-strict.js new file mode 100644 index 0000000000..0b11a5d040 --- /dev/null +++ b/test/built-ins/Object/seal/symbol-object-contains-symbol-properties-non-strict.js @@ -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`"); + diff --git a/test/built-ins/Object/seal/symbol-object-contains-symbol-properties-strict.js b/test/built-ins/Object/seal/symbol-object-contains-symbol-properties-strict.js new file mode 100644 index 0000000000..477dd8ce74 --- /dev/null +++ b/test/built-ins/Object/seal/symbol-object-contains-symbol-properties-strict.js @@ -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; +}); + diff --git a/test/built-ins/Object/symbol_object-returns-fresh-symbol.js b/test/built-ins/Object/symbol_object-returns-fresh-symbol.js new file mode 100644 index 0000000000..ef83db90cb --- /dev/null +++ b/test/built-ins/Object/symbol_object-returns-fresh-symbol.js @@ -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`"); diff --git a/test/built-ins/Symbol/species/Symbol.species.in_Promise.js b/test/built-ins/Promise/symbol-species.js similarity index 97% rename from test/built-ins/Symbol/species/Symbol.species.in_Promise.js rename to test/built-ins/Promise/symbol-species.js index 0201377b89..cfc797ce05 100644 --- a/test/built-ins/Symbol/species/Symbol.species.in_Promise.js +++ b/test/built-ins/Promise/symbol-species.js @@ -7,7 +7,7 @@ info: > es6id: 6.1.5.1 author: Sam Mikes description: Promise[Symbol.species] exists per spec -includes: +includes: - propertyHelper.js ---*/ diff --git a/test/built-ins/Symbol/species/Symbol.species.in_RegExp.js b/test/built-ins/RegExp/symbol-species.js similarity index 97% rename from test/built-ins/Symbol/species/Symbol.species.in_RegExp.js rename to test/built-ins/RegExp/symbol-species.js index 4b82e471dd..453bcdfae3 100644 --- a/test/built-ins/Symbol/species/Symbol.species.in_RegExp.js +++ b/test/built-ins/RegExp/symbol-species.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 ---*/ diff --git a/test/built-ins/Set/symbol-as-entry.js b/test/built-ins/Set/symbol-as-entry.js new file mode 100644 index 0000000000..7faa667031 --- /dev/null +++ b/test/built-ins/Set/symbol-as-entry.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`"); diff --git a/test/built-ins/Symbol/species/Symbol.species.in_Set.js b/test/built-ins/Set/symbol-species.js similarity index 97% rename from test/built-ins/Symbol/species/Symbol.species.in_Set.js rename to test/built-ins/Set/symbol-species.js index 8568a732c0..6f9763199e 100644 --- a/test/built-ins/Symbol/species/Symbol.species.in_Set.js +++ b/test/built-ins/Set/symbol-species.js @@ -7,7 +7,7 @@ info: > es6id: 23.2.2.2 author: Sam Mikes description: Set[Symbol.species] exists per spec -includes: +includes: - propertyHelper.js ---*/ diff --git a/test/built-ins/String/symbol-string-coercion.js b/test/built-ins/String/symbol-string-coercion.js new file mode 100644 index 0000000000..2a5881503b --- /dev/null +++ b/test/built-ins/String/symbol-string-coercion.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') + ''; +}); + + diff --git a/test/built-ins/Symbol/auto-boxing-non-strict.js b/test/built-ins/Symbol/auto-boxing-non-strict.js new file mode 100644 index 0000000000..888745f3be --- /dev/null +++ b/test/built-ins/Symbol/auto-boxing-non-strict.js @@ -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;`"); diff --git a/test/built-ins/Symbol/auto-boxing-strict.js b/test/built-ins/Symbol/auto-boxing-strict.js new file mode 100644 index 0000000000..fd06011549 --- /dev/null +++ b/test/built-ins/Symbol/auto-boxing-strict.js @@ -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; +}); diff --git a/test/built-ins/Symbol/constructor.js b/test/built-ins/Symbol/constructor.js new file mode 100644 index 0000000000..38fd3dc029 --- /dev/null +++ b/test/built-ins/Symbol/constructor.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.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`" +); diff --git a/test/built-ins/Symbol/prototype/@@toStringTag/@@toStringTag.js b/test/built-ins/Symbol/prototype/@@toStringTag/@@toStringTag.js new file mode 100644 index 0000000000..90a66cec2a --- /dev/null +++ b/test/built-ins/Symbol/prototype/@@toStringTag/@@toStringTag.js @@ -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]'`" +); diff --git a/test/built-ins/Symbol/prototype/intrinsic.js b/test/built-ins/Symbol/prototype/intrinsic.js new file mode 100644 index 0000000000..d1db43e86f --- /dev/null +++ b/test/built-ins/Symbol/prototype/intrinsic.js @@ -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`" +); diff --git a/test/built-ins/Symbol/prototype/toString/toString-default-attributes-non-strict.js b/test/built-ins/Symbol/prototype/toString/toString-default-attributes-non-strict.js new file mode 100644 index 0000000000..35804142c0 --- /dev/null +++ b/test/built-ins/Symbol/prototype/toString/toString-default-attributes-non-strict.js @@ -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;`"); diff --git a/test/built-ins/Symbol/prototype/toString/toString-default-attributes-strict.js b/test/built-ins/Symbol/prototype/toString/toString-default-attributes-strict.js new file mode 100644 index 0000000000..e240094e81 --- /dev/null +++ b/test/built-ins/Symbol/prototype/toString/toString-default-attributes-strict.js @@ -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; +}); diff --git a/test/built-ins/Symbol/prototype/toString/toString.js b/test/built-ins/Symbol/prototype/toString/toString.js new file mode 100644 index 0000000000..3d1c4f7e65 --- /dev/null +++ b/test/built-ins/Symbol/prototype/toString/toString.js @@ -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)'`" +); diff --git a/test/built-ins/Symbol/species/Symbol.species.exists.js b/test/built-ins/Symbol/species/basic.js similarity index 100% rename from test/built-ins/Symbol/species/Symbol.species.exists.js rename to test/built-ins/Symbol/species/basic.js diff --git a/test/built-ins/Symbol/species/Symbol.species.builtin-getter-name.js b/test/built-ins/Symbol/species/builtin-getter-name.js similarity index 100% rename from test/built-ins/Symbol/species/Symbol.species.builtin-getter-name.js rename to test/built-ins/Symbol/species/builtin-getter-name.js diff --git a/test/built-ins/Symbol/species/Symbol.species.notChangedByExtends.js b/test/built-ins/Symbol/species/subclassing.js similarity index 100% rename from test/built-ins/Symbol/species/Symbol.species.notChangedByExtends.js rename to test/built-ins/Symbol/species/subclassing.js diff --git a/test/built-ins/WeakMap/symbol-disallowed-as-weakmap-key.js b/test/built-ins/WeakMap/symbol-disallowed-as-weakmap-key.js new file mode 100644 index 0000000000..4ed39dfe5a --- /dev/null +++ b/test/built-ins/WeakMap/symbol-disallowed-as-weakmap-key.js @@ -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); +}); diff --git a/test/built-ins/WeakSet/symbol-disallowed-as-weakset-key.js b/test/built-ins/WeakSet/symbol-disallowed-as-weakset-key.js new file mode 100644 index 0000000000..64cb1862bf --- /dev/null +++ b/test/built-ins/WeakSet/symbol-disallowed-as-weakset-key.js @@ -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); +}); + + diff --git a/test/language/expressions/conditional/symbol-conditional-evaluation.js b/test/language/expressions/conditional/symbol-conditional-evaluation.js new file mode 100644 index 0000000000..048a3800a7 --- /dev/null +++ b/test/language/expressions/conditional/symbol-conditional-evaluation.js @@ -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`"); diff --git a/test/language/expressions/equals/symbol-abstract-equality-comparison.js b/test/language/expressions/equals/symbol-abstract-equality-comparison.js new file mode 100644 index 0000000000..cbd640bba9 --- /dev/null +++ b/test/language/expressions/equals/symbol-abstract-equality-comparison.js @@ -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`"); + diff --git a/test/language/expressions/equals/symbol-strict-equality-comparison.js b/test/language/expressions/equals/symbol-strict-equality-comparison.js new file mode 100644 index 0000000000..b83512dbae --- /dev/null +++ b/test/language/expressions/equals/symbol-strict-equality-comparison.js @@ -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`"); diff --git a/test/language/expressions/logical-and/symbol-logical-and-evaluation.js b/test/language/expressions/logical-and/symbol-logical-and-evaluation.js new file mode 100644 index 0000000000..cb5d8222ee --- /dev/null +++ b/test/language/expressions/logical-and/symbol-logical-and-evaluation.js @@ -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`"); diff --git a/test/language/expressions/logical-not/symbol-logical-not-evaluation.js b/test/language/expressions/logical-not/symbol-logical-not-evaluation.js new file mode 100644 index 0000000000..2cebca785a --- /dev/null +++ b/test/language/expressions/logical-not/symbol-logical-not-evaluation.js @@ -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`"); +} diff --git a/test/language/expressions/logical-or/symbol-logical-or-evaluation.js b/test/language/expressions/logical-or/symbol-logical-or-evaluation.js new file mode 100644 index 0000000000..ce86e19334 --- /dev/null +++ b/test/language/expressions/logical-or/symbol-logical-or-evaluation.js @@ -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`"); diff --git a/test/language/expressions/typeof/symbol.js b/test/language/expressions/typeof/symbol.js new file mode 100644 index 0000000000..71403e7d8a --- /dev/null +++ b/test/language/expressions/typeof/symbol.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: 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());`"); +