diff options
Diffstat (limited to '')
13 files changed, 312 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T1.js new file mode 100644 index 0000000000..704878882a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "valueOf" has { DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.valueOf; +if (x === 1) { + Date.prototype.valueOf = 2; +} else { + Date.prototype.valueOf = 1; +} + +assert.notSameValue( + Date.prototype.valueOf, + x, + 'The value of Date.prototype.valueOf is expected to not equal the value of `x`' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T2.js new file mode 100644 index 0000000000..f19351c81b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "valueOf" has { DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking absence of DontDelete attribute +---*/ + +assert.notSameValue(delete Date.prototype.valueOf, false, 'The value of delete Date.prototype.valueOf is not false'); + +assert( + !Date.prototype.hasOwnProperty('valueOf'), + 'The value of !Date.prototype.hasOwnProperty(\'valueOf\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T3.js new file mode 100644 index 0000000000..e9c3021e81 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "valueOf" has { DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking DontEnum attribute +---*/ +assert( + !Date.prototype.propertyIsEnumerable('valueOf'), + 'The value of !Date.prototype.propertyIsEnumerable(\'valueOf\') is expected to be true' +); + +for (var x in Date.prototype) { + assert.notSameValue(x, "valueOf", 'The value of x is not "valueOf"'); +} + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A2_T1.js new file mode 100644 index 0000000000..1653792cf0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "valueOf" is 0 +esid: sec-date.prototype.valueof +description: The "length" property of the "valueOf" is 0 +---*/ + +assert.sameValue( + Date.prototype.valueOf.hasOwnProperty("length"), + true, + 'Date.prototype.valueOf.hasOwnProperty("length") must return true' +); + +assert.sameValue(Date.prototype.valueOf.length, 0, 'The value of Date.prototype.valueOf.length is expected to be 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T1.js new file mode 100644 index 0000000000..24e84469c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T1.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.valueOf property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.valueOf.length; +verifyNotWritable(Date.prototype.valueOf, "length", null, 1); + +assert.sameValue( + Date.prototype.valueOf.length, + x, + 'The value of Date.prototype.valueOf.length is expected to equal the value of x' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T2.js new file mode 100644 index 0000000000..9cfe3eab54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.valueOf property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking DontDelete attribute +---*/ + +assert.sameValue( + delete Date.prototype.valueOf.length, + true, + 'The value of `delete Date.prototype.valueOf.length` is expected to be true' +); + +assert( + !Date.prototype.valueOf.hasOwnProperty('length'), + 'The value of !Date.prototype.valueOf.hasOwnProperty(\'length\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T3.js new file mode 100644 index 0000000000..5d3dcf9c67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.valueOf property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking DontEnum attribute +---*/ +assert( + !Date.prototype.valueOf.propertyIsEnumerable('length'), + 'The value of !Date.prototype.valueOf.propertyIsEnumerable(\'length\') is expected to be true' +); + +for (var x in Date.prototype.valueOf) { + assert.notSameValue(x, "length", 'The value of x is not "length"'); +} + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T1.js new file mode 100644 index 0000000000..65de790c8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T1.js @@ -0,0 +1,61 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.valueof +info: | + Result of ToInteger(value) conversion is the result of computing + sign(ToNumber(value)) * floor(abs(ToNumber(value))) +es5id: 9.4_A3_T1 +description: For testing constructor Date(Number) is used +---*/ + +// CHECK#1 +var d1 = new Date(6.54321); +assert.sameValue(d1.valueOf(), 6, 'd1.valueOf() must return 6'); + +// CHECK#2 +var d2 = new Date(-6.54321); +assert.sameValue(d2.valueOf(), -6, 'd2.valueOf() must return -6'); + +// CHECK#3 +var d3 = new Date(6.54321e2); +assert.sameValue(d3.valueOf(), 654, 'd3.valueOf() must return 654'); + +// CHECK#4 +var d4 = new Date(-6.54321e2); +assert.sameValue(d4.valueOf(), -654, 'd4.valueOf() must return -654'); + +// CHECK#5 +var d5 = new Date(0.654321e1); +assert.sameValue(d5.valueOf(), 6, 'd5.valueOf() must return 6'); + +// CHECK#6 +var d6 = new Date(-0.654321e1); +assert.sameValue(d6.valueOf(), -6, 'd6.valueOf() must return -6'); + +// CHECK#7 +var d7 = new Date(true); +assert.sameValue(d7.valueOf(), 1, 'd7.valueOf() must return 1'); + +// CHECK#8 +var d8 = new Date(false); +assert.sameValue(d8.valueOf(), 0, 'd8.valueOf() must return 0'); + +// CHECK#9 +var d9 = new Date(1.23e15); +assert.sameValue(d9.valueOf(), 1.23e15, 'd9.valueOf() must return 1.23e15'); + +// CHECK#10 +var d10 = new Date(-1.23e15); +assert.sameValue(d10.valueOf(), -1.23e15, 'd10.valueOf() must return -1.23e15'); + +// CHECK#11 +var d11 = new Date(1.23e-15); +assert.sameValue(d11.valueOf(), 0, 'd11.valueOf() must return 0'); + +// CHECK#12 +var d12 = new Date(-1.23e-15); +assert.sameValue(d12.valueOf(), 0, 'd12.valueOf() must return 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T2.js new file mode 100644 index 0000000000..e1747d60d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T2.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.valueof +info: | + Result of ToInteger(value) conversion is the result of computing + sign(ToNumber(value)) * floor(abs(ToNumber(value))) +es5id: 9.4_A3_T2 +description: > + For testing constructor Date(NaN, Infinity, Infinity, +0 and -0) + is used +---*/ + +// CHECK#1 +var d1 = new Date(Number.NaN); +assert.sameValue(d1.valueOf(), NaN, 'd1.valueOf() returns NaN'); + +// CHECK#2 +var d2 = new Date(Infinity); +assert.sameValue(d2.valueOf(), NaN, 'd2.valueOf() returns NaN'); + +// CHECK#3 +var d3 = new Date(-Infinity); +assert.sameValue(d3.valueOf(), NaN, 'd3.valueOf() returns NaN'); + +// CHECK#4 +var d4 = new Date(0); +assert.sameValue(d4.valueOf(), 0, 'd4.valueOf() must return 0'); + +// CHECK#5 +var d5 = new Date(-0); +assert.sameValue(d5.valueOf(), 0, 'd5.valueOf() must return 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/browser.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js new file mode 100644 index 0000000000..e1e16eb74b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.valueof +description: > + Date.prototype.valueOf.name is "valueOf". +info: | + Date.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.valueOf.name, "valueOf"); + +verifyNotEnumerable(Date.prototype.valueOf, "name"); +verifyNotWritable(Date.prototype.valueOf, "name"); +verifyConfigurable(Date.prototype.valueOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js new file mode 100644 index 0000000000..5e333ff19e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.valueOf does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.valueOf), + false, + 'isConstructor(Date.prototype.valueOf) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.valueOf(); +}, '`let date = new Date(Date.now()); new date.valueOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/shell.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/shell.js |