diff options
author | André Bargull <andre.bargull@gmail.com> | 2015-08-06 17:50:08 +0200 |
---|---|---|
committer | André Bargull <andre.bargull@gmail.com> | 2015-09-07 17:25:55 +0200 |
commit | df9bf58204c21f7b1bfb0a13a73226949fbe1fed (patch) | |
tree | d28fc2f40a0f5e939e4b7135d37f10af53aecb89 /test/built-ins/Object | |
parent | 03d2f68c9c185970a9b7cee5806e8733188db360 (diff) | |
download | qtdeclarative-testsuites-df9bf58204c21f7b1bfb0a13a73226949fbe1fed.tar.gz |
Tests for changes introduced in ES2015 (Annex E)
- String case functions iterate over code points
- Has called before Get in Array.p.reverse
- Add test for web-compat Array.p.splice behaviour; Plus missing test for no arguments case
- ToObject no longer applied to this-value in Array.p.toLocaleString
- ToObject no longer applied to this-value in Object.p.toLocaleString
- Add tests for Object.p.propertyIsEnumerable and symbol property keys
- Add tests for Object.p.hasOwnProperty and symbol property keys
- Test property descriptor attributes of message property
- Tests for RegExp constructor checks
- Date constructor when called with date object
- TimeClip never returns negative zero
Diffstat (limited to 'test/built-ins/Object')
10 files changed, 315 insertions, 0 deletions
diff --git a/test/built-ins/Object/prototype/hasOwnProperty/symbol_own_property.js b/test/built-ins/Object/prototype/hasOwnProperty/symbol_own_property.js new file mode 100755 index 000000000..f69cc1beb --- /dev/null +++ b/test/built-ins/Object/prototype/hasOwnProperty/symbol_own_property.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.hasOwnProperty called with symbol property key +info: > + 19.1.3.2 Object.prototype.hasOwnProperty ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.2 +---*/ + +var obj = {}; +var sym = Symbol(); + +assert.sameValue( + obj.hasOwnProperty(sym), + false, + "Returns false if symbol own property not found" +); + +obj[sym] = 0; + +assert.sameValue( + obj.hasOwnProperty(sym), + true, + "Returns true if symbol own property found" +); diff --git a/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_toPrimitive.js b/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_toPrimitive.js new file mode 100755 index 000000000..fa8d2ce15 --- /dev/null +++ b/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_toPrimitive.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.hasOwnProperty with symbol and @@toPrimitive conversion +info: > + 19.1.3.2 Object.prototype.hasOwnProperty ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.2 +features: [Symbol.toPrimitive] +---*/ + +var obj = {}; +var sym = Symbol(); + +var callCount = 0; +var wrapper = {}; +wrapper[Symbol.toPrimitive] = function() { + callCount += 1; + return sym; +}; + +obj[sym] = 0; + +assert.sameValue( + obj.hasOwnProperty(wrapper), + true, + "Returns true if symbol own property found" +); + +assert.sameValue(callCount, 1, "toPrimitive method called exactly once"); diff --git a/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_toString.js b/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_toString.js new file mode 100755 index 000000000..0f52fb72f --- /dev/null +++ b/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_toString.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.hasOwnProperty with symbol and toString conversion +info: > + 19.1.3.2 Object.prototype.hasOwnProperty ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.2 +---*/ + +var obj = {}; +var sym = Symbol(); + +var callCount = 0; +var wrapper = { + toString: function() { + callCount += 1; + return sym; + }, + valueOf: function() { + $ERROR("valueOf() called"); + } +}; + +obj[sym] = 0; + +assert.sameValue( + obj.hasOwnProperty(wrapper), + true, + "Returns true if symbol own property found" +); + +assert.sameValue(callCount, 1, "toString method called exactly once"); diff --git a/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_valueOf.js b/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_valueOf.js new file mode 100755 index 000000000..772fa4f15 --- /dev/null +++ b/test/built-ins/Object/prototype/hasOwnProperty/symbol_property_valueOf.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.hasOwnProperty with symbol and valueOf conversion +info: > + 19.1.3.2 Object.prototype.hasOwnProperty ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.2 +---*/ + +var obj = {}; +var sym = Symbol(); + +var callCount = 0; +var wrapper = { + valueOf: function() { + callCount += 1; + return sym; + }, + toString: null +}; + +obj[sym] = 0; + +assert.sameValue( + obj.hasOwnProperty(wrapper), + true, + "Returns true if symbol own property found" +); + +assert.sameValue(callCount, 1, "valueOf method called exactly once"); diff --git a/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_own_property.js b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_own_property.js new file mode 100755 index 000000000..201f951b1 --- /dev/null +++ b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_own_property.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.propertyIsEnumerable called with symbol property key +info: > + 19.1.3.4 Object.prototype.propertyIsEnumerable ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.4 +---*/ + +var obj = {}; +var sym = Symbol(); + +assert.sameValue( + obj.propertyIsEnumerable(sym), + false, + "Returns false if symbol own property not found" +); + +obj[sym] = 0; + +assert.sameValue( + obj.propertyIsEnumerable(sym), + true, + "Returns true if symbol own enumerable property found" +); diff --git a/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_toPrimitive.js b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_toPrimitive.js new file mode 100755 index 000000000..63f0e4d86 --- /dev/null +++ b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_toPrimitive.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.propertyIsEnumerable with symbol and @@toPrimitive conversion +info: > + 19.1.3.4 Object.prototype.propertyIsEnumerable ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.4 +features: [Symbol.toPrimitive] +---*/ + +var obj = {}; +var sym = Symbol(); + +var callCount = 0; +var wrapper = {}; +wrapper[Symbol.toPrimitive] = function() { + callCount += 1; + return sym; +}; + +obj[sym] = 0; + +assert.sameValue( + obj.propertyIsEnumerable(wrapper), + true, + "Returns true if symbol own enumerable property found" +); + +assert.sameValue(callCount, 1, "toPrimitive method called exactly once"); diff --git a/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_toString.js b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_toString.js new file mode 100755 index 000000000..945f5d1f3 --- /dev/null +++ b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_toString.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.propertyIsEnumerable with symbol and toString conversion +info: > + 19.1.3.4 Object.prototype.propertyIsEnumerable ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.4 +---*/ + +var obj = {}; +var sym = Symbol(); + +var callCount = 0; +var wrapper = { + toString: function() { + callCount += 1; + return sym; + }, + valueOf: function() { + $ERROR("valueOf() called"); + } +}; + +obj[sym] = 0; + +assert.sameValue( + obj.propertyIsEnumerable(wrapper), + true, + "Returns true if symbol own enumerable property found" +); + +assert.sameValue(callCount, 1, "toString method called exactly once"); diff --git a/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_valueOf.js b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_valueOf.js new file mode 100755 index 000000000..89397e7e3 --- /dev/null +++ b/test/built-ins/Object/prototype/propertyIsEnumerable/symbol_property_valueOf.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.propertyIsEnumerable with symbol and valueOf conversion +info: > + 19.1.3.4 Object.prototype.propertyIsEnumerable ( V ) + + 1. Let P be ToPropertyKey(V). + 2. ReturnIfAbrupt(P). + ... +es6id: 19.1.3.4 +---*/ + +var obj = {}; +var sym = Symbol(); + +var callCount = 0; +var wrapper = { + valueOf: function() { + callCount += 1; + return sym; + }, + toString: null +}; + +obj[sym] = 0; + +assert.sameValue( + obj.propertyIsEnumerable(wrapper), + true, + "Returns true if symbol own enumerable property found" +); + +assert.sameValue(callCount, 1, "valueOf method called exactly once"); diff --git a/test/built-ins/Object/prototype/toLocaleString/primitive_this_value.js b/test/built-ins/Object/prototype/toLocaleString/primitive_this_value.js new file mode 100755 index 000000000..7ca356cc3 --- /dev/null +++ b/test/built-ins/Object/prototype/toLocaleString/primitive_this_value.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.toLocaleString called with primitive thisValue +info: > + 19.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 2. Return Invoke(O, "toString"). +es6id: 19.1.3.5 +flags: [onlyStrict] +---*/ + +Boolean.prototype.toString = function() { + return typeof this; +}; + +assert.sameValue(true.toLocaleString(), "boolean"); diff --git a/test/built-ins/Object/prototype/toLocaleString/primitive_this_value_getter.js b/test/built-ins/Object/prototype/toLocaleString/primitive_this_value_getter.js new file mode 100755 index 000000000..0b5034798 --- /dev/null +++ b/test/built-ins/Object/prototype/toLocaleString/primitive_this_value_getter.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.prototype.toLocaleString called with primitive thisValue in getter +info: > + 19.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 2. Return Invoke(O, "toString"). +es6id: 19.1.3.5 +flags: [onlyStrict] +---*/ + +Object.defineProperty(Boolean.prototype, "toString", { + get: function() { + var v = typeof this; + return function() { + return v; + }; + } +}); + +assert.sameValue(true.toLocaleString(), "boolean"); |