JavaScript Tests - handle 'race' in some Date tests, not part of the build

This commit is contained in:
bclary%bclary.com 2007-12-17 11:59:28 +00:00
Родитель 34f671c36a
Коммит 393d855038
2 изменённых файлов: 43 добавлений и 8 удалений

Просмотреть файл

@ -59,11 +59,28 @@ var TITLE = "The Date Constructor Called as a Function";
writeHeaderToLog(SECTION+" "+TITLE );
// allow up to 1 second difference due to possibility
// the date may change by 1 second in between calls to Date
var d1;
var d2;
// Dates around 1900
new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59));
new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) );
new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) );
new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0));
d1 = new Date();
d2 = Date.parse(Date(1899,11,31,23,59,59));
new TestCase( SECTION, "Date(1899,11,31,23,59,59)", true, d2 - d1 <= 1000);
d1 = new Date();
d2 = Date.parse(Date(1900,0,1,0,0,0));
new TestCase( SECTION, "Date(1900,0,1,0,0,0)", true, d2 - d1 <= 1000);
d1 = new Date();
d2 = Date.parse(Date(1900,0,1,0,0,1) );
new TestCase( SECTION, "Date(1900,0,1,0,0,1)", true, d2 - d1 <= 1000);
d1 = new Date();
d2 = Date.parse(Date(1899,11,31,16,0,0,0));
new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", true, d2 - d1 <= 1000);
test();

Просмотреть файл

@ -59,10 +59,28 @@ var TITLE = "The Date Constructor Called as a Function";
writeHeaderToLog(SECTION+" "+TITLE );
// allow up to 1 second difference due to possibility
// the date may change by 1 second in between calls to Date
var d1;
var d2;
// Dates around jan 1, 2005
new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
d1 = new Date();
d2 = Date.parse(Date(2004,11,31,23,59,59));
new TestCase( SECTION, "Date(2004,11,31,23,59,59)", true, d2 - d1 <= 1000);
d1 = new Date();
d2 = Date.parse(Date(2005,0,1,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,0)", true, d2 - d1 <= 1000);
d1 = new Date();
d2 = Date.parse(Date(2005,0,1,0,0,1) );
new TestCase( SECTION, "Date(2005,0,1,0,0,1)", true, d2 - d1 <= 1000);
d1 = new Date();
d2 = Date.parse(Date(2004,11,31,16,0,0,0));
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", true, d2 - d1 <= 1000);
test();