diff options
author | André Bargull <andre.bargull@gmail.com> | 2015-05-14 17:22:12 +0200 |
---|---|---|
committer | André Bargull <andre.bargull@gmail.com> | 2015-05-18 18:01:00 +0200 |
commit | 56036e4064da981fec3b3bfc7f34e22e684b249b (patch) | |
tree | baf22c328029ac5897d926febc7d85e69cf9d0b1 /test/built-ins/Object | |
parent | b56af07567959c7962f9d639f5791fa5c25b4c08 (diff) | |
download | qtdeclarative-testsuites-56036e4064da981fec3b3bfc7f34e22e684b249b.tar.gz |
Enable strict mode for more built-in tests
- Remove no longer needed noStrict flags.
- Change tests to use propertyHelper.js for strict mode compatibility.
- Add tests for return value of `delete` operator, e.g. `delete Array.prototype === false`.
- Add non-writable tests for global NaN property.
- Split some tests to run in strict mode.
- Change tests with global `var length` declaration to use a different variable name for browser environments.
- Merge duplicated tests symbol-data-property-configurable-non-strict and symbol-data-property-configurable-strict.
- Merge duplicated tests symbol-data-property-writable-non-strict and symbol-data-property-writable-strict.
- (And a small change in propertyHelper to reduce code duplication in function call.)
Diffstat (limited to 'test/built-ins/Object')
12 files changed, 27 insertions, 107 deletions
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 deleted file mode 100644 index 4e8be2295..000000000 --- a/test/built-ins/Object/defineProperty/symbol-data-property-configurable-strict.js +++ /dev/null @@ -1,43 +0,0 @@ -// 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-configurable-non-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-configurable.js index 622f6787c..cac26a733 100644 --- a/test/built-ins/Object/defineProperty/symbol-data-property-configurable-non-strict.js +++ b/test/built-ins/Object/defineProperty/symbol-data-property-configurable.js @@ -4,7 +4,6 @@ es6id: 19.1.2.4 description: > Symbol used as property for configurable data property definition -flags: [noStrict] ---*/ var sym = Symbol(); var obj = {}; 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 deleted file mode 100644 index d76388ad6..000000000 --- a/test/built-ins/Object/defineProperty/symbol-data-property-writable-strict.js +++ /dev/null @@ -1,39 +0,0 @@ -// 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/defineProperty/symbol-data-property-writable-non-strict.js b/test/built-ins/Object/defineProperty/symbol-data-property-writable.js index 5156206a6..69357f0c5 100644 --- a/test/built-ins/Object/defineProperty/symbol-data-property-writable-non-strict.js +++ b/test/built-ins/Object/defineProperty/symbol-data-property-writable.js @@ -4,7 +4,6 @@ es6id: 19.1.2.4 description: > Symbol used as property for writable data property definition -flags: [noStrict] ---*/ var sym = Symbol(); var obj = {}; diff --git a/test/built-ins/Object/prototype/S15.2.3.1_A1.js b/test/built-ins/Object/prototype/S15.2.3.1_A1.js index 21192d107..44b0ea6e6 100644 --- a/test/built-ins/Object/prototype/S15.2.3.1_A1.js +++ b/test/built-ins/Object/prototype/S15.2.3.1_A1.js @@ -5,11 +5,11 @@ info: The Object.prototype property has the attribute ReadOnly es5id: 15.2.3.1_A1 description: Checking if varying "Object.prototype" property fails -flags: [noStrict] +includes: [propertyHelper.js] ---*/ var obj = Object.prototype; -Object.prototype = function(){return "shifted";}; +verifyNotWritable(Object, "prototype", null, function(){return "shifted";}); //CHECK#1 if (Object.prototype !== obj) { @@ -21,5 +21,5 @@ try { Object.prototype(); $ERROR('#2: the Object.prototype property has the attributes ReadOnly'); } catch (e) { - ; + if (e instanceof Test262Error) throw e; } diff --git a/test/built-ins/Object/prototype/S15.2.3.1_A3.js b/test/built-ins/Object/prototype/S15.2.3.1_A3.js index e069f594e..5b7c6e5ea 100644 --- a/test/built-ins/Object/prototype/S15.2.3.1_A3.js +++ b/test/built-ins/Object/prototype/S15.2.3.1_A3.js @@ -4,10 +4,20 @@ /*--- es5id: 15.2.3.1_A3 description: Checking if deleting "Object.prototype" property fails; -flags: [noStrict] +includes: [propertyHelper.js] ---*/ -delete Object.prototype; +verifyNotConfigurable(Object, "prototype"); + +//CHECK#1 +try { + if((delete Object.prototype) !== false){ + $ERROR('#1: Object.prototype has the attribute DontDelete'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} //CHECK#2 if (!(Object.hasOwnProperty('prototype'))) { diff --git a/test/built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A10.js b/test/built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A10.js index 9076d9ae9..5a190b8cb 100644 --- a/test/built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A10.js +++ b/test/built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A10.js @@ -9,8 +9,7 @@ es5id: 15.2.4.5_A10 description: > Checking if varying the Object.prototype.hasOwnProperty.length property fails -flags: [noStrict] -includes: [$FAIL.js] +includes: [$FAIL.js, propertyHelper.js] ---*/ //CHECK#1 @@ -20,7 +19,7 @@ if (!(Object.prototype.hasOwnProperty.hasOwnProperty('length'))) { var obj = Object.prototype.hasOwnProperty.length; -Object.prototype.hasOwnProperty.length = function(){return "shifted";}; +verifyNotWritable(Object.prototype.hasOwnProperty, "length", null, function(){return "shifted";}); //CHECK#2 if (Object.prototype.hasOwnProperty.length !== obj) { diff --git a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A10.js b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A10.js index 6ace571c5..466a70a69 100644 --- a/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A10.js +++ b/test/built-ins/Object/prototype/isPrototypeOf/S15.2.4.6_A10.js @@ -9,8 +9,7 @@ es5id: 15.2.4.6_A10 description: > Checking if varying the Object.prototype.isPrototypeOf.length property fails -flags: [noStrict] -includes: [$FAIL.js] +includes: [$FAIL.js, propertyHelper.js] ---*/ //CHECK#1 @@ -20,7 +19,7 @@ if (!(Object.prototype.isPrototypeOf.hasOwnProperty('length'))) { var obj = Object.prototype.isPrototypeOf.length; -Object.prototype.isPrototypeOf.length = function(){return "shifted";}; +verifyNotWritable(Object.prototype.isPrototypeOf, "length", null, function(){return "shifted";}); //CHECK#2 if (Object.prototype.isPrototypeOf.length !== obj) { diff --git a/test/built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A10.js b/test/built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A10.js index 876a17131..4aa9a16b6 100644 --- a/test/built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A10.js +++ b/test/built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A10.js @@ -9,8 +9,7 @@ es5id: 15.2.4.7_A10 description: > Checking if varying the Object.prototype.propertyIsEnumerable.length property fails -flags: [noStrict] -includes: [$FAIL.js] +includes: [$FAIL.js, propertyHelper.js] ---*/ //CHECK#1 @@ -20,7 +19,7 @@ if (!(Object.prototype.propertyIsEnumerable.hasOwnProperty('length'))) { var obj = Object.prototype.propertyIsEnumerable.length; -Object.prototype.propertyIsEnumerable.length = function(){return "shifted";}; +verifyNotWritable(Object.prototype.propertyIsEnumerable, "length", null, function(){return "shifted";}); //CHECK#2 if (Object.prototype.propertyIsEnumerable.length !== obj) { diff --git a/test/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A10.js b/test/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A10.js index c71880656..f77571101 100644 --- a/test/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A10.js +++ b/test/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A10.js @@ -9,8 +9,7 @@ es5id: 15.2.4.3_A10 description: > Checking if varying the Object.prototype.toLocaleString.length property fails -flags: [noStrict] -includes: [$FAIL.js] +includes: [$FAIL.js, propertyHelper.js] ---*/ //CHECK#1 @@ -20,7 +19,7 @@ if (!(Object.prototype.toLocaleString.hasOwnProperty('length'))) { var obj = Object.prototype.toLocaleString.length; -Object.prototype.toLocaleString.length = function(){return "shifted";}; +verifyNotWritable(Object.prototype.toLocaleString, "length", null, function(){return "shifted";}); //CHECK#2 if (Object.prototype.toLocaleString.length !== obj) { diff --git a/test/built-ins/Object/prototype/toString/S15.2.4.2_A10.js b/test/built-ins/Object/prototype/toString/S15.2.4.2_A10.js index a97f7f79d..887915b20 100644 --- a/test/built-ins/Object/prototype/toString/S15.2.4.2_A10.js +++ b/test/built-ins/Object/prototype/toString/S15.2.4.2_A10.js @@ -7,8 +7,7 @@ es5id: 15.2.4.2_A10 description: > Checking if varying the Object.prototype.toString.length property fails -flags: [noStrict] -includes: [$FAIL.js] +includes: [$FAIL.js, propertyHelper.js] ---*/ //CHECK#1 @@ -18,7 +17,7 @@ if (!(Object.prototype.toString.hasOwnProperty('length'))) { var obj = Object.prototype.toString.length; -Object.prototype.toString.length = function(){return "shifted";}; +verifyNotWritable(Object.prototype.toString, "length", null, function(){return "shifted";}); //CHECK#2 if (Object.prototype.toString.length !== obj) { diff --git a/test/built-ins/Object/prototype/valueOf/S15.2.4.4_A10.js b/test/built-ins/Object/prototype/valueOf/S15.2.4.4_A10.js index 878ecf265..734343a08 100644 --- a/test/built-ins/Object/prototype/valueOf/S15.2.4.4_A10.js +++ b/test/built-ins/Object/prototype/valueOf/S15.2.4.4_A10.js @@ -7,8 +7,7 @@ es5id: 15.2.4.4_A10 description: > Checking if varying the Object.prototype.valueOf.length property fails -flags: [noStrict] -includes: [$FAIL.js] +includes: [$FAIL.js, propertyHelper.js] ---*/ //CHECK#1 @@ -18,7 +17,7 @@ if (!(Object.prototype.valueOf.hasOwnProperty('length'))) { var obj = Object.prototype.valueOf.length; -Object.prototype.valueOf.length = function(){return "shifted";}; +verifyNotWritable(Object.prototype.valueOf, "length", null, function(){return "shifted";}); //CHECK#2 if (Object.prototype.valueOf.length !== obj) { |