Skip to content

Correct invalid tests for the Date constructor #573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions harness/assertRelativeDateMs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* Verify that the given date object's Number representation describes the
* correct number of milliseconds since the Unix epoch relative to the local
* time zone (as interpreted at the specified date).
*
* @param {Date} date
* @param {Number} expectedMs
*/
function assertRelativeDateMs(date, expectedMs) {
var actualMs = date.valueOf();
var localOffset = date.getTimezoneOffset() * 60000;

if (actualMs - localOffset !== expectedMs) {
$ERROR(
'Expected ' + date + ' to be ' + expectedMs +
' milliseconds from the Unix epoch'
);
}
}
55 changes: 14 additions & 41 deletions test/built-ins/Date/S15.9.3.1_A5_T1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-date-constructor
info: >
The [[Value]] property of the newly constructed object
is set by following steps:
Expand All @@ -14,56 +14,29 @@ info: >
TimeClip(UTC(Result(11)))
es5id: 15.9.3.1_A5_T1
description: 2 arguments, (year, month)
includes:
- numeric_conversion.js
- Date_constants.js
- Date_library.js
includes: [assertRelativeDateMs.js]
---*/

if (-2211638400000 !== new Date(1899, 11).valueOf()) {
$ERROR("#1: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 11), -2211667200000);

if (-2208960000000 !== new Date(1899, 12).valueOf()) {
$ERROR("#2: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 12), -2208988800000);

if (-2208960000000 !== new Date(1900, 0).valueOf()) {
$ERROR("#3: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1900, 0), -2208988800000);

if (-2649600000 !== new Date(1969, 11).valueOf()) {
$ERROR("#4: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 11), -2678400000);

if (28800000 !== new Date(1969, 12).valueOf()) {
$ERROR("#5: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 12), 0);

if (28800000 !== new Date(1970, 0).valueOf()) {
$ERROR("#6: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1970, 0), 0);

if (944035200000 !== new Date(1999, 11).valueOf()) {
$ERROR("#7: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 11), 944006400000);

if (946713600000 !== new Date(1999, 12).valueOf()) {
$ERROR("#8: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 12), 946684800000);

if (946713600000 !== new Date(2000, 0).valueOf()) {
$ERROR("#9: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2000, 0), 946684800000);

if (4099795200000 !== new Date(2099, 11).valueOf()) {
$ERROR("#10: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 11), 4099766400000);

if (4102473600000 !== new Date(2099, 12).valueOf()) {
$ERROR("#11: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 12), 4102444800000);

if (4102473600000 !== new Date(2100, 0).valueOf()) {
$ERROR("#12: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2100, 0), 4102444800000);
55 changes: 14 additions & 41 deletions test/built-ins/Date/S15.9.3.1_A5_T2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-date-constructor
info: >
The [[Value]] property of the newly constructed object
is set by following steps:
Expand All @@ -14,56 +14,29 @@ info: >
TimeClip(UTC(Result(11)))
es5id: 15.9.3.1_A5_T2
description: 3 arguments, (year, month, date)
includes:
- numeric_conversion.js
- Date_constants.js
- Date_library.js
includes: [assertRelativeDateMs.js]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file doesn't have an esid flag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.

---*/

if (-2209046400000 !== new Date(1899, 11, 31).valueOf()) {
$ERROR("#1: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 11, 31), -2209075200000);

if (-2208960000000 !== new Date(1899, 12, 1).valueOf()) {
$ERROR("#2: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 12, 1), -2208988800000);

if (-2208960000000 !== new Date(1900, 0, 1).valueOf()) {
$ERROR("#3: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1900, 0, 1), -2208988800000);

if (-57600000 !== new Date(1969, 11, 31).valueOf()) {
$ERROR("#4: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 11, 31), -86400000);

if (28800000 !== new Date(1969, 12, 1).valueOf()) {
$ERROR("#5: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 12, 1), 0);

if (28800000 !== new Date(1970, 0, 1).valueOf()) {
$ERROR("#6: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1970, 0, 1), 0);

if (946627200000 !== new Date(1999, 11, 31).valueOf()) {
$ERROR("#7: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 11, 31), 946598400000);

if (946713600000 !== new Date(1999, 12, 1).valueOf()) {
$ERROR("#8: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 12, 1), 946684800000);

if (946713600000 !== new Date(2000, 0, 1).valueOf()) {
$ERROR("#9: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2000, 0, 1), 946684800000);

if (4102387200000 !== new Date(2099, 11, 31).valueOf()) {
$ERROR("#10: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 11, 31), 4102358400000);

if (4102473600000 !== new Date(2099, 12, 1).valueOf()) {
$ERROR("#11: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 12, 1), 4102444800000);

if (4102473600000 !== new Date(2100, 0, 1).valueOf()) {
$ERROR("#12: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2100, 0, 1), 4102444800000);
55 changes: 14 additions & 41 deletions test/built-ins/Date/S15.9.3.1_A5_T3.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-date-constructor
info: >
The [[Value]] property of the newly constructed object
is set by following steps:
Expand All @@ -14,56 +14,29 @@ info: >
TimeClip(UTC(Result(11)))
es5id: 15.9.3.1_A5_T3
description: 4 arguments, (year, month, date, hours)
includes:
- numeric_conversion.js
- Date_constants.js
- Date_library.js
includes: [assertRelativeDateMs.js]
---*/

if (-2208963600000 !== new Date(1899, 11, 31, 23).valueOf()) {
$ERROR("#1: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 11, 31, 23), -2208992400000);

if (-2208960000000 !== new Date(1899, 12, 1, 0).valueOf()) {
$ERROR("#2: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 12, 1, 0), -2208988800000);

if (-2208960000000 !== new Date(1900, 0, 1, 0).valueOf()) {
$ERROR("#3: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1900, 0, 1, 0), -2208988800000);

if (25200000 !== new Date(1969, 11, 31, 23).valueOf()) {
$ERROR("#4: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 11, 31, 23), -3600000);

if (28800000 !== new Date(1969, 12, 1, 0).valueOf()) {
$ERROR("#5: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 12, 1, 0), 0);

if (28800000 !== new Date(1970, 0, 1, 0).valueOf()) {
$ERROR("#6: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1970, 0, 1, 0), 0);

if (946710000000 !== new Date(1999, 11, 31, 23).valueOf()) {
$ERROR("#7: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 11, 31, 23), 946681200000);

if (946713600000 !== new Date(1999, 12, 1, 0).valueOf()) {
$ERROR("#8: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 12, 1, 0), 946684800000);

if (946713600000 !== new Date(2000, 0, 1, 0).valueOf()) {
$ERROR("#9: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2000, 0, 1, 0), 946684800000);

if (4102470000000 !== new Date(2099, 11, 31, 23).valueOf()) {
$ERROR("#10: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 11, 31, 23), 4102441200000);

if (4102473600000 !== new Date(2099, 12, 1, 0).valueOf()) {
$ERROR("#11: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 12, 1, 0), 4102444800000);

if (4102473600000 !== new Date(2100, 0, 1, 0).valueOf()) {
$ERROR("#12: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2100, 0, 1, 0), 4102444800000);
55 changes: 14 additions & 41 deletions test/built-ins/Date/S15.9.3.1_A5_T4.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-date-constructor
info: >
The [[Value]] property of the newly constructed object
is set by following steps:
Expand All @@ -14,56 +14,29 @@ info: >
TimeClip(UTC(Result(11)))
es5id: 15.9.3.1_A5_T4
description: 5 arguments, (year, month, date, hours, minutes)
includes:
- numeric_conversion.js
- Date_constants.js
- Date_library.js
includes: [assertRelativeDateMs.js]
---*/

if (-2208960060000 !== new Date(1899, 11, 31, 23, 59).valueOf()) {
$ERROR("#1: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 11, 31, 23, 59), -2208988860000);

if (-2208960000000 !== new Date(1899, 12, 1, 0, 0).valueOf()) {
$ERROR("#2: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1899, 12, 1, 0, 0), -2208988800000);

if (-2208960000000 !== new Date(1900, 0, 1, 0, 0).valueOf()) {
$ERROR("#3: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1900, 0, 1, 0, 0), -2208988800000);

if (28740000 !== new Date(1969, 11, 31, 23, 59).valueOf()) {
$ERROR("#4: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 11, 31, 23, 59), -60000);

if (28800000 !== new Date(1969, 12, 1, 0, 0).valueOf()) {
$ERROR("#5: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1969, 12, 1, 0, 0), 0);

if (28800000 !== new Date(1970, 0, 1, 0, 0).valueOf()) {
$ERROR("#6: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1970, 0, 1, 0, 0), 0);

if (946713540000 !== new Date(1999, 11, 31, 23, 59).valueOf()) {
$ERROR("#7: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 11, 31, 23, 59), 946684740000);

if (946713600000 !== new Date(1999, 12, 1, 0, 0).valueOf()) {
$ERROR("#8: Incorrect value of Date");
}
assertRelativeDateMs(new Date(1999, 12, 1, 0, 0), 946684800000);

if (946713600000 !== new Date(2000, 0, 1, 0, 0).valueOf()) {
$ERROR("#9: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2000, 0, 1, 0, 0), 946684800000);

if (4102473540000 !== new Date(2099, 11, 31, 23, 59).valueOf()) {
$ERROR("#10: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 11, 31, 23, 59), 4102444740000);

if (4102473600000 !== new Date(2099, 12, 1, 0, 0).valueOf()) {
$ERROR("#11: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2099, 12, 1, 0, 0), 4102444800000);

if (4102473600000 !== new Date(2100, 0, 1, 0, 0).valueOf()) {
$ERROR("#12: Incorrect value of Date");
}
assertRelativeDateMs(new Date(2100, 0, 1, 0, 0), 4102444800000);
Loading