Add tests for Date.prototype methods

This commit is contained in:
Mike Pennisi 2016-07-09 12:18:24 -04:00
parent 8918e860cc
commit acebbcaeb2
153 changed files with 6129 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// 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.getdate
es6id: 20.3.4.2
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getDate(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getdate
es6id: 20.3.4.2
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getDate = Date.prototype.getDate;
var args = (function() { return arguments; }());
assert.sameValue(typeof getDate, 'function');
assert.throws(TypeError, function() {
getDate.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getDate.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getDate.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getdate
es6id: 20.3.4.2
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getDate = Date.prototype.getDate;
var symbol = Symbol();
assert.sameValue(typeof getDate, 'function');
assert.throws(TypeError, function() {
getDate.call(0);
}, 'number');
assert.throws(TypeError, function() {
getDate.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getDate.call(null);
}, 'null');
assert.throws(TypeError, function() {
getDate.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getDate.call('');
}, 'string');
assert.throws(TypeError, function() {
getDate.call(symbol);
}, 'symbol');

View File

@ -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.getdate
es6id: 20.3.4.2
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return DateFromTime(LocalTime(t)).
---*/
assert.sameValue(new Date(2016, 6, 6).getDate(), 6, 'first millisecond');
assert.sameValue(
new Date(2016, 6, 6, 0, 0, 0, -1).getDate(), 5, 'previous millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 999).getDate(), 6, 'final millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 1000).getDate(), 7, 'subsequent millisecond'
);
assert.sameValue(
new Date(2016, 1, 29).getDate(), 29, 'first millisecond (month boundary)'
);
assert.sameValue(
new Date(2016, 1, 29, 0, 0, 0, -1).getDate(),
28,
'previous millisecond (month boundary)'
);
assert.sameValue(
new Date(2016, 1, 29, 23, 59, 59, 999).getDate(),
29,
'final millisecond (month boundary)'
);
assert.sameValue(
new Date(2016, 1, 29, 23, 59, 59, 1000).getDate(),
1,
'subsequent millisecond (month boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getday
es6id: 20.3.4.3
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getDay(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getday
es6id: 20.3.4.3
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getDay = Date.prototype.getDay;
var args = (function() { return arguments; }());
assert.sameValue(typeof getDay, 'function');
assert.throws(TypeError, function() {
getDay.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getDay.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getDay.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getday
es6id: 20.3.4.3
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getDay = Date.prototype.getDay;
var symbol = Symbol();
assert.sameValue(typeof getDay, 'function');
assert.throws(TypeError, function() {
getDay.call(0);
}, 'number');
assert.throws(TypeError, function() {
getDay.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getDay.call(null);
}, 'null');
assert.throws(TypeError, function() {
getDay.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getDay.call('');
}, 'string');
assert.throws(TypeError, function() {
getDay.call(symbol);
}, 'symbol');

View File

@ -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.getday
es6id: 20.3.4.3
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return WeekDay(LocalTime(t)).
---*/
assert.sameValue(new Date(2016, 6, 6).getDay(), 3, 'first millisecond');
assert.sameValue(
new Date(2016, 6, 6, 0, 0, 0, -1).getDay(), 2, 'previous millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 999).getDay(), 3, 'final millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 1000).getDay(), 4, 'subsequent millisecond'
);
assert.sameValue(
new Date(2016, 6, 9).getDay(), 6, 'first millisecond (week boundary)'
);
assert.sameValue(
new Date(2016, 6, 9, 0, 0, 0, -1).getDay(),
5,
'previous millisecond (week boundary)'
);
assert.sameValue(
new Date(2016, 6, 9, 23, 59, 59, 999).getDay(),
6,
'final millisecond (week boundary)'
);
assert.sameValue(
new Date(2016, 6, 9, 23, 59, 59, 1000).getDay(),
0,
'subsequent millisecond (week boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getfullyear
es6id: 20.3.4.4
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getFullYear(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getfullyear
es6id: 20.3.4.4
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getFullYear = Date.prototype.getFullYear;
var args = (function() { return arguments; }());
assert.sameValue(typeof getFullYear, 'function');
assert.throws(TypeError, function() {
getFullYear.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getFullYear.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getFullYear.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getfullyear
es6id: 20.3.4.4
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getFullYear = Date.prototype.getFullYear;
var symbol = Symbol();
assert.sameValue(typeof getFullYear, 'function');
assert.throws(TypeError, function() {
getFullYear.call(0);
}, 'number');
assert.throws(TypeError, function() {
getFullYear.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getFullYear.call(null);
}, 'null');
assert.throws(TypeError, function() {
getFullYear.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getFullYear.call('');
}, 'string');
assert.throws(TypeError, function() {
getFullYear.call(symbol);
}, 'symbol');

View File

@ -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.getfullyear
es6id: 20.3.4.4
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return YearFromTime(LocalTime(t)).
---*/
assert.sameValue(new Date(2016, 0).getFullYear(), 2016, 'first millisecond');
assert.sameValue(
new Date(2016, 0, 1, 0, 0, 0, -1).getFullYear(), 2015, 'previous millisecond'
);
assert.sameValue(
new Date(2016, 11, 31, 23, 59, 59, 999).getFullYear(),
2016,
'final millisecond'
);
assert.sameValue(
new Date(2016, 11, 31, 23, 59, 59, 1000).getFullYear(),
2017,
'subsequent millisecond'
);

View File

@ -0,0 +1,12 @@
// 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.gethours
es6id: 20.3.4.5
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getHours(), NaN);

View File

@ -0,0 +1,33 @@
// 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.gethours
es6id: 20.3.4.5
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getHours = Date.prototype.getHours;
var args = (function() { return arguments; }());
assert.sameValue(typeof getHours, 'function');
assert.throws(TypeError, function() {
getHours.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getHours.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getHours.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.gethours
es6id: 20.3.4.5
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getHours = Date.prototype.getHours;
var symbol = Symbol();
assert.sameValue(typeof getHours, 'function');
assert.throws(TypeError, function() {
getHours.call(0);
}, 'number');
assert.throws(TypeError, function() {
getHours.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getHours.call(null);
}, 'null');
assert.throws(TypeError, function() {
getHours.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getHours.call('');
}, 'string');
assert.throws(TypeError, function() {
getHours.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,45 @@
// 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.gethours
es6id: 20.3.4.5
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return HourFromTime(LocalTime(t)).
---*/
assert.sameValue(new Date(2016, 6, 6, 13).getHours(), 13, 'first millisecond');
assert.sameValue(
new Date(2016, 6, 6, 13, 0, 0, -1).getHours(), 12, 'previous millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 13, 59, 59, 999).getHours(),
13,
'final millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 13, 59, 59, 1000).getHours(),
14,
'subsequent millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 23).getHours(), 23, 'first millisecond (hour boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 0, 0, -1).getHours(),
22,
'previous millisecond (hour boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 999).getHours(),
23,
'final millisecond (hour boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 1000).getHours(),
0,
'subsequent millisecond (hour boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getmilliseconds
es6id: 20.3.4.6
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getMilliseconds(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getmilliseconds
es6id: 20.3.4.6
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getMilliseconds = Date.prototype.getMilliseconds;
var args = (function() { return arguments; }());
assert.sameValue(typeof getMilliseconds, 'function');
assert.throws(TypeError, function() {
getMilliseconds.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getMilliseconds.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getMilliseconds.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getmilliseconds
es6id: 20.3.4.6
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getMilliseconds = Date.prototype.getMilliseconds;
var symbol = Symbol();
assert.sameValue(typeof getMilliseconds, 'function');
assert.throws(TypeError, function() {
getMilliseconds.call(0);
}, 'number');
assert.throws(TypeError, function() {
getMilliseconds.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getMilliseconds.call(null);
}, 'null');
assert.throws(TypeError, function() {
getMilliseconds.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getMilliseconds.call('');
}, 'string');
assert.throws(TypeError, function() {
getMilliseconds.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,30 @@
// 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.getmilliseconds
es6id: 20.3.4.6
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return msFromTime(LocalTime(t)).
---*/
assert.sameValue(
new Date(2016, 6, 6).getMilliseconds(), 0, 'first millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 0, 0, 0, -1).getMilliseconds(),
999,
'previous millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 999).getMilliseconds(),
999,
'final millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 23, 59, 59, 1000).getMilliseconds(),
0,
'subsequent millisecond'
);

View File

@ -0,0 +1,12 @@
// 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.getminutes
es6id: 20.3.4.7
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getMinutes(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getminutes
es6id: 20.3.4.7
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getMinutes = Date.prototype.getMinutes;
var args = (function() { return arguments; }());
assert.sameValue(typeof getMinutes, 'function');
assert.throws(TypeError, function() {
getMinutes.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getMinutes.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getMinutes.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getminutes
es6id: 20.3.4.7
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getMinutes = Date.prototype.getMinutes;
var symbol = Symbol();
assert.sameValue(typeof getMinutes, 'function');
assert.throws(TypeError, function() {
getMinutes.call(0);
}, 'number');
assert.throws(TypeError, function() {
getMinutes.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getMinutes.call(null);
}, 'null');
assert.throws(TypeError, function() {
getMinutes.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getMinutes.call('');
}, 'string');
assert.throws(TypeError, function() {
getMinutes.call(symbol);
}, 'symbol');

View File

@ -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.getminutes
es6id: 20.3.4.7
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return MinFromTime(LocalTime(t)).
---*/
assert.sameValue(new Date(2016, 6, 6, 14, 6).getMinutes(), 6, 'first millisecond');
assert.sameValue(
new Date(2016, 6, 6, 14, 6, 0, -1).getMinutes(), 5, 'previous millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 6, 59, 999).getMinutes(), 6, 'final millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 6, 59, 1000).getMinutes(), 7, 'subsequent millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 59).getMinutes(), 59, 'first millisecond (hour boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 59, 0, -1).getMinutes(),
58,
'previous millisecond (hour boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 59, 59, 999).getMinutes(),
59,
'final millisecond (hour boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 59, 59, 1000).getMinutes(),
0,
'subsequent millisecond (hour boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getmonth
es6id: 20.3.4.8
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getMonth(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getmonth
es6id: 20.3.4.8
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getMonth = Date.prototype.getMonth;
var args = (function() { return arguments; }());
assert.sameValue(typeof getMonth, 'function');
assert.throws(TypeError, function() {
getMonth.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getMonth.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getMonth.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getmonth
es6id: 20.3.4.8
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getMonth = Date.prototype.getMonth;
var symbol = Symbol();
assert.sameValue(typeof getMonth, 'function');
assert.throws(TypeError, function() {
getMonth.call(0);
}, 'number');
assert.throws(TypeError, function() {
getMonth.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getMonth.call(null);
}, 'null');
assert.throws(TypeError, function() {
getMonth.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getMonth.call('');
}, 'string');
assert.throws(TypeError, function() {
getMonth.call(symbol);
}, 'symbol');

View File

@ -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.getmonth
es6id: 20.3.4.8
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return MonthFromTime(LocalTime(t)).
---*/
assert.sameValue(new Date(2016, 6).getMonth(), 6, 'first millisecond');
assert.sameValue(
new Date(2016, 6, 0, 0, 0, 0, -1).getMonth(), 5, 'previous millisecond'
);
assert.sameValue(
new Date(2016, 6, 31, 23, 59, 59, 999).getMonth(), 6, 'final millisecond'
);
assert.sameValue(
new Date(2016, 6, 31, 23, 59, 59, 1000).getMonth(), 7, 'subsequent millisecond'
);
assert.sameValue(
new Date(2016, 11, 31).getMonth(), 11, 'first millisecond (year boundary)'
);
assert.sameValue(
new Date(2016, 11, 0, 0, 0, 0, -1).getMonth(),
10,
'previous millisecond (year boundary)'
);
assert.sameValue(
new Date(2016, 11, 31, 23, 59, 59, 999).getMonth(),
11,
'final millisecond (year boundary)'
);
assert.sameValue(
new Date(2016, 11, 31, 23, 59, 59, 1000).getMonth(),
0,
'subsequent millisecond (year boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getseconds
es6id: 20.3.4.9
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getSeconds(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getseconds
es6id: 20.3.4.9
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getSeconds = Date.prototype.getSeconds;
var args = (function() { return arguments; }());
assert.sameValue(typeof getSeconds, 'function');
assert.throws(TypeError, function() {
getSeconds.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getSeconds.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getSeconds.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getseconds
es6id: 20.3.4.9
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getSeconds = Date.prototype.getSeconds;
var symbol = Symbol();
assert.sameValue(typeof getSeconds, 'function');
assert.throws(TypeError, function() {
getSeconds.call(0);
}, 'number');
assert.throws(TypeError, function() {
getSeconds.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getSeconds.call(null);
}, 'null');
assert.throws(TypeError, function() {
getSeconds.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getSeconds.call('');
}, 'string');
assert.throws(TypeError, function() {
getSeconds.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,49 @@
// 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.getseconds
es6id: 20.3.4.9
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return SecFromTime(LocalTime(t)).
---*/
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 30).getSeconds(),
30,
'first millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 30, -1).getSeconds(), 29, 'previous millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 30, 999).getSeconds(), 30, 'final millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 30, 1000).getSeconds(),
31,
'subsequent millisecond'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 59).getSeconds(),
59,
'first millisecond (minute boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 59, -1).getSeconds(),
58,
'previous millisecond (minute boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 59, 999).getSeconds(),
59,
'final millisecond (minute boundary)'
);
assert.sameValue(
new Date(2016, 6, 6, 14, 16, 59, 1000).getSeconds(),
0,
'subsequent millisecond (minute boundary)'
);

View File

@ -0,0 +1,11 @@
// 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.gettime
es6id: 20.3.4.10
description: Return value for invalid date
info: |
1. Return ? thisTimeValue(this value).
---*/
assert.sameValue(new Date(NaN).getTime(), NaN);

View File

@ -0,0 +1,33 @@
// 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.gettime
es6id: 20.3.4.10
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Return ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getTime = Date.prototype.getTime;
var args = (function() { return arguments; }());
assert.sameValue(typeof getTime, 'function');
assert.throws(TypeError, function() {
getTime.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getTime.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getTime.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.gettime
es6id: 20.3.4.10
description: Behavior when "this" value is not an Object
info: |
1. Return ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getTime = Date.prototype.getTime;
var symbol = Symbol();
assert.sameValue(typeof getTime, 'function');
assert.throws(TypeError, function() {
getTime.call(0);
}, 'number');
assert.throws(TypeError, function() {
getTime.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getTime.call(null);
}, 'null');
assert.throws(TypeError, function() {
getTime.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getTime.call('');
}, 'string');
assert.throws(TypeError, function() {
getTime.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,16 @@
// 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.gettime
es6id: 20.3.4.10
description: Return value for valid dates
info: |
1. Return ? thisTimeValue(this value).
---*/
assert.sameValue(new Date(0).getTime(), 0, '+0');
assert.sameValue(new Date(-0).getTime(), 0, '-0');
assert.sameValue(new Date(-1).getTime(), -1);
assert.sameValue(new Date(1).getTime(), 1);
assert.sameValue(new Date(8640000000000000).getTime(), 8640000000000000);
assert.sameValue(new Date(-8640000000000000).getTime(), -8640000000000000);

View File

@ -0,0 +1,12 @@
// 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.gettimezoneoffset
es6id: 20.3.4.11
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getTimezoneOffset(), NaN);

View File

@ -0,0 +1,33 @@
// 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.gettimezoneoffset
es6id: 20.3.4.11
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getTimezoneOffset = Date.prototype.getTimezoneOffset;
var args = (function() { return arguments; }());
assert.sameValue(typeof getTimezoneOffset, 'function');
assert.throws(TypeError, function() {
getTimezoneOffset.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getTimezoneOffset.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getTimezoneOffset.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.gettimezoneoffset
es6id: 20.3.4.11
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getTimezoneOffset = Date.prototype.getTimezoneOffset;
var symbol = Symbol();
assert.sameValue(typeof getTimezoneOffset, 'function');
assert.throws(TypeError, function() {
getTimezoneOffset.call(0);
}, 'number');
assert.throws(TypeError, function() {
getTimezoneOffset.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getTimezoneOffset.call(null);
}, 'null');
assert.throws(TypeError, function() {
getTimezoneOffset.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getTimezoneOffset.call('');
}, 'string');
assert.throws(TypeError, function() {
getTimezoneOffset.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,31 @@
// 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.gettimezoneoffset
es6id: 20.3.4.11
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return (t - LocalTime(t)) / msPerMinute.
---*/
assert.sameValue(
typeof new Date(0).getTimezoneOffset(), 'number', 'Unix epoch'
);
assert.sameValue(
typeof new Date(8640000000000000).getTimezoneOffset(),
'number',
'latest representable time'
);
assert.sameValue(
typeof new Date(-8640000000000000).getTimezoneOffset(),
'number',
'earliest representable time'
);
assert.sameValue(
typeof new Date().getTimezoneOffset(), 'number', 'current time'
);

View File

@ -0,0 +1,12 @@
// 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.getutcdate
es6id: 20.3.4.12
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCDate(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutcdate
es6id: 20.3.4.12
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCDate = Date.prototype.getUTCDate;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCDate, 'function');
assert.throws(TypeError, function() {
getUTCDate.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCDate.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCDate.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutcdate
es6id: 20.3.4.12
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCDate = Date.prototype.getUTCDate;
var symbol = Symbol();
assert.sameValue(typeof getUTCDate, 'function');
assert.throws(TypeError, function() {
getUTCDate.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCDate.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCDate.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCDate.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCDate.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCDate.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,43 @@
// 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.getutcdate
es6id: 20.3.4.12
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return DateFromTime(t).
---*/
var july6 = 1467763200000;
var feb29 = 1456704000000;
var dayMs = 24 * 60 * 60 * 1000;
assert.sameValue(new Date(july6).getUTCDate(), 6, 'first millisecond');
assert.sameValue(
new Date(july6 - 1).getUTCDate(), 5, 'previous millisecond'
);
assert.sameValue(
new Date(july6 + dayMs - 1).getUTCDate(), 6, 'final millisecond'
);
assert.sameValue(
new Date(july6 + dayMs).getUTCDate(), 7, 'subsequent millisecond'
);
assert.sameValue(
new Date(feb29).getUTCDate(), 29, 'first millisecond (month boundary)'
);
assert.sameValue(
new Date(feb29 - 1).getUTCDate(), 28, 'previous millisecond (month boundary)'
);
assert.sameValue(
new Date(feb29 + dayMs - 1).getUTCDate(),
29,
'final millisecond (month boundary)'
);
assert.sameValue(
new Date(feb29 + dayMs).getUTCDate(),
1,
'subsequent millisecond (month boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getutcday
es6id: 20.3.4.13
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCDay(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutcday
es6id: 20.3.4.13
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCDay = Date.prototype.getUTCDay;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCDay, 'function');
assert.throws(TypeError, function() {
getUTCDay.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCDay.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCDay.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutcdaty
es6id: 20.3.4.13
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCDay = Date.prototype.getUTCDay;
var symbol = Symbol();
assert.sameValue(typeof getUTCDay, 'function');
assert.throws(TypeError, function() {
getUTCDay.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCDay.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCDay.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCDay.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCDay.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCDay.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,43 @@
// 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.getutcday
es6id: 20.3.4.13
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return WeekDay(t).
---*/
var july6 = 1467763200000;
var july9 = 1468022400000;
var dayMs = 24 * 60 * 60 * 1000;
assert.sameValue(new Date(july6).getUTCDay(), 3, 'first millisecond');
assert.sameValue(
new Date(july6 - 1).getUTCDay(), 2, 'previous millisecond'
);
assert.sameValue(
new Date(july6 + dayMs - 1).getUTCDay(), 3, 'final millisecond'
);
assert.sameValue(
new Date(july6 + dayMs).getUTCDay(), 4, 'subsequent millisecond'
);
assert.sameValue(
new Date(july9).getUTCDay(), 6, 'first millisecond (week boundary)'
);
assert.sameValue(
new Date(july9 - 1).getUTCDay(), 5, 'previous millisecond (week boundary)'
);
assert.sameValue(
new Date(july9 + dayMs - 1).getUTCDay(),
6,
'final millisecond (week boundary)'
);
assert.sameValue(
new Date(july9 + dayMs).getUTCDay(),
0,
'subsequent millisecond (week boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getutcfullyear
es6id: 20.3.4.14
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCFullYear(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutcfullyear
es6id: 20.3.4.14
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCFullYear = Date.prototype.getUTCFullYear;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCFullYear, 'function');
assert.throws(TypeError, function() {
getUTCFullYear.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCFullYear.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCFullYear.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutcfullyear
es6id: 20.3.4.14
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCFullYear = Date.prototype.getUTCFullYear;
var symbol = Symbol();
assert.sameValue(typeof getUTCFullYear, 'function');
assert.throws(TypeError, function() {
getUTCFullYear.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCFullYear.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCFullYear.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCFullYear.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCFullYear.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCFullYear.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,25 @@
// 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.getutcfullyear
es6id: 20.3.4.14
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return YearFromTime(t).
---*/
var dec31 = 1483142400000;
var dayMs = 24 * 60 * 60 * 1000;
assert.sameValue(new Date(dec31).getUTCFullYear(), 2016, 'first millisecond');
assert.sameValue(
new Date(dec31 - 1).getUTCFullYear(), 2016, 'previous millisecond'
);
assert.sameValue(
new Date(dec31 + dayMs - 1).getUTCFullYear(), 2016, 'final millisecond'
);
assert.sameValue(
new Date(dec31 + dayMs).getUTCFullYear(), 2017, 'subsequent millisecond'
);

View File

@ -0,0 +1,12 @@
// 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.getutchours
es6id: 20.3.4.15
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCHours(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutchours
es6id: 20.3.4.15
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCHours = Date.prototype.getUTCHours;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCHours, 'function');
assert.throws(TypeError, function() {
getUTCHours.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCHours.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCHours.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutchours
es6id: 20.3.4.15
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCHours = Date.prototype.getUTCHours;
var symbol = Symbol();
assert.sameValue(typeof getUTCHours, 'function');
assert.throws(TypeError, function() {
getUTCHours.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCHours.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCHours.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCHours.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCHours.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCHours.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,43 @@
// 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.getutchours
es6id: 20.3.4.15
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return HourFromTime(t).
---*/
var hour15 = 1467817200000;
var hour23 = 1467846000000;
var hourMs = 60 * 60 * 1000;
assert.sameValue(new Date(hour15).getUTCHours(), 15, 'first millisecond');
assert.sameValue(
new Date(hour15 - 1).getUTCHours(), 14, 'previous millisecond'
);
assert.sameValue(
new Date(hour15 + hourMs - 1).getUTCHours(), 15, 'final millisecond'
);
assert.sameValue(
new Date(hour15 + hourMs).getUTCHours(), 16, 'subsequent millisecond'
);
assert.sameValue(
new Date(hour23).getUTCHours(), 23, 'first millisecond (day boundary)'
);
assert.sameValue(
new Date(hour23 - 1).getUTCHours(), 22, 'previous millisecond (day boundary)'
);
assert.sameValue(
new Date(hour23 + hourMs - 1).getUTCHours(),
23,
'final millisecond (day boundary)'
);
assert.sameValue(
new Date(hour23 + hourMs).getUTCHours(),
0,
'subsequent millisecond (day boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getutcmilliseconds
es6id: 20.3.4.16
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCMilliseconds(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutcmilliseconds
es6id: 20.3.4.16
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCMilliseconds = Date.prototype.getUTCMilliseconds;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCMilliseconds, 'function');
assert.throws(TypeError, function() {
getUTCMilliseconds.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCMilliseconds.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCMilliseconds.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutcmilliseconds
es6id: 20.3.4.16
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCMilliseconds = Date.prototype.getUTCMilliseconds;
var symbol = Symbol();
assert.sameValue(typeof getUTCMilliseconds, 'function');
assert.throws(TypeError, function() {
getUTCMilliseconds.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCMilliseconds.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCMilliseconds.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCMilliseconds.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCMilliseconds.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCMilliseconds.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,24 @@
// 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.getutcmmilliseconds
es6id: 20.3.4.16
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return msFromTime(t).
---*/
var july6 = 1467763200000;
assert.sameValue(new Date(july6).getUTCMilliseconds(), 0, 'first millisecond');
assert.sameValue(
new Date(july6 - 1).getUTCMilliseconds(), 999, 'previous millisecond'
);
assert.sameValue(
new Date(july6 + 999).getUTCMilliseconds(), 999, 'final millisecond'
);
assert.sameValue(
new Date(july6 + 1000).getUTCMilliseconds(), 0, 'subsequent millisecond'
);

View File

@ -0,0 +1,12 @@
// 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.getutcminutes
es6id: 20.3.4.17
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCMinutes(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutcminutes
es6id: 20.3.4.17
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCMinutes = Date.prototype.getUTCMinutes;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCMinutes, 'function');
assert.throws(TypeError, function() {
getUTCMinutes.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCMinutes.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCMinutes.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutcminutes
es6id: 20.3.4.17
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCMinutes = Date.prototype.getUTCMinutes;
var symbol = Symbol();
assert.sameValue(typeof getUTCMinutes, 'function');
assert.throws(TypeError, function() {
getUTCMinutes.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCMinutes.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCMinutes.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCMinutes.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCMinutes.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCMinutes.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,51 @@
// 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.getutcminutes
es6id: 20.3.4.17
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return MinFromTime(t).
---*/
var threeTwentyTwo = 1467818520000;
var threeFiftyNine = 1467820740000;
var minMs = 60 * 1000;
assert.sameValue(
new Date(threeTwentyTwo).getUTCMinutes(), 22, 'first millisecond'
);
assert.sameValue(
new Date(threeTwentyTwo - 1).getUTCMinutes(), 21, 'previous millisecond'
);
assert.sameValue(
new Date(threeTwentyTwo + minMs - 1).getUTCMinutes(), 22, 'final millisecond'
);
assert.sameValue(
new Date(threeTwentyTwo + minMs).getUTCMinutes(),
23,
'subsequent millisecond'
);
assert.sameValue(
new Date(threeFiftyNine).getUTCMinutes(),
59,
'first millisecond (day boundary)'
);
assert.sameValue(
new Date(threeFiftyNine - 1).getUTCMinutes(),
58,
'previous millisecond (day boundary)'
);
assert.sameValue(
new Date(threeFiftyNine + minMs - 1).getUTCMinutes(),
59,
'final millisecond (day boundary)'
);
assert.sameValue(
new Date(threeFiftyNine + minMs).getUTCMinutes(),
0,
'subsequent millisecond (day boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getutcmonth
es6id: 20.3.4.18
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCMonth(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutcmonth
es6id: 20.3.4.18
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCMonth = Date.prototype.getUTCMonth;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCMonth, 'function');
assert.throws(TypeError, function() {
getUTCMonth.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCMonth.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCMonth.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutcmonth
es6id: 20.3.4.18
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCMonth = Date.prototype.getUTCMonth;
var symbol = Symbol();
assert.sameValue(typeof getUTCMonth, 'function');
assert.throws(TypeError, function() {
getUTCMonth.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCMonth.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCMonth.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCMonth.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCMonth.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCMonth.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,43 @@
// 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.getutcmonth
es6id: 20.3.4.18
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return MonthFromTime(t).
---*/
var july31 = 1469923200000;
var dec31 = 1483142400000;
var dayMs = 24 * 60 * 60 * 1000;
assert.sameValue(new Date(july31).getUTCMonth(), 6, 'first millisecond');
assert.sameValue(
new Date(july31 - 1).getUTCMonth(), 6, 'previous millisecond'
);
assert.sameValue(
new Date(july31 + dayMs - 1).getUTCMonth(), 6, 'final millisecond'
);
assert.sameValue(
new Date(july31 + dayMs).getUTCMonth(), 7, 'subsequent millisecond'
);
assert.sameValue(
new Date(dec31).getUTCMonth(), 11, 'first millisecond (year boundary)'
);
assert.sameValue(
new Date(dec31 - 1).getUTCMonth(), 11, 'previous millisecond (year boundary)'
);
assert.sameValue(
new Date(dec31 + dayMs - 1).getUTCMonth(),
11,
'final millisecond (year boundary)'
);
assert.sameValue(
new Date(dec31 + dayMs).getUTCMonth(),
0,
'subsequent millisecond (year boundary)'
);

View File

@ -0,0 +1,12 @@
// 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.getutcseconds
es6id: 20.3.4.19
description: Return value for invalid date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
---*/
assert.sameValue(new Date(NaN).getUTCSeconds(), NaN);

View File

@ -0,0 +1,33 @@
// 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.getutcseconds
es6id: 20.3.4.19
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var getUTCSeconds = Date.prototype.getUTCSeconds;
var args = (function() { return arguments; }());
assert.sameValue(typeof getUTCSeconds, 'function');
assert.throws(TypeError, function() {
getUTCSeconds.call({});
}, 'ordinary object');
assert.throws(TypeError, function() {
getUTCSeconds.call([]);
}, 'array exotic object');
assert.throws(TypeError, function() {
getUTCSeconds.call(args);
}, 'arguments exotic object');

View File

@ -0,0 +1,45 @@
// 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.getutcseconds
es6id: 20.3.4.19
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var getUTCSeconds = Date.prototype.getUTCSeconds;
var symbol = Symbol();
assert.sameValue(typeof getUTCSeconds, 'function');
assert.throws(TypeError, function() {
getUTCSeconds.call(0);
}, 'number');
assert.throws(TypeError, function() {
getUTCSeconds.call(true);
}, 'boolean');
assert.throws(TypeError, function() {
getUTCSeconds.call(null);
}, 'null');
assert.throws(TypeError, function() {
getUTCSeconds.call(undefined);
}, 'undefined');
assert.throws(TypeError, function() {
getUTCSeconds.call('');
}, 'string');
assert.throws(TypeError, function() {
getUTCSeconds.call(symbol);
}, 'symbol');

View File

@ -0,0 +1,44 @@
// 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.getutcseconds
es6id: 20.3.4.19
description: Return value for valid dates
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, return NaN.
3. Return SecFromTime(t).
---*/
var sec34 = 1467819394000;
var sec59 = 1467819419000;
assert.sameValue(new Date(sec34).getUTCSeconds(), 34, 'first millisecond');
assert.sameValue(
new Date(sec34 - 1).getUTCSeconds(), 33, 'previous millisecond'
);
assert.sameValue(
new Date(sec34 + 999).getUTCSeconds(), 34, 'final millisecond'
);
assert.sameValue(
new Date(sec34 + 1000).getUTCSeconds(), 35, 'subsequent millisecond'
);
assert.sameValue(
new Date(sec59).getUTCSeconds(), 59, 'first millisecond (minute boundary)'
);
assert.sameValue(
new Date(sec59 - 1).getUTCSeconds(),
58,
'previous millisecond (minute boundary)'
);
assert.sameValue(
new Date(sec59 + 99).getUTCSeconds(),
59,
'final millisecond (minute boundary)'
);
assert.sameValue(
new Date(sec59 + 1000).getUTCSeconds(),
0,
'subsequent millisecond (minute boundary)'
);

View File

@ -0,0 +1,24 @@
// 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.setdate
es6id: 20.3.4.20
description: Abrupt completion during type coercion of provided argument
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(date).
---*/
var date = new Date();
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
date.setDate(obj);
});
assert.sameValue(date.getTime(), originalValue);

View File

@ -0,0 +1,56 @@
// 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.setdate
es6id: 20.3.4.20
description: Type coercion of provided argument
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(date).
3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt),
TimeWithinDay(t)).
4. Let u be TimeClip(UTC(newDate)).
5. Set the [[DateValue]] internal slot of this Date object to u.
6. Return u.
---*/
var date = new Date(2016, 6);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setDate(arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue, new Date(2016, 6, 2).getTime(), 'application of specified value'
);
returnValue = date.setDate(null);
assert.sameValue(returnValue, new Date(2016, 5, 30).getTime(), 'null');
returnValue = date.setDate(true);
assert.sameValue(returnValue, new Date(2016, 5, 1).getTime(), 'true');
returnValue = date.setDate(false);
assert.sameValue(returnValue, new Date(2016, 4, 31).getTime(), 'false');
returnValue = date.setDate(' +00200.000E-0002 ');
assert.sameValue(returnValue, new Date(2016, 4, 2).getTime(), 'string');
returnValue = date.setDate();
assert.sameValue(returnValue, NaN, 'undefined');

View File

@ -0,0 +1,29 @@
// 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.setdate
es6id: 20.3.4.20
description: Behavior when new value exceeds [[DateValue]] limits
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(date).
3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt),
TimeWithinDay(t)).
4. Let u be TimeClip(UTC(newDate)).
5. Set the [[DateValue]] internal slot of this Date object to u.
6. Return u.
TimeClip (time)
1. If time is not finite, return NaN.
2. If abs(time) > 8.64 × 1015, return NaN.
---*/
var date = new Date(8.64e15);
var returnValue;
assert.notSameValue(date.getTime(), NaN);
returnValue = date.setDate(28);
assert.sameValue(returnValue, NaN);

View File

@ -0,0 +1,24 @@
// 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.setdate
es6id: 20.3.4.20
description: >
Behavior when the "this" value is a Date object describing an invald date
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(date).
3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt),
TimeWithinDay(t)).
4. Let u be TimeClip(UTC(newDate)).
5. Set the [[DateValue]] internal slot of this Date object to u.
6. Return u.
---*/
var date = new Date(NaN);
var result;
result = date.setDate(0);
assert.sameValue(result, NaN, 'return value');
assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot');

View File

@ -0,0 +1,42 @@
// 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.setdate
es6id: 20.3.4.20
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var setDate = Date.prototype.setDate;
var callCount = 0;
var arg = {
valueOf: function() {
callCount += 1;
return 1;
}
};
var args = (function() { return arguments; }());
assert.sameValue(typeof setDate, 'function');
assert.throws(TypeError, function() {
setDate.call({}, arg);
}, 'ordinary object');
assert.throws(TypeError, function() {
setDate.call([], arg);
}, 'array exotic object');
assert.throws(TypeError, function() {
setDate.call(args, arg);
}, 'arguments exotic object');
assert.sameValue(callCount, 0, 'validation preceeds input coercion');

View File

@ -0,0 +1,54 @@
// 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.setdate
es6id: 20.3.4.20
description: Behavior when "this" value is not an Object
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var setDate = Date.prototype.setDate;
var callCount = 0;
var arg = {
valueOf: function() {
callCount += 1;
return 1;
}
};
var symbol = Symbol();
assert.sameValue(typeof setDate, 'function');
assert.throws(TypeError, function() {
setDate.call(0, arg);
}, 'number');
assert.throws(TypeError, function() {
setDate.call(true, arg);
}, 'boolean');
assert.throws(TypeError, function() {
setDate.call(null, arg);
}, 'null');
assert.throws(TypeError, function() {
setDate.call(undefined, arg);
}, 'undefined');
assert.throws(TypeError, function() {
setDate.call('', arg);
}, 'string');
assert.throws(TypeError, function() {
setDate.call(symbol, arg);
}, 'symbol');
assert.sameValue(callCount, 0, 'validation preceeds input coercion');

View File

@ -0,0 +1,48 @@
// 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.setdate
es6id: 20.3.4.20
description: Return value for valid dates
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(date).
3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt),
TimeWithinDay(t)).
4. Let u be TimeClip(UTC(newDate)).
5. Set the [[DateValue]] internal slot of this Date object to u.
6. Return u.
---*/
var date = new Date(2016, 6);
var returnValue, expected;
returnValue = date.setDate(6);
expected = new Date(2016, 6, 6).getTime();
assert.sameValue(
returnValue, expected, 'within unit boundary (return value)'
);
assert.sameValue(
date.getTime(), expected, 'within unit boundary ([[DateValue]] slot)'
);
returnValue = date.setDate(0);
expected = new Date(2016, 5, 30).getTime();
assert.sameValue(
returnValue, expected, 'before time unit boundary (return value)'
);
assert.sameValue(
date.getTime(), expected, 'before time unit boundary ([[DateValue]] slot)'
);
returnValue = date.setDate(31);
expected = new Date(2016, 6, 1).getTime();
assert.sameValue(
returnValue, expected, 'after time unit boundary (return value)'
);
assert.sameValue(
date.getTime(), expected, 'after time unit boundary ([[DateValue]] slot)'
);

View File

@ -0,0 +1,29 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Abrupt completion during type coercion of provided "date"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
---*/
var date = new Date();
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
date.setFullYear(0, 0, obj);
});
assert.sameValue(date.getTime(), originalValue);

View File

@ -0,0 +1,78 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Type coercion of provided "date"
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6, 7, 11, 36, 23, 2);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setFullYear(2016, 6, arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue,
new Date(2016, 6, 2, 11, 36, 23, 2).getTime(),
'application of specified value'
);
returnValue = date.setFullYear(2016, 6, null);
assert.sameValue(
returnValue,
new Date(2016, 6, 0, 11, 36, 23, 2).getTime(),
'null'
);
returnValue = date.setFullYear(2016, 6, true);
assert.sameValue(
returnValue,
new Date(2016, 6, 1, 11, 36, 23, 2).getTime(),
'true'
);
returnValue = date.setFullYear(2016, 6, false);
assert.sameValue(
returnValue,
new Date(2016, 6, 0, 11, 36, 23, 2).getTime(),
'false'
);
returnValue = date.setFullYear(2016, 6, ' +00200.000E-0002 ');
assert.sameValue(
returnValue,
new Date(2016, 6, 2, 11, 36, 23, 2).getTime(),
'string'
);
returnValue = date.setFullYear(2016, 6, undefined);
assert.sameValue(returnValue, NaN, 'undefined');

View File

@ -0,0 +1,34 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Abrupt completion during type coercion of provided "month"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
---*/
var date = new Date();
var callCount = 0;
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
var counter = {
valueOf: function() {
callCount += 1;
}
};
assert.throws(Test262Error, function() {
date.setFullYear(0, obj, counter);
});
assert.sameValue(date.getTime(), originalValue);
assert.sameValue(callCount, 0);

View File

@ -0,0 +1,78 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Type coercion of provided "month"
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6, 7, 11, 36, 23, 2);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setFullYear(2016, arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue,
new Date(2016, 2, 7, 11, 36, 23, 2).getTime(),
'application of specified value'
);
returnValue = date.setFullYear(2016, null);
assert.sameValue(
returnValue,
new Date(2016, 0, 7, 11, 36, 23, 2).getTime(),
'null'
);
returnValue = date.setFullYear(2016, true);
assert.sameValue(
returnValue,
new Date(2016, 1, 7, 11, 36, 23, 2).getTime(),
'true'
);
returnValue = date.setFullYear(2016, false);
assert.sameValue(
returnValue,
new Date(2016, 0, 7, 11, 36, 23, 2).getTime(),
'false'
);
returnValue = date.setFullYear(2016, ' +00200.000E-0002 ');
assert.sameValue(
returnValue,
new Date(2016, 2, 7, 11, 36, 23, 2).getTime(),
'string'
);
returnValue = date.setFullYear(2016, undefined);
assert.sameValue(returnValue, NaN, 'undefined');

View File

@ -0,0 +1,32 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Abrupt completion during type coercion of provided "year"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
---*/
var date = new Date();
var callCount = 0;
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
var counter = {
valueOf: function() {
callCount += 1;
}
};
assert.throws(Test262Error, function() {
date.setFullYear(obj, counter, counter);
});
assert.sameValue(date.getTime(), originalValue);
assert.sameValue(callCount, 0);

View File

@ -0,0 +1,78 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Type coercion of provided "year"
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6, 7, 11, 36, 23, 2);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setFullYear(arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue,
new Date(-1, 42, 7, 11, 36, 23, 2).getTime(),
'application of specified value'
);
returnValue = date.setFullYear(null);
assert.sameValue(
returnValue,
new Date(-1, 18, 7, 11, 36, 23, 2).getTime(),
'null'
);
returnValue = date.setFullYear(true);
assert.sameValue(
returnValue,
new Date(-1, 30, 7, 11, 36, 23, 2).getTime(),
'true'
);
returnValue = date.setFullYear(false);
assert.sameValue(
returnValue,
new Date(-1, 18, 7, 11, 36, 23, 2).getTime(),
'false'
);
returnValue = date.setFullYear(' +00200.000E-0002 ');
assert.sameValue(
returnValue,
new Date(-1, 42, 7, 11, 36, 23, 2).getTime(),
'string'
);
returnValue = date.setFullYear();
assert.sameValue(returnValue, NaN, 'undefined');

View File

@ -0,0 +1,49 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Behavior when new value exceeds [[DateValue]] limits
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
TimeClip (time)
1. If time is not finite, return NaN.
2. If abs(time) > 8.64 × 1015, return NaN.
---*/
var maxMs = 8.64e15;
var maxYear = 275760;
var maxDate = 12;
var maxMonth = 8;
var date = new Date(maxMs);
var returnValue;
assert.notSameValue(date.getTime(), NaN);
returnValue = date.setFullYear(maxYear + 1);
assert.sameValue(returnValue, NaN, 'overflow due to year');
date = new Date(maxMs);
returnValue = date.setFullYear(maxYear, maxMonth + 1);
assert.sameValue(returnValue, NaN, 'overflow due to month');
date = new Date(maxMs);
returnValue = date.setFullYear(maxYear, maxMonth, maxDate + 1);
assert.sameValue(returnValue, NaN, 'overflow due to date');

View File

@ -0,0 +1,51 @@
// 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.setfullyear
es6id: 20.3.4.21
description: >
Behavior when the "this" value is a Date object describing an invald date
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(NaN);
var expected, result;
result = date.setFullYear(2016);
expected = new Date(2016, 0).getTime();
assert.sameValue(result, expected, 'return value (year)');
assert.sameValue(
date.getTime(), expected, '[[DateValue]] internal slot (year)'
);
date = new Date(NaN);
result = date.setFullYear(2016, 6);
expected = new Date(2016, 6).getTime();
assert.sameValue(result, expected, 'return value (month)');
assert.sameValue(
date.getTime(), expected, '[[DateValue]] internal slot (month)'
);
date = new Date(NaN);
result = date.setFullYear(2016, 6, 7);
expected = new Date(2016, 6, 7).getTime();
assert.sameValue(result, expected, 'return value (date)');
assert.sameValue(
date.getTime(), expected, '[[DateValue]] internal slot (month)'
);

View File

@ -0,0 +1,42 @@
// 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.setfullyear
es6id: 20.3.4.21
description: >
Behavior when "this" value is an Object without a [[DateValue]] internal slot
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
---*/
var setFullYear = Date.prototype.setFullYear;
var callCount = 0;
var arg = {
valueOf: function() {
callCount += 1;
return 1;
}
};
var args = (function() { return arguments; }());
assert.sameValue(typeof setFullYear, 'function');
assert.throws(TypeError, function() {
setFullYear.call({}, arg);
}, 'ordinary object');
assert.throws(TypeError, function() {
setFullYear.call([], arg);
}, 'array exotic object');
assert.throws(TypeError, function() {
setFullYear.call(args, arg);
}, 'arguments exotic object');
assert.sameValue(callCount, 0, 'validation preceeds input coercion');

View File

@ -0,0 +1,54 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Behavior when "this" value is not an Object
info: |
1. Let t be ? thisTimeValue(this value).
The abstract operation thisTimeValue(value) performs the following steps:
1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
a. Return value.[[DateValue]].
2. Throw a TypeError exception.
features: [Symbol]
---*/
var setFullYear = Date.prototype.setFullYear;
var callCount = 0;
var arg = {
valueOf: function() {
callCount += 1;
return 1;
}
};
var symbol = Symbol();
assert.sameValue(typeof setFullYear, 'function');
assert.throws(TypeError, function() {
setFullYear.call(0, arg);
}, 'number');
assert.throws(TypeError, function() {
setFullYear.call(true, arg);
}, 'boolean');
assert.throws(TypeError, function() {
setFullYear.call(null, arg);
}, 'null');
assert.throws(TypeError, function() {
setFullYear.call(undefined, arg);
}, 'undefined');
assert.throws(TypeError, function() {
setFullYear.call('', arg);
}, 'string');
assert.throws(TypeError, function() {
setFullYear.call(symbol, arg);
}, 'symbol');
assert.sameValue(callCount, 0, 'validation preceeds input coercion');

View File

@ -0,0 +1,56 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Return value for valid dates (setting date)
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6);
var returnValue, expected;
returnValue = date.setFullYear(2016, 6, 6);
expected = new Date(2016, 6, 6).getTime();
assert.sameValue(
returnValue, expected, 'date within unit boundary (return value)'
);
assert.sameValue(
date.getTime(), expected, 'date within unit boundary ([[DateValue]] slot)'
);
returnValue = date.setFullYear(2016, 6, 0);
expected = new Date(2016, 5, 30).getTime();
assert.sameValue(
returnValue, expected, 'date before time unit boundary (return value)'
);
assert.sameValue(
date.getTime(),
expected,
'date before time unit boundary ([[DateValue]] slot)'
);
returnValue = date.setFullYear(2016, 5, 31);
expected = new Date(2016, 6, 1).getTime();
assert.sameValue(
returnValue, expected, 'date after time unit boundary (return value)'
);
assert.sameValue(
date.getTime(),
expected,
'date after time unit boundary ([[DateValue]] slot)'
);

View File

@ -0,0 +1,56 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Return value for valid dates (setting month)
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6);
var returnValue, expected;
returnValue = date.setFullYear(2016, 3);
expected = new Date(2016, 3).getTime();
assert.sameValue(
returnValue, expected, 'month within unit boundary (return value)'
);
assert.sameValue(
date.getTime(), expected, 'month within unit boundary ([[DateValue]] slot)'
);
returnValue = date.setFullYear(2016, -1);
expected = new Date(2015, 11).getTime();
assert.sameValue(
returnValue, expected, 'month before time unit boundary (return value)'
);
assert.sameValue(
date.getTime(),
expected,
'month before time unit boundary ([[DateValue]] slot)'
);
returnValue = date.setFullYear(2016, 12);
expected = new Date(2017, 0).getTime();
assert.sameValue(
returnValue, expected, 'month after time unit boundary (return value)'
);
assert.sameValue(
date.getTime(),
expected,
'month after time unit boundary ([[DateValue]] slot)'
);

View File

@ -0,0 +1,28 @@
// 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.setfullyear
es6id: 20.3.4.21
description: Return value for valid dates (setting year)
info: |
1. Let t be ? thisTimeValue(this value).
2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t).
3. Let y be ? ToNumber(year).
4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be
? ToNumber(month).
5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be
? ToNumber(date).
6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
7. Let u be TimeClip(UTC(newDate)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6);
var returnValue, expected;
returnValue = date.setFullYear(2015);
expected = new Date(2015, 6).getTime();
assert.sameValue(returnValue, expected, 'year (return value)');
assert.sameValue(date.getTime(), expected, 'year ([[DateValue]] slot)');

View File

@ -0,0 +1,31 @@
// 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.sethours
es6id: 20.3.4.22
description: Abrupt completion during type coercion of provided "hour"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(hour).
---*/
var date = new Date();
var callCount = 0;
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
var counter = {
valueOf: function() {
callCount += 1;
}
};
assert.throws(Test262Error, function() {
date.setHours(obj, counter, counter, counter);
});
assert.sameValue(date.getTime(), originalValue);
assert.sameValue(callCount, 0);

View File

@ -0,0 +1,63 @@
// 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.sethours
es6id: 20.3.4.22
description: Type coercion of provided "hour"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let h be ? ToNumber(hour).
3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ?
ToNumber(min).
4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ?
ToNumber(sec).
5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli
be ? ToNumber(ms).
6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)).
7. Let u be TimeClip(UTC(date)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setHours(arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue,
new Date(2016, 6, 1, 2).getTime(),
'application of specified value'
);
returnValue = date.setHours(null);
assert.sameValue(returnValue, new Date(2016, 6, 1, 0).getTime(), 'null');
returnValue = date.setHours(true);
assert.sameValue(returnValue, new Date(2016, 6, 1, 1).getTime(), 'true');
returnValue = date.setHours(false);
assert.sameValue(returnValue, new Date(2016, 6, 1, 0).getTime(), 'false');
returnValue = date.setHours(' +00200.000E-0002 ');
assert.sameValue(returnValue, new Date(2016, 6, 1, 2).getTime(), 'string');
returnValue = date.setHours();
assert.sameValue(returnValue, NaN, 'undefined');

View File

@ -0,0 +1,33 @@
// 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.sethours
es6id: 20.3.4.22
description: Abrupt completion during type coercion of provided "min"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(hour).
3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ?
ToNumber(min).
---*/
var date = new Date();
var callCount = 0;
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
var counter = {
valueOf: function() {
callCount += 1;
}
};
assert.throws(Test262Error, function() {
date.setHours(0, obj, counter, counter);
});
assert.sameValue(date.getTime(), originalValue);
assert.sameValue(callCount, 0);

View File

@ -0,0 +1,63 @@
// 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.sethours
es6id: 20.3.4.22
description: Type coercion of provided "min"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let h be ? ToNumber(hour).
3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ?
ToNumber(min).
4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ?
ToNumber(sec).
5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli
be ? ToNumber(ms).
6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)).
7. Let u be TimeClip(UTC(date)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setHours(0, arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue,
new Date(2016, 6, 1, 0, 2).getTime(),
'application of specified value'
);
returnValue = date.setHours(0, null);
assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null');
returnValue = date.setHours(0, true);
assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 1).getTime(), 'true');
returnValue = date.setHours(0, false);
assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false');
returnValue = date.setHours(0, ' +00200.000E-0002 ');
assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 2).getTime(), 'string');
returnValue = date.setHours();
assert.sameValue(returnValue, NaN, 'undefined');

View File

@ -0,0 +1,30 @@
// 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.sethours
es6id: 20.3.4.22
description: Abrupt completion during type coercion of provided "ms"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(hour).
3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ?
ToNumber(min).
4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ?
ToNumber(sec).
5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli
be ? ToNumber(ms).
---*/
var date = new Date();
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
date.setHours(0, 0, 0, obj);
});
assert.sameValue(date.getTime(), originalValue);

View File

@ -0,0 +1,67 @@
// 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.sethours
es6id: 20.3.4.22
description: Type coercion of provided "ms"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let h be ? ToNumber(hour).
3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ?
ToNumber(min).
4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ?
ToNumber(sec).
5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli
be ? ToNumber(ms).
6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)).
7. Let u be TimeClip(UTC(date)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setHours(0, 0, 0, arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue,
new Date(2016, 6, 1, 0, 0, 0, 2).getTime(),
'application of specified value'
);
returnValue = date.setHours(0, 0, 0, null);
assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null');
returnValue = date.setHours(0, 0, 0, true);
assert.sameValue(
returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true'
);
returnValue = date.setHours(0, 0, 0, false);
assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false');
returnValue = date.setHours(0, 0, 0, ' +00200.000E-0002 ');
assert.sameValue(
returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string'
);
returnValue = date.setHours();
assert.sameValue(returnValue, NaN, 'undefined');

View File

@ -0,0 +1,35 @@
// 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.sethours
es6id: 20.3.4.22
description: Abrupt completion during type coercion of provided "sec"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let dt be ? ToNumber(hour).
3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ?
ToNumber(min).
4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ?
ToNumber(sec).
---*/
var date = new Date();
var callCount = 0;
var originalValue = date.getTime();
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
var counter = {
valueOf: function() {
callCount += 1;
}
};
assert.throws(Test262Error, function() {
date.setHours(0, 0, obj, counter);
});
assert.sameValue(date.getTime(), originalValue);
assert.sameValue(callCount, 0);

View File

@ -0,0 +1,65 @@
// 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.sethours
es6id: 20.3.4.22
description: Type coercion of provided "sec"
info: |
1. Let t be LocalTime(? thisTimeValue(this value)).
2. Let h be ? ToNumber(hour).
3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ?
ToNumber(min).
4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ?
ToNumber(sec).
5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli
be ? ToNumber(ms).
6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)).
7. Let u be TimeClip(UTC(date)).
8. Set the [[DateValue]] internal slot of this Date object to u.
9. Return u.
---*/
var date = new Date(2016, 6);
var callCount = 0;
var arg = {
valueOf: function() {
args = arguments;
thisValue = this;
callCount += 1;
return 2;
}
};
var args, thisValue, returnValue;
returnValue = date.setHours(0, 0, arg);
assert.sameValue(callCount, 1, 'invoked exactly once');
assert.sameValue(args.length, 0, 'invoked without arguments');
assert.sameValue(thisValue, arg, '"this" value');
assert.sameValue(
returnValue,
new Date(2016, 6, 1, 0, 0, 2).getTime(),
'application of specified value'
);
returnValue = date.setHours(0, 0, null);
assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null');
returnValue = date.setHours(0, 0, true);
assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 0, 1).getTime(), 'true');
returnValue = date.setHours(0, 0, false);
assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false');
returnValue = date.setHours(0, 0, ' +00200.000E-0002 ');
assert.sameValue(
returnValue, new Date(2016, 6, 1, 0, 0, 2).getTime(), 'string'
);
returnValue = date.setHours();
assert.sameValue(returnValue, NaN, 'undefined');

Some files were not shown because too many files have changed in this diff Show More