diff --git a/test/built-ins/Object/entries/observable-operations.js b/test/built-ins/Object/entries/observable-operations.js new file mode 100644 index 0000000000000000000000000000000000000000..1ace44358c53532ac41d280c93a73d1fecb5785f --- /dev/null +++ b/test/built-ins/Object/entries/observable-operations.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries should perform observable operations in the correct order +es7id: pending +author: Jordan Harband +features: [Proxy] +---*/ + +var log = ""; +var object = { a: 0, b: 0, c: 0 }; +var handler = { + get: function (target, propertyKey, receiver) { + assert.sameValue(target, object, "get target"); + assert.sameValue(receiver, proxy, "get receiver"); + log += "|get:" + propertyKey; + return target[propertyKey]; + }, + getOwnPropertyDescriptor: function (target, propertyKey) { + assert.sameValue(target, object, "getOwnPropertyDescriptor"); + log += "|getOwnPropertyDescriptor:" + propertyKey; + return Object.getOwnPropertyDescriptor(target, propertyKey); + }, + ownKeys: function (target) { + assert.sameValue(target, object, "ownKeys"); + log += "|ownKeys"; + return Object.getOwnPropertyNames(target); + }, + deleteProperty: function (oTarget, sKey) { + throw new Test262Error('properties should not be deleted'); + }, + defineProperty: function (oTarget, sKey, oDesc) { + throw new Test262Error('properties should not be defined'); + }, + set: function (oTarget, sKey, vValue) { + throw new Test262Error('properties should not be assigned'); + } +}; +var check = { + get: function (target, propertyKey, receiver) { + assert(propertyKey in target, "handler check: " + propertyKey); + return target[propertyKey]; + } +}; +var proxy = new Proxy(object, new Proxy(handler, check)); +var result = Object.entries(proxy); +assert.sameValue(log, "|ownKeys|getOwnPropertyDescriptor:a|get:a|getOwnPropertyDescriptor:b|get:b|getOwnPropertyDescriptor:c|get:c", log); diff --git a/test/built-ins/Object/values/observable-operations.js b/test/built-ins/Object/values/observable-operations.js new file mode 100644 index 0000000000000000000000000000000000000000..e6c12d0b8aead6bdde2b4750c813dfca02f841b4 --- /dev/null +++ b/test/built-ins/Object/values/observable-operations.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values should perform observable operations in the correct order +es7id: pending +author: Jordan Harband +features: [Proxy] +---*/ + +var log = ""; +var object = { a: 0, b: 0, c: 0 }; +var handler = { + get: function (target, propertyKey, receiver) { + assert.sameValue(target, object, "get target"); + assert.sameValue(receiver, proxy, "get receiver"); + log += "|get:" + propertyKey; + return target[propertyKey]; + }, + getOwnPropertyDescriptor: function (target, propertyKey) { + assert.sameValue(target, object, "getOwnPropertyDescriptor"); + log += "|getOwnPropertyDescriptor:" + propertyKey; + return Object.getOwnPropertyDescriptor(target, propertyKey); + }, + ownKeys: function (target) { + assert.sameValue(target, object, "ownKeys"); + log += "|ownKeys"; + return Object.getOwnPropertyNames(target); + }, + deleteProperty: function (oTarget, sKey) { + throw new Test262Error('properties should not be deleted'); + }, + defineProperty: function (oTarget, sKey, oDesc) { + throw new Test262Error('properties should not be defined'); + }, + set: function (oTarget, sKey, vValue) { + throw new Test262Error('properties should not be assigned'); + } +}; +var check = { + get: function (target, propertyKey, receiver) { + assert(propertyKey in target, "handler check: " + propertyKey); + return target[propertyKey]; + } +}; +var proxy = new Proxy(object, new Proxy(handler, check)); +var result = Object.values(proxy); +assert.sameValue(log, "|ownKeys|getOwnPropertyDescriptor:a|get:a|getOwnPropertyDescriptor:b|get:b|getOwnPropertyDescriptor:c|get:c", log); diff --git a/test/built-ins/object/entries/exception-during-enumeration.js b/test/built-ins/object/entries/exception-during-enumeration.js new file mode 100644 index 0000000000000000000000000000000000000000..5066c8c7af8b81855657cfcb024f035df512649d --- /dev/null +++ b/test/built-ins/object/entries/exception-during-enumeration.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries should terminate if getting a value throws an exception +es7id: pending +author: Jordan Harband +---*/ + +var trappedKey = { + get a() { + throw new RangeError('This error should be re-thrown'); + }, + get b() { + $ERROR('Should not try to get the second element'); + } +}; + +assert.throws(RangeError, function () { + Object.entries(trappedKey); +}); diff --git a/test/built-ins/object/entries/exception-not-object-coercible.js b/test/built-ins/object/entries/exception-not-object-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..0a434aa3bb7f29e6c2248ece56031f021675ee66 --- /dev/null +++ b/test/built-ins/object/entries/exception-not-object-coercible.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries should fail if given a null or undefined value +es7id: pending +author: Jordan Harband +---*/ + +assert.throws(TypeError, function () { + Object.entries(null); +}); + +assert.throws(TypeError, function () { + Object.entries(undefined); +}); diff --git a/test/built-ins/object/entries/function-length.js b/test/built-ins/object/entries/function-length.js new file mode 100644 index 0000000000000000000000000000000000000000..a0b1b6a36459ed114324f6c80fc54621237b80c2 --- /dev/null +++ b/test/built-ins/object/entries/function-length.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries should have length 1 +es7id: pending +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Object.entries.length, 1, 'Expected Object.entries.length to be 1'); + +verifyNotEnumerable(Object.entries, 'length'); +verifyNotWritable(Object.entries, 'length'); +verifyConfigurable(Object.entries, 'length'); diff --git a/test/built-ins/object/entries/function-name.js b/test/built-ins/object/entries/function-name.js new file mode 100644 index 0000000000000000000000000000000000000000..4fd68f9f76ecd8ddea5587676dfa19390379eca8 --- /dev/null +++ b/test/built-ins/object/entries/function-name.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries should have name property with value 'entries' +es7id: pending +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Object.entries.name, + 'entries', + 'Expected Object.entries.name to be "entries"' +); + +verifyNotEnumerable(Object.entries, 'name'); +verifyNotWritable(Object.entries, 'name'); +verifyConfigurable(Object.entries, 'name'); diff --git a/test/built-ins/object/entries/function-property-descriptor.js b/test/built-ins/object/entries/function-property-descriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..a8109c0b81a50ed4591cc0e6dddec044abfacddf --- /dev/null +++ b/test/built-ins/object/entries/function-property-descriptor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries should be writable, non-enumerable, and configurable +es7id: pending +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Object, 'entries'); +verifyWritable(Object, 'entries'); +verifyConfigurable(Object, 'entries'); diff --git a/test/built-ins/object/entries/getter-adding-key.js b/test/built-ins/object/entries/getter-adding-key.js new file mode 100644 index 0000000000000000000000000000000000000000..d6a7217769f3f3713b87867e679392b403d68386 --- /dev/null +++ b/test/built-ins/object/entries/getter-adding-key.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries does not see a new element added by a getter that is hit during iteration +es7id: pending +author: Jordan Harband +---*/ + +var bAddsC = { + a: 'A', + get b() { + this.c = 'C'; + return 'B'; + } +}; + +var result = Object.entries(bAddsC); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array'); +assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array'); + +assert.sameValue(result[0][0], 'a', 'first entry has key "a"'); +assert.sameValue(result[0][1], 'A', 'first entry has value "A"'); +assert.sameValue(result[1][0], 'b', 'second entry has key "b"'); +assert.sameValue(result[1][1], 'B', 'second entry has value "B"'); diff --git a/test/built-ins/object/entries/getter-making-future-key-nonenumerable.js b/test/built-ins/object/entries/getter-making-future-key-nonenumerable.js new file mode 100644 index 0000000000000000000000000000000000000000..ae8407d5aaade1b65f8d04dd28d7f0edd8aceb79 --- /dev/null +++ b/test/built-ins/object/entries/getter-making-future-key-nonenumerable.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries does not see an element made non-enumerable by a getter that is hit during iteration +es7id: pending +author: Jordan Harband +---*/ + +var bDeletesC = { + a: 'A', + get b() { + Object.defineProperty(this, 'c', { + enumerable: false + }); + return 'B'; + }, + c: 'C' +}; + +var result = Object.entries(bDeletesC); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array'); +assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array'); + +assert.sameValue(result[0][0], 'a', 'first entry has key "a"'); +assert.sameValue(result[0][1], 'A', 'first entry has value "A"'); +assert.sameValue(result[1][0], 'b', 'second entry has key "b"'); +assert.sameValue(result[1][1], 'B', 'second entry has value "B"'); diff --git a/test/built-ins/object/entries/getter-removing-future-key.js b/test/built-ins/object/entries/getter-removing-future-key.js new file mode 100644 index 0000000000000000000000000000000000000000..5429ec4e42c11681ef3c3ecb60ff765332af4ae7 --- /dev/null +++ b/test/built-ins/object/entries/getter-removing-future-key.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries does not see an element removed by a getter that is hit during iteration +es7id: pending +author: Jordan Harband +---*/ + +var bDeletesC = { + a: 'A', + get b() { + delete this.c; + return 'B'; + }, + c: 'C' +}; + +var result = Object.entries(bDeletesC); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array'); +assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array'); + +assert.sameValue(result[0][0], 'a', 'first entry has key "a"'); +assert.sameValue(result[0][1], 'A', 'first entry has value "A"'); +assert.sameValue(result[1][0], 'b', 'second entry has key "b"'); +assert.sameValue(result[1][1], 'B', 'second entry has value "B"'); diff --git a/test/built-ins/object/entries/inherited-properties-omitted.js b/test/built-ins/object/entries/inherited-properties-omitted.js new file mode 100644 index 0000000000000000000000000000000000000000..0b9a55c18d3c3b1c56b4ebcd2f29482c1601725d --- /dev/null +++ b/test/built-ins/object/entries/inherited-properties-omitted.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries does not see inherited properties. +es7id: pending +author: Jordan Harband +---*/ + +var F = function G() {}; +F.prototype.a = {}; +F.prototype.b = {}; + +var f = new F(); +f.b = {}; // shadow the prototype +f.c = {}; // solely an own property + +var result = Object.entries(f); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array'); +assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array'); + +assert.sameValue(result[0][0], 'b', 'first entry has key "b"'); +assert.sameValue(result[0][1], f.b, 'first entry has value f.b'); +assert.sameValue(result[1][0], 'c', 'second entry has key "c"'); +assert.sameValue(result[1][1], f.c, 'second entry has value f.c'); diff --git a/test/built-ins/object/entries/primitive-booleans.js b/test/built-ins/object/entries/primitive-booleans.js new file mode 100644 index 0000000000000000000000000000000000000000..d7f961c458f635a4beee74d769bd594a25bb9324 --- /dev/null +++ b/test/built-ins/object/entries/primitive-booleans.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries accepts boolean primitives. +es7id: pending +author: Jordan Harband +---*/ + +var trueResult = Object.entries(true); + +assert.sameValue(Array.isArray(trueResult), true, 'trueResult is an array'); +assert.sameValue(trueResult.length, 0, 'trueResult has 0 items'); + +var falseResult = Object.entries(false); + +assert.sameValue(Array.isArray(falseResult), true, 'falseResult is an array'); +assert.sameValue(falseResult.length, 0, 'falseResult has 0 items'); diff --git a/test/built-ins/object/entries/primitive-numbers.js b/test/built-ins/object/entries/primitive-numbers.js new file mode 100644 index 0000000000000000000000000000000000000000..fb5649923b6928a2cf5d11aadda4454e8180c7d3 --- /dev/null +++ b/test/built-ins/object/entries/primitive-numbers.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries accepts number primitives. +es7id: pending +author: Jordan Harband +---*/ + +assert.sameValue(Object.entries(0).length, 0, '0 has zero entries'); +assert.sameValue(Object.entries(-0).length, 0, '-0 has zero entries'); +assert.sameValue(Object.entries(Infinity).length, 0, 'Infinity has zero entries'); +assert.sameValue(Object.entries(-Infinity).length, 0, '-Infinity has zero entries'); +assert.sameValue(Object.entries(NaN).length, 0, 'NaN has zero entries'); +assert.sameValue(Object.entries(Math.PI).length, 0, 'Math.PI has zero entries'); diff --git a/test/built-ins/object/entries/primitive-strings.js b/test/built-ins/object/entries/primitive-strings.js new file mode 100644 index 0000000000000000000000000000000000000000..5c3ab5d16f74f24997e00cc5d976819f5e6f2318 --- /dev/null +++ b/test/built-ins/object/entries/primitive-strings.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries accepts string primitives. +es7id: pending +author: Jordan Harband +---*/ + +var result = Object.entries('abc'); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 3, 'result has 3 items'); + +assert.sameValue(result[0][0], '0', 'first entry has key "0"'); +assert.sameValue(result[0][1], 'a', 'first entry has value "a"'); +assert.sameValue(result[1][0], '1', 'second entry has key "1"'); +assert.sameValue(result[1][1], 'b', 'second entry has value "b"'); +assert.sameValue(result[2][0], '2', 'third entry has key "2"'); +assert.sameValue(result[2][1], 'c', 'third entry has value "c"'); diff --git a/test/built-ins/object/entries/primitive-symbols.js b/test/built-ins/object/entries/primitive-symbols.js new file mode 100644 index 0000000000000000000000000000000000000000..c105a6293369c05b92feebe0cc89fb9b98bf19fb --- /dev/null +++ b/test/built-ins/object/entries/primitive-symbols.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries accepts Symbol primitives. +es7id: pending +author: Jordan Harband +features: [Symbol] +---*/ + +var result = Object.entries(Symbol()); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 0, 'result has 0 items'); diff --git a/test/built-ins/object/entries/symbols-omitted.js b/test/built-ins/object/entries/symbols-omitted.js new file mode 100644 index 0000000000000000000000000000000000000000..7268e9f2db56f98e2081932d13c58fe156f19cc9 --- /dev/null +++ b/test/built-ins/object/entries/symbols-omitted.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.entries does not include Symbol keys. +es7id: pending +author: Jordan Harband +features: [Symbol] +---*/ + +var value = {}; +var enumSym = Symbol('enum'); +var nonEnumSym = Symbol('nonenum'); +var symValue = Symbol('value'); + +var obj = { key: symValue }; +obj[enumSym] = value; +Object.defineProperty(obj, nonEnumSym, { enumerable: false, value: value }); + +var result = Object.entries(obj); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 1, 'result has 1 item'); + +assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array'); + +assert.sameValue(result[0][0], 'key', 'first entry has key "key"'); +assert.sameValue(result[0][1], symValue, 'first entry has value `symValue`'); diff --git a/test/built-ins/object/entries/tamper-with-global-object.js b/test/built-ins/object/entries/tamper-with-global-object.js new file mode 100644 index 0000000000000000000000000000000000000000..0ba60fcb4c3f712294cfdc1780aa0cb79343c4bd --- /dev/null +++ b/test/built-ins/object/entries/tamper-with-global-object.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object.entries should not have its behavior impacted by modifications to the global property Object +es7id: pending +author: Jordan Harband +---*/ + +function fakeObject() { + $ERROR('The overriden version of Object was called!'); +} +fakeObject.entries = Object.entries; + +var global = Function('return this;')(); +global.Object = fakeObject; + +assert.sameValue(Object, fakeObject, 'Sanity check failed: could not modify the global Object'); +assert.sameValue(Object.entries(1).length, 0, 'Expected number primitive to have zero entries'); diff --git a/test/built-ins/object/entries/tamper-with-object-keys.js b/test/built-ins/object/entries/tamper-with-object-keys.js new file mode 100644 index 0000000000000000000000000000000000000000..b2fc255a11dbb678eec8040f78ab0838b9649f27 --- /dev/null +++ b/test/built-ins/object/entries/tamper-with-object-keys.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object.entries should not have its behavior impacted by modifications to Object.keys +es7id: pending +author: Jordan Harband +---*/ + +function fakeObjectKeys() { + $ERROR('The overriden version of Object.keys was called!'); +} + +Object.keys = fakeObjectKeys; + +assert.sameValue(Object.keys, fakeObjectKeys, 'Sanity check failed: could not modify the global Object.keys'); +assert.sameValue(Object.entries({ a: 1 }).length, 1, 'Expected object with 1 key to have 1 entry'); diff --git a/test/built-ins/object/values/exception-during-enumeration.js b/test/built-ins/object/values/exception-during-enumeration.js new file mode 100644 index 0000000000000000000000000000000000000000..eabe7d4316aefd523a3184542932c941081fa1b1 --- /dev/null +++ b/test/built-ins/object/values/exception-during-enumeration.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values should terminate if getting a value throws an exception +es7id: pending +author: Jordan Harband +---*/ + +var trappedKey = { + get a() { + throw new RangeError('This error should be re-thrown'); + }, + get b() { + $ERROR('Should not try to get the second element'); + } +}; + +assert.throws(RangeError, function () { + Object.values(trappedKey); +}); diff --git a/test/built-ins/object/values/exception-not-object-coercible.js b/test/built-ins/object/values/exception-not-object-coercible.js new file mode 100644 index 0000000000000000000000000000000000000000..f23af2c67b596eaa295c5288cc64e2e8df881d6c --- /dev/null +++ b/test/built-ins/object/values/exception-not-object-coercible.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values should fail if given a null or undefined value +es7id: pending +author: Jordan Harband +---*/ + +assert.throws(TypeError, function () { + Object.values(null); +}); + +assert.throws(TypeError, function () { + Object.values(undefined); +}); diff --git a/test/built-ins/object/values/function-length.js b/test/built-ins/object/values/function-length.js new file mode 100644 index 0000000000000000000000000000000000000000..d8129b9dbf21938ee791cb2caf5bca0caf892da1 --- /dev/null +++ b/test/built-ins/object/values/function-length.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values should have length 1 +es7id: pending +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Object.values.length, 1, 'Expected Object.values.length to be 1'); + +verifyNotEnumerable(Object.values, 'length'); +verifyNotWritable(Object.values, 'length'); +verifyConfigurable(Object.values, 'length'); diff --git a/test/built-ins/object/values/function-name.js b/test/built-ins/object/values/function-name.js new file mode 100644 index 0000000000000000000000000000000000000000..388f91d2205a9be12ca05a27d9655cf1d5ea617c --- /dev/null +++ b/test/built-ins/object/values/function-name.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values should have name property with value 'values' +es7id: pending +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Object.values.name, + 'values', + 'Expected Object.values.name to be "values"' +); + +verifyNotEnumerable(Object.values, 'name'); +verifyNotWritable(Object.values, 'name'); +verifyConfigurable(Object.values, 'name'); diff --git a/test/built-ins/object/values/function-property-descriptor.js b/test/built-ins/object/values/function-property-descriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..c6d285cc8b7d8ddf020ae1ced094e78d986e8803 --- /dev/null +++ b/test/built-ins/object/values/function-property-descriptor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values should be writable, non-enumerable, and configurable +es7id: pending +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Object, 'values'); +verifyWritable(Object, 'values'); +verifyConfigurable(Object, 'values'); diff --git a/test/built-ins/object/values/getter-adding-key.js b/test/built-ins/object/values/getter-adding-key.js new file mode 100644 index 0000000000000000000000000000000000000000..dfb9752eeb6b7ef5214507fb88a75e95ea971238 --- /dev/null +++ b/test/built-ins/object/values/getter-adding-key.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values does not see a new element added by a getter that is hit during iteration +es7id: pending +author: Jordan Harband +---*/ + +var bAddsC = { + a: 'A', + get b() { + this.c = 'C'; + return 'B'; + } +}; + +var result = Object.values(bAddsC); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(result[0], 'A', 'first value is "A"'); +assert.sameValue(result[1], 'B', 'second value is "B"'); diff --git a/test/built-ins/object/values/getter-making-future-key-nonenumerable.js b/test/built-ins/object/values/getter-making-future-key-nonenumerable.js new file mode 100644 index 0000000000000000000000000000000000000000..5dd452fa4cd4795de9af733634b132f38b318bce --- /dev/null +++ b/test/built-ins/object/values/getter-making-future-key-nonenumerable.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values does not see an element made non-enumerable by a getter that is hit during iteration +es7id: pending +author: Jordan Harband +---*/ + +var bDeletesC = { + a: 'A', + get b() { + Object.defineProperty(this, 'c', { + enumerable: false + }); + return 'B'; + }, + c: 'C' +}; + +var result = Object.values(bDeletesC); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(result[0], 'A', 'first value is "A"'); +assert.sameValue(result[1], 'B', 'second value is "B"'); diff --git a/test/built-ins/object/values/getter-removing-future-key.js b/test/built-ins/object/values/getter-removing-future-key.js new file mode 100644 index 0000000000000000000000000000000000000000..60fd230b5a8e1bbdae6a08c9bac226933633b218 --- /dev/null +++ b/test/built-ins/object/values/getter-removing-future-key.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values does not see an element removed by a getter that is hit during iteration +es7id: pending +author: Jordan Harband +---*/ + +var bDeletesC = { + a: 'A', + get b() { + delete this.c; + return 'B'; + }, + c: 'C' +}; + +var result = Object.values(bDeletesC); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(result[0], 'A', 'first value is "A"'); +assert.sameValue(result[1], 'B', 'second value is "B"'); diff --git a/test/built-ins/object/values/inherited-properties-omitted.js b/test/built-ins/object/values/inherited-properties-omitted.js new file mode 100644 index 0000000000000000000000000000000000000000..c62fc7e6cf41aa212161804d11458d184215218e --- /dev/null +++ b/test/built-ins/object/values/inherited-properties-omitted.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values does not see inherited properties. +es7id: pending +author: Jordan Harband +---*/ + +var F = function G() {}; +F.prototype.a = {}; +F.prototype.b = {}; + +var f = new F(); +f.b = {}; // shadow the prototype +f.c = {}; // solely an own property + +var result = Object.values(f); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 2, 'result has 2 items'); + +assert.sameValue(result[0], f.b, 'first value is f.b'); +assert.sameValue(result[1], f.c, 'second value is f.c'); diff --git a/test/built-ins/object/values/primitive-booleans.js b/test/built-ins/object/values/primitive-booleans.js new file mode 100644 index 0000000000000000000000000000000000000000..83739a584b760f542412bb6f469168153345fc6a --- /dev/null +++ b/test/built-ins/object/values/primitive-booleans.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values accepts boolean primitives. +es7id: pending +author: Jordan Harband +---*/ + +var trueResult = Object.values(true); + +assert.sameValue(Array.isArray(trueResult), true, 'trueResult is an array'); +assert.sameValue(trueResult.length, 0, 'trueResult has 0 items'); + +var falseResult = Object.values(false); + +assert.sameValue(Array.isArray(falseResult), true, 'falseResult is an array'); +assert.sameValue(falseResult.length, 0, 'falseResult has 0 items'); diff --git a/test/built-ins/object/values/primitive-numbers.js b/test/built-ins/object/values/primitive-numbers.js new file mode 100644 index 0000000000000000000000000000000000000000..e7ea45a1a1474f91f3cd05c6a4a1d80765d2e321 --- /dev/null +++ b/test/built-ins/object/values/primitive-numbers.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values accepts number primitives. +es7id: pending +author: Jordan Harband +---*/ + +assert.sameValue(Object.values(0).length, 0, '0 has zero values'); +assert.sameValue(Object.values(-0).length, 0, '-0 has zero values'); +assert.sameValue(Object.values(Infinity).length, 0, 'Infinity has zero values'); +assert.sameValue(Object.values(-Infinity).length, 0, '-Infinity has zero values'); +assert.sameValue(Object.values(NaN).length, 0, 'NaN has zero values'); +assert.sameValue(Object.values(Math.PI).length, 0, 'Math.PI has zero values'); diff --git a/test/built-ins/object/values/primitive-strings.js b/test/built-ins/object/values/primitive-strings.js new file mode 100644 index 0000000000000000000000000000000000000000..baf0d0cbe0c2c3c599095b3de28f2de782cd2ea7 --- /dev/null +++ b/test/built-ins/object/values/primitive-strings.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values accepts string primitives. +es7id: pending +author: Jordan Harband +---*/ + +var result = Object.values('abc'); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 3, 'result has 3 items'); + +assert.sameValue(result[0], 'a', 'first value is "a"'); +assert.sameValue(result[1], 'b', 'second value is "b"'); +assert.sameValue(result[2], 'c', 'third value is "c"'); diff --git a/test/built-ins/object/values/primitive-symbols.js b/test/built-ins/object/values/primitive-symbols.js new file mode 100644 index 0000000000000000000000000000000000000000..32d74d7b05e1aaa5bb32ff42c0ffbbec55428944 --- /dev/null +++ b/test/built-ins/object/values/primitive-symbols.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values accepts Symbol primitives. +es7id: pending +author: Jordan Harband +features: [Symbol] +---*/ + +var result = Object.values(Symbol()); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 0, 'result has 0 items'); diff --git a/test/built-ins/object/values/symbols-omitted.js b/test/built-ins/object/values/symbols-omitted.js new file mode 100644 index 0000000000000000000000000000000000000000..c698e355f3547f20c4da17c5ea5c4a675cfb7f6e --- /dev/null +++ b/test/built-ins/object/values/symbols-omitted.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.values does not include Symbol keys. +es7id: pending +author: Jordan Harband +features: [Symbol] +---*/ + +var value = {}; +var enumSym = Symbol('enum'); +var nonEnumSym = Symbol('nonenum'); +var symValue = Symbol('value'); + +var obj = { key: symValue }; +obj[enumSym] = value; +Object.defineProperty(obj, nonEnumSym, { enumerable: false, value: value }); + +var result = Object.values(obj); + +assert.sameValue(Array.isArray(result), true, 'result is an array'); +assert.sameValue(result.length, 1, 'result has 1 item'); + +assert.sameValue(result[0], symValue, 'first value is `symValue`'); diff --git a/test/built-ins/object/values/tamper-with-global-object.js b/test/built-ins/object/values/tamper-with-global-object.js new file mode 100644 index 0000000000000000000000000000000000000000..df442fe186ea499da62c3572afa8e73fa494dc6e --- /dev/null +++ b/test/built-ins/object/values/tamper-with-global-object.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object.values should not have its behavior impacted by modifications to the global property Object +es7id: pending +author: Jordan Harband +---*/ + +function fakeObject() { + $ERROR('The overriden version of Object was called!'); +} +fakeObject.values = Object.values; + +var global = Function('return this;')(); +global.Object = fakeObject; + +assert.sameValue(Object, fakeObject, 'Sanity check failed: could not modify the global Object'); +assert.sameValue(Object.values(1).length, 0, 'Expected number primitive to have zero values'); diff --git a/test/built-ins/object/values/tamper-with-object-keys.js b/test/built-ins/object/values/tamper-with-object-keys.js new file mode 100644 index 0000000000000000000000000000000000000000..bf36a1e240f6e092a3e00ca5fa984cb6627ea23b --- /dev/null +++ b/test/built-ins/object/values/tamper-with-object-keys.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Object.values should not have its behavior impacted by modifications to Object.keys +es7id: pending +author: Jordan Harband +---*/ + +function fakeObjectKeys() { + $ERROR('The overriden version of Object.keys was called!'); +} + +Object.keys = fakeObjectKeys; + +assert.sameValue(Object.keys, fakeObjectKeys, 'Sanity check failed: could not modify the global Object.keys'); +assert.sameValue(Object.values({ a: 1 }).length, 1, 'Expected object with 1 key to have 1 value');