Replace runTestCase with assert helpers [test/built-ins/Date]

This commit is contained in:
André Bargull 2015-08-06 18:25:18 +02:00
parent cf231fb03b
commit bec8782918
8 changed files with 12 additions and 45 deletions

View File

@ -7,15 +7,12 @@ description: >
Date Time String Format - specified default values will be set for
all optional fields(MM, DD, mm, ss and time zone) when they are
absent
includes: [runTestCase.js]
---*/
function testcase() {
var result = false;
var expectedDateTimeStr = new Date(1970, 0, 1, 0, 0, 0, 0).toISOString();
var dateObj = new Date("1970");
var dateStr = dateObj.toISOString();
result = dateStr === expectedDateTimeStr;
return result;
}
runTestCase(testcase);
assert(result, 'result !== true');

View File

@ -4,12 +4,8 @@
/*---
es5id: 15.9.4.4-0-3
description: Date.now must exist as a function
includes: [runTestCase.js]
---*/
function testcase() {
var fun = Date.now;
return (typeof (fun) === "function");
}
runTestCase(testcase);
assert.sameValue(typeof (fun), "function", 'typeof (fun)');

View File

@ -7,16 +7,12 @@ description: >
Date.prototype.toISOString - RangeError is not thrown when value
of date is Date(1970, 0, 100000001, 0, 0, 0, -1), the time zone is
UTC(0)
includes: [runTestCase.js]
---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr;
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, -1);
dateStr = date.toISOString();
return dateStr[dateStr.length - 1] === "Z";
}
runTestCase(testcase);
assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]');

View File

@ -7,16 +7,12 @@ description: >
Date.prototype.toISOString - RangeError is not thrown when value
of date is Date(1970, 0, 100000001, 0, 0, 0, 0), the time zone is
UTC(0)
includes: [runTestCase.js]
---*/
function testcase() {
var timeZoneMinutes = new Date().getTimezoneOffset() * (-1);
var date, dateStr;
date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, 0);
dateStr = date.toISOString();
return dateStr[dateStr.length - 1] === "Z";
}
runTestCase(testcase);
assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]');

View File

@ -6,13 +6,9 @@ es5id: 15.9.5.43-0-4
description: >
Date.prototype.toISOString - format of returned string is
'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 localDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
return localDate.toISOString() === "1999-10-10T10:10:10.010Z";
}
runTestCase(testcase);
assert.sameValue(localDate.toISOString(), "1999-10-10T10:10:10.010Z", 'localDate.toISOString()');

View File

@ -6,11 +6,8 @@ es5id: 15.9.5.43-0-5
description: >
Date.prototype.toISOString - The returned string is the UTC time
zone(0)
includes: [runTestCase.js]
---*/
function testcase() {
var dateStr = (new Date()).toISOString();
return dateStr[dateStr.length - 1] === "Z";
}
runTestCase(testcase);
assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]');

View File

@ -4,13 +4,8 @@
/*---
es5id: 15.9.5.44-0-1
description: Date.prototype.toJSON must exist as a function
includes: [runTestCase.js]
---*/
function testcase() {
var f = Date.prototype.toJSON;
if (typeof(f) === "function") {
return true;
}
}
runTestCase(testcase);
assert.sameValue(typeof(f), "function", 'typeof(f)');

View File

@ -4,12 +4,6 @@
/*---
es5id: 15.9.5.44-0-2
description: Date.prototype.toJSON must exist as a function taking 1 parameter
includes: [runTestCase.js]
---*/
function testcase() {
if (Date.prototype.toJSON.length === 1) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(Date.prototype.toJSON.length, 1, 'Date.prototype.toJSON.length');