mirror of https://github.com/tc39/test262.git
Replace runTestCase with assert helpers [test/built-ins/Date]
This commit is contained in:
parent
cf231fb03b
commit
bec8782918
|
@ -7,15 +7,12 @@ description: >
|
||||||
Date Time String Format - specified default values will be set for
|
Date Time String Format - specified default values will be set for
|
||||||
all optional fields(MM, DD, mm, ss and time zone) when they are
|
all optional fields(MM, DD, mm, ss and time zone) when they are
|
||||||
absent
|
absent
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var result = false;
|
var result = false;
|
||||||
var expectedDateTimeStr = new Date(1970, 0, 1, 0, 0, 0, 0).toISOString();
|
var expectedDateTimeStr = new Date(1970, 0, 1, 0, 0, 0, 0).toISOString();
|
||||||
var dateObj = new Date("1970");
|
var dateObj = new Date("1970");
|
||||||
var dateStr = dateObj.toISOString();
|
var dateStr = dateObj.toISOString();
|
||||||
result = dateStr === expectedDateTimeStr;
|
result = dateStr === expectedDateTimeStr;
|
||||||
return result;
|
|
||||||
}
|
assert(result, 'result !== true');
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
|
@ -4,12 +4,8 @@
|
||||||
/*---
|
/*---
|
||||||
es5id: 15.9.4.4-0-3
|
es5id: 15.9.4.4-0-3
|
||||||
description: Date.now must exist as a function
|
description: Date.now must exist as a function
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
|
|
||||||
var fun = Date.now;
|
var fun = Date.now;
|
||||||
return (typeof (fun) === "function");
|
|
||||||
}
|
assert.sameValue(typeof (fun), "function", 'typeof (fun)');
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
|
@ -7,16 +7,12 @@ description: >
|
||||||
Date.prototype.toISOString - RangeError is not thrown when value
|
Date.prototype.toISOString - RangeError is not thrown when value
|
||||||
of date is Date(1970, 0, 100000001, 0, 0, 0, -1), the time zone is
|
of date is Date(1970, 0, 100000001, 0, 0, 0, -1), the time zone is
|
||||||
UTC(0)
|
UTC(0)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
|
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
|
||||||
var date, dateStr;
|
var date, dateStr;
|
||||||
|
|
||||||
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, -1);
|
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, -1);
|
||||||
dateStr = date.toISOString();
|
dateStr = date.toISOString();
|
||||||
|
|
||||||
return dateStr[dateStr.length - 1] === "Z";
|
assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
|
@ -7,16 +7,12 @@ description: >
|
||||||
Date.prototype.toISOString - RangeError is not thrown when value
|
Date.prototype.toISOString - RangeError is not thrown when value
|
||||||
of date is Date(1970, 0, 100000001, 0, 0, 0, 0), the time zone is
|
of date is Date(1970, 0, 100000001, 0, 0, 0, 0), the time zone is
|
||||||
UTC(0)
|
UTC(0)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
|
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
|
||||||
var date, dateStr;
|
var date, dateStr;
|
||||||
|
|
||||||
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, 0);
|
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, 0);
|
||||||
dateStr = date.toISOString();
|
dateStr = date.toISOString();
|
||||||
|
|
||||||
return dateStr[dateStr.length - 1] === "Z";
|
assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
|
@ -6,13 +6,9 @@ es5id: 15.9.5.43-0-4
|
||||||
description: >
|
description: >
|
||||||
Date.prototype.toISOString - format of returned string is
|
Date.prototype.toISOString - format of returned string is
|
||||||
'YYYY-MM-DDTHH:mm:ss.sssZ', the time zone is UTC(0)
|
'YYYY-MM-DDTHH:mm:ss.sssZ', the time zone is UTC(0)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var date = new Date(1999, 9, 10, 10, 10, 10, 10);
|
var date = new Date(1999, 9, 10, 10, 10, 10, 10);
|
||||||
var localDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
var localDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
||||||
|
|
||||||
return localDate.toISOString() === "1999-10-10T10:10:10.010Z";
|
assert.sameValue(localDate.toISOString(), "1999-10-10T10:10:10.010Z", 'localDate.toISOString()');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
|
@ -6,11 +6,8 @@ es5id: 15.9.5.43-0-5
|
||||||
description: >
|
description: >
|
||||||
Date.prototype.toISOString - The returned string is the UTC time
|
Date.prototype.toISOString - The returned string is the UTC time
|
||||||
zone(0)
|
zone(0)
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var dateStr = (new Date()).toISOString();
|
var dateStr = (new Date()).toISOString();
|
||||||
return dateStr[dateStr.length - 1] === "Z";
|
|
||||||
}
|
assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]');
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
|
@ -4,13 +4,8 @@
|
||||||
/*---
|
/*---
|
||||||
es5id: 15.9.5.44-0-1
|
es5id: 15.9.5.44-0-1
|
||||||
description: Date.prototype.toJSON must exist as a function
|
description: Date.prototype.toJSON must exist as a function
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var f = Date.prototype.toJSON;
|
var f = Date.prototype.toJSON;
|
||||||
if (typeof(f) === "function") {
|
|
||||||
return true;
|
assert.sameValue(typeof(f), "function", 'typeof(f)');
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
|
@ -4,12 +4,6 @@
|
||||||
/*---
|
/*---
|
||||||
es5id: 15.9.5.44-0-2
|
es5id: 15.9.5.44-0-2
|
||||||
description: Date.prototype.toJSON must exist as a function taking 1 parameter
|
description: Date.prototype.toJSON must exist as a function taking 1 parameter
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
assert.sameValue(Date.prototype.toJSON.length, 1, 'Date.prototype.toJSON.length');
|
||||||
if (Date.prototype.toJSON.length === 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
|
Loading…
Reference in New Issue