diff --git a/test/annexB/built-ins/Date/prototype/getYear/B.2.4.propertyCheck.js b/test/annexB/built-ins/Date/prototype/getYear/B.2.4.propertyCheck.js deleted file mode 100644 index 38223ba3d0..0000000000 --- a/test/annexB/built-ins/Date/prototype/getYear/B.2.4.propertyCheck.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Check type of various properties -es5id: B.2.4 -description: Checking properties of the Date object (getYear) ----*/ - -if (typeof Date.prototype.getYear !== "function") $ERROR('#1: typeof Date.prototype.getYear === "function". Actual: ' + (typeof Date.prototype.getYear )); -if (typeof Date.prototype['getYear'] !== "function") $ERROR('#2: typeof Date.prototype["getYear"] === "function". Actual: ' + (typeof Date.prototype["getYear"] )); diff --git a/test/annexB/built-ins/Date/prototype/getYear/nan.js b/test/annexB/built-ins/Date/prototype/getYear/nan.js new file mode 100644 index 0000000000..1d4db853b3 --- /dev/null +++ b/test/annexB/built-ins/Date/prototype/getYear/nan.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getyear +es6id: B.2.4.1 +es5id: B.2.4 +description: NaN time value +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +var date = new Date({}); + +assert.sameValue(date.getYear(), NaN); diff --git a/test/annexB/built-ins/Date/prototype/getYear/return-value.js b/test/annexB/built-ins/Date/prototype/getYear/return-value.js new file mode 100644 index 0000000000..f379bab10c --- /dev/null +++ b/test/annexB/built-ins/Date/prototype/getYear/return-value.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getyear +es6id: B.2.4.1 +es5id: B.2.4 +description: > + Return value for objects with numeric value in [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)) - 1900. +---*/ + +assert.sameValue(new Date(1899, 0).getYear(), -1, '1899: first millisecond'); +assert.sameValue( + new Date(1899, 11, 31, 23, 59, 59, 999).getYear(), + -1, + '1899: final millisecond' +); + +assert.sameValue(new Date(1900, 0).getYear(), 0, '1900: first millisecond'); +assert.sameValue( + new Date(1900, 11, 31, 23, 59, 59, 999).getYear(), + 0, + '1900: final millisecond' +); + +assert.sameValue(new Date(1970, 0).getYear(), 70, '1970: first millisecond'); +assert.sameValue( + new Date(1970, 11, 31, 23, 59, 59, 999).getYear(), + 70, + '1970: final millisecond' +); + +assert.sameValue(new Date(2000, 0).getYear(), 100, '2000: first millisecond'); +assert.sameValue( + new Date(2000, 11, 31, 23, 59, 59, 999).getYear(), + 100, + '2000: final millisecond' +); diff --git a/test/annexB/built-ins/Date/prototype/getYear/this-not-date.js b/test/annexB/built-ins/Date/prototype/getYear/this-not-date.js new file mode 100644 index 0000000000..86f9a652dd --- /dev/null +++ b/test/annexB/built-ins/Date/prototype/getYear/this-not-date.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getyear +es6id: B.2.4.1 +es5id: B.2.4 +description: Behavior when `this` value has no [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). +---*/ + +var getYear = Date.prototype.getYear; + +assert.sameValue(typeof getYear, 'function'); + +assert.throws(TypeError, function() { + getYear.call({}); +}, 'object'); + +assert.throws(TypeError, function() { + getYear.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getYear.call(null); +}, 'null');