зеркало из https://github.com/mozilla/pjs.git
The JavaScript Test Library, Part I. ECMA v. 1.0. See the page at
http://www.mozilla.org/js/tests/library.html for information about these tests, like how to run them and stuff. According to fur, these tests should not get checked out when you check out Mozilla -- you'd have to specifically check out mozilla/js/tests to get all these files.
This commit is contained in:
Родитель
957a3aeeae
Коммит
9f52c280da
|
@ -0,0 +1,123 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4-1.js
|
||||
ECMA Section: 15.4 Array Objects
|
||||
|
||||
Description: Every Array object has a length property whose value
|
||||
is always an integer with positive sign and less than
|
||||
Math.pow(2,32).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.4-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array Objects";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]",
|
||||
"hi",
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]")
|
||||
);
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length",
|
||||
(Math.pow(2,32)-1),
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length")
|
||||
);
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]",
|
||||
"hi",
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]")
|
||||
);
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length",
|
||||
(Math.pow(2,32)-2),
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length")
|
||||
);
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]",
|
||||
"hi",
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]")
|
||||
);
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length",
|
||||
(Math.pow(2,31)-1),
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length")
|
||||
);
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]",
|
||||
"hi",
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]")
|
||||
);
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length",
|
||||
(Math.pow(2,31)),
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length")
|
||||
);
|
||||
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]",
|
||||
"hi",
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]")
|
||||
);
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length",
|
||||
(Math.pow(2,31)+1),
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length")
|
||||
);
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]",
|
||||
"hi",
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]")
|
||||
);
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length",
|
||||
(Math.pow(2,30)-1),
|
||||
eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length")
|
||||
);
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4-2.js
|
||||
ECMA Section: 15.4 Array Objects
|
||||
|
||||
Description: Whenever a property is added whose name is an array
|
||||
index, the length property is changed, if necessary,
|
||||
to be one more than the numeric value of that array
|
||||
index; and whenever the length property is changed,
|
||||
every property whose name is an array index whose value
|
||||
is not smaller than the new length is automatically
|
||||
deleted. This constraint applies only to the Array
|
||||
object itself, and is unaffected by length or array
|
||||
index properties that may be inherited from its
|
||||
prototype.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.4-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array Objects";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", Math.pow(2,16)+1, eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", Math.pow(2,30)-1, eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") );
|
||||
array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", Math.pow(2,30), eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") );
|
||||
array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", Math.pow(2,30)+1, eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", Math.pow(2,31)-1, eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") );
|
||||
array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", Math.pow(2,31), eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") );
|
||||
array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", Math.pow(2,31)+1, eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", "0,1", eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") );
|
||||
array[item++] = new TestCase( SECTION, "var arr = new Array(0,1); arr.length = 3; String(arr)", "0,1,", eval("var arr = new Array(0,1); arr.length = 3; String(arr)") );
|
||||
// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length") );
|
||||
// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test( array ) {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.1.1.js
|
||||
ECMA Section: 15.4.1 Array( item0, item1,... )
|
||||
|
||||
Description: When Array is called as a function rather than as a
|
||||
constructor, it creates and initializes a new array
|
||||
object. Thus, the function call Array(...) is
|
||||
equivalent to the object creation new Array(...) with
|
||||
the same arguments.
|
||||
|
||||
An array is created and returned as if by the expression
|
||||
new Array( item0, item1, ... ).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.1.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function ToUint32( n ) {
|
||||
n = Number( n );
|
||||
if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY ||
|
||||
n == Number.NEGATIVE_INFINITY ) {
|
||||
return 0;
|
||||
}
|
||||
var sign = n < 0 ? -1 : 1;
|
||||
|
||||
return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32);
|
||||
}
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "typeof Array(1,2)", "object", typeof Array(1,2) );
|
||||
array[item++] = new TestCase( SECTION, "(Array(1,2)).toString", Array.prototype.toString, (Array(1,2)).toString );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()",
|
||||
"[object Array]",
|
||||
eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") );
|
||||
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(Array(1,2)).length", 2, (Array(1,2)).length );
|
||||
array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[0]", 1, eval("var arr = (Array(1,2)); arr[0]") );
|
||||
array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[1]", 2, eval("var arr = (Array(1,2)); arr[1]") );
|
||||
array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); String(arr)", "1,2", eval("var arr = (Array(1,2)); String(arr)") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.1.2.js
|
||||
ECMA Section: 15.4.1.2 Array(len)
|
||||
|
||||
Description: When Array is called as a function rather than as a
|
||||
constructor, it creates and initializes a new array
|
||||
object. Thus, the function call Array(...) is
|
||||
equivalent to the object creationi new Array(...) with
|
||||
the same arguments.
|
||||
|
||||
An array is created and returned as if by the
|
||||
expression new Array(len).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.1.2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array Constructor Called as a Function: Array(len)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(Array()).length", 0, (Array()).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(0)).length", 0, (Array(0)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(1)).length", 1, (Array(1)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(-1)).length", ToUint32(-1), (Array(-1)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(10)).length", 10, (Array(10)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array('1')).length", 1, (Array('1')).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(1000)).length", 1000, (Array(1000)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array('1000')).length", 1, (Array('1000')).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(4294967295)).length", ToUint32(4294967295), (Array(4294967295)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(4294967296)).length", ToUint32(4294967296), (Array(4294967296)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(4294967297)).length", ToUint32(4294967297), (Array(4294967297)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)-1)).length", ToUint32(Math.pow(2,31)-1), (Array(Math.pow(2,31)-1)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31))).length", ToUint32(Math.pow(2,31)), (Array(Math.pow(2,31))).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)+1)).length", ToUint32(Math.pow(2,31)+1), (Array(Math.pow(2,31)+1)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(8589934592)).length", ToUint32(8589934592), (Array(8589934592)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array('8589934592')).length", 1, (Array("8589934592")).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array('4294967296')).length", 1, (Array("4294967296")).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(3.14159)).length", ToUint32(3.14159), (Array(3.14159)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(-3.14159)).length", ToUint32(-3.14159), (Array(-3.14159)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(1073741823)).length", ToUint32(1073741823), (Array(1073741823)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array(1073741824)).length", ToUint32(1073741824), (Array(1073741824)).length );
|
||||
array[item++] = new TestCase( SECTION, "(Array('a string')).length", 1, (Array("a string")).length );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function ToUint32( n ) {
|
||||
n = Number( n );
|
||||
var sign = ( n < 0 ) ? -1 : 1;
|
||||
|
||||
if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) {
|
||||
return 0;
|
||||
}
|
||||
n = sign * Math.floor( Math.abs(n) )
|
||||
|
||||
n = n % Math.pow(2,32);
|
||||
|
||||
if ( n < 0 ){
|
||||
n += Math.pow(2,32);
|
||||
}
|
||||
|
||||
return ( n );
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.1.3.js
|
||||
ECMA Section: 15.4.1.3 Array()
|
||||
|
||||
Description: When Array is called as a function rather than as a
|
||||
constructor, it creates and initializes a new array
|
||||
object. Thus, the function call Array(...) is
|
||||
equivalent to the object creationi new Array(...) with
|
||||
the same arguments.
|
||||
|
||||
An array is created and returned as if by the
|
||||
expression new Array(len).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.1.3";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array Constructor Called as a Function: Array()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"typeof Array()",
|
||||
"object",
|
||||
typeof Array() );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"MYARR = new Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()",
|
||||
"[object Array]",
|
||||
eval("MYARR = Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"(Array()).length",
|
||||
0, (
|
||||
Array()).length );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Array().toString()",
|
||||
"",
|
||||
Array().toString() );
|
||||
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.1.js
|
||||
ECMA Section: 15.4.1 The Array Constructor Called as a Function
|
||||
|
||||
Description: When Array is called as a function rather than as a
|
||||
constructor, it creates and initializes a new array
|
||||
object. Thus, the function call Array(...) is
|
||||
equivalent to the object creationi new Array(...) with
|
||||
the same arguments.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Array Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Array() +''",
|
||||
"",
|
||||
Array() +"" );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"typeof Array()",
|
||||
"object",
|
||||
typeof Array() );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
|
||||
"[object Array]",
|
||||
eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = Array(); arr.toString == Array.prototype.toString",
|
||||
true,
|
||||
eval("var arr = Array(); arr.toString == Array.prototype.toString") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Array().length",
|
||||
0,
|
||||
Array().length );
|
||||
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Array(1,2,3) +''",
|
||||
"1,2,3",
|
||||
Array(1,2,3) +"" );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"typeof Array(1,2,3)",
|
||||
"object",
|
||||
typeof Array(1,2,3) );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
|
||||
"[object Array]",
|
||||
eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = Array(1,2,3); arr.toString == Array.prototype.toString",
|
||||
true,
|
||||
eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Array(1,2,3).length",
|
||||
3,
|
||||
Array(1,2,3).length );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"typeof Array(12345)",
|
||||
"object",
|
||||
typeof Array(12345) );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()",
|
||||
"[object Array]",
|
||||
eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString",
|
||||
true,
|
||||
eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Array(12345).length",
|
||||
12345,
|
||||
Array(12345).length );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for (tc=0 ; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.2.1-1.js
|
||||
ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
|
||||
Description: This description only applies of the constructor is
|
||||
given two or more arguments.
|
||||
|
||||
The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Array prototype object,
|
||||
the one that is the initial value of Array.prototype
|
||||
(15.4.3.1).
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set to "Array".
|
||||
|
||||
The length property of the newly constructed object is
|
||||
set to the number of arguments.
|
||||
|
||||
The 0 property of the newly constructed object is set
|
||||
to item0... in general, for as many arguments as there
|
||||
are, the k property of the newly constructed object is
|
||||
set to argument k, where the first argument is
|
||||
considered to be argument number 0.
|
||||
|
||||
This file tests the typeof the newly constructed object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.2.1-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "typeof new Array(1,2)", "object", typeof new Array(1,2) );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(1,2)).toString", Array.prototype.toString, (new Array(1,2)).toString );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
|
||||
"[object Array]",
|
||||
eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array(1,2)).length", 2, (new Array(1,2)).length );
|
||||
array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[0]", 1, eval("var arr = (new Array(1,2)); arr[0]") );
|
||||
array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[1]", 2, eval("var arr = (new Array(1,2)); arr[1]") );
|
||||
array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); String(arr)", "1,2", eval("var arr = (new Array(1,2)); String(arr)") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.2.1-2.js
|
||||
ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
|
||||
Description: This description only applies of the constructor is
|
||||
given two or more arguments.
|
||||
|
||||
The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Array prototype object,
|
||||
the one that is the initial value of Array.prototype
|
||||
(15.4.3.1).
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set to "Array".
|
||||
|
||||
The length property of the newly constructed object is
|
||||
set to the number of arguments.
|
||||
|
||||
The 0 property of the newly constructed object is set
|
||||
to item0... in general, for as many arguments as there
|
||||
are, the k property of the newly constructed object is
|
||||
set to argument k, where the first argument is
|
||||
considered to be argument number 0.
|
||||
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.2.1-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
testcases = getTestCases();
|
||||
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
|
||||
var TEST_STRING = "new Array(";
|
||||
var ARGUMENTS = ""
|
||||
var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
|
||||
|
||||
for ( var index = 0; index < TEST_LENGTH; index++ ) {
|
||||
ARGUMENTS += index;
|
||||
ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
|
||||
}
|
||||
|
||||
TEST_STRING += ARGUMENTS + ")";
|
||||
|
||||
TEST_ARRAY = eval( TEST_STRING );
|
||||
|
||||
for ( item = 0; item < TEST_LENGTH; item++ ) {
|
||||
array[item] = new TestCase( SECTION, "["+item+"]", item, TEST_ARRAY[item] );
|
||||
}
|
||||
|
||||
array[item++ ] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" );
|
||||
|
||||
return ( array );
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.2.1-3.js
|
||||
ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
|
||||
Description: This description only applies of the constructor is
|
||||
given two or more arguments.
|
||||
|
||||
The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Array prototype object,
|
||||
the one that is the initial value of Array.prototype
|
||||
(15.4.3.1).
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set to "Array".
|
||||
|
||||
The length property of the newly constructed object is
|
||||
set to the number of arguments.
|
||||
|
||||
The 0 property of the newly constructed object is set
|
||||
to item0... in general, for as many arguments as there
|
||||
are, the k property of the newly constructed object is
|
||||
set to argument k, where the first argument is
|
||||
considered to be argument number 0.
|
||||
|
||||
This test stresses the number of arguments presented to
|
||||
the Array constructor. Should support up to Math.pow
|
||||
(2,32) arguments, since that is the maximum length of an
|
||||
ECMAScript array.
|
||||
|
||||
***Change TEST_LENGTH to Math.pow(2,32) when larger array
|
||||
lengths are supported.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.2.1-3";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
|
||||
var TEST_STRING = "new Array(";
|
||||
var ARGUMENTS = ""
|
||||
var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
|
||||
|
||||
for ( var index = 0; index < TEST_LENGTH; index++ ) {
|
||||
ARGUMENTS += index;
|
||||
ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
|
||||
}
|
||||
|
||||
TEST_STRING += ARGUMENTS + ")";
|
||||
|
||||
TEST_ARRAY = eval( TEST_STRING );
|
||||
|
||||
for ( item = 0; item < TEST_LENGTH; item++ ) {
|
||||
array[item] = new TestCase( SECTION, "TEST_ARRAY["+item+"]", item, TEST_ARRAY[item] );
|
||||
}
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" );
|
||||
array[item++] = new TestCase( SECTION, "TEST_ARRAY.toString", Array.prototype.toString, TEST_ARRAY.toString );
|
||||
array[item++] = new TestCase( SECTION, "TEST_ARRAY.join", Array.prototype.join, TEST_ARRAY.join );
|
||||
array[item++] = new TestCase( SECTION, "TEST_ARRAY.sort", Array.prototype.sort, TEST_ARRAY.sort );
|
||||
array[item++] = new TestCase( SECTION, "TEST_ARRAY.reverse", Array.prototype.reverse, TEST_ARRAY.reverse );
|
||||
array[item++] = new TestCase( SECTION, "TEST_ARRAY.length", TEST_LENGTH, TEST_ARRAY.length );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()",
|
||||
"[object Array]",
|
||||
eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.2.2-1.js
|
||||
ECMA Section: 15.4.2.2 new Array(len)
|
||||
|
||||
Description: This description only applies of the constructor is
|
||||
given two or more arguments.
|
||||
|
||||
The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Array prototype object,
|
||||
the one that is the initial value of Array.prototype(0)
|
||||
(15.4.3.1).
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set to "Array".
|
||||
|
||||
If the argument len is a number, then the length
|
||||
property of the newly constructed object is set to
|
||||
ToUint32(len).
|
||||
|
||||
If the argument len is not a number, then the length
|
||||
property of the newly constructed object is set to 1
|
||||
and the 0 property of the newly constructed object is
|
||||
set to len.
|
||||
|
||||
This file tests cases where len is a number.
|
||||
|
||||
The cases in this test need to be updated since the
|
||||
ToUint32 description has changed.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.2.2-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Array Constructor: new Array( len )";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Array(0)", "", (new Array(0)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Array(0)", "object", (typeof new Array(0)) );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(0)).toString", Array.prototype.toString, (new Array(0)).toString );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Array(1)", "", (new Array(1)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Array(1).length", 1, (new Array(1)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(1)).toString", Array.prototype.toString, (new Array(1)).toString );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array(Number.NaN)).length", 0, (new Array(Number.NaN)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(Number.POSITIVE_INFINITY)).length", 0, (new Array(Number.POSITIVE_INFINITY)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(Number.NEGATIVE_INFINITY)).length", 0, (new Array(Number.NEGATIVE_INFINITY)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(-0)).length", 0, (new Array(-0)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array(-1000)).length", ToUint32(-1000), (new Array(-1000)).length );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array(10)).length", 10, (new Array(10)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array('1')).length", 1, (new Array('1')).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(1000)).length", 1000, (new Array(1000)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array('1000')).length", 1, (new Array('1000')).length );
|
||||
|
||||
// array[item++] = new TestCase( SECTION, "(new Array(4294967295)).length", ToUint32(4294967295), (new Array(4294967295)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(4294967296)).length", ToUint32(4294967296), (new Array(4294967296)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(4294967297)).length", ToUint32(4294967297), (new Array(4294967297)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(4294967298)).length", ToUint32(4294967298), (new Array(4294967298)).length );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array(8589934592)).length", ToUint32(8589934592), (new Array(8589934592)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array('8589934592')).length", 1, (new Array("8589934592")).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array('4294967296')).length", 1, (new Array("4294967296")).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(3.14159)).length", ToUint32(3.14159), (new Array(3.14159)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(-3.14159)).length", ToUint32(-3.14159), (new Array(-3.14159)).length );
|
||||
// array[item++] = new TestCase( SECTION, "(new Array(1073741823)).length", ToUint32(1073741823), (new Array(1073741823)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(1073741824)).length", ToUint32(1073741824), (new Array(1073741824)).length );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed )
|
||||
? ""
|
||||
: "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function ToUint32( n ) {
|
||||
n = Number( n );
|
||||
var sign = ( n < 0 ) ? -1 : 1;
|
||||
|
||||
if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) {
|
||||
return 0;
|
||||
}
|
||||
n = sign * Math.floor( Math.abs(n) )
|
||||
|
||||
n = n % Math.pow(2,32);
|
||||
|
||||
if ( n < 0 ){
|
||||
n += Math.pow(2,32);
|
||||
}
|
||||
|
||||
return ( n );
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.2.2-2.js
|
||||
ECMA Section: 15.4.2.2 new Array(len)
|
||||
|
||||
Description: This description only applies of the constructor is
|
||||
given two or more arguments.
|
||||
|
||||
The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Array prototype object,
|
||||
the one that is the initial value of Array.prototype(0)
|
||||
(15.4.3.1).
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set to "Array".
|
||||
|
||||
If the argument len is a number, then the length
|
||||
property of the newly constructed object is set to
|
||||
ToUint32(len).
|
||||
|
||||
If the argument len is not a number, then the length
|
||||
property of the newly constructed object is set to 1
|
||||
and the 0 property of the newly constructed object is
|
||||
set to len.
|
||||
|
||||
This file tests length of the newly constructed array
|
||||
when len is not a number.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.2.2-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Array Constructor: new Array( len )";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array(new Number(1073741823))).length", 1, (new Array(new Number(1073741823))).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(new Number(0))).length", 1, (new Array(new Number(0))).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(new Number(1000))).length", 1, (new Array(new Number(1000))).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array('mozilla, larryzilla, curlyzilla')).length", 1, (new Array('mozilla, larryzilla, curlyzilla')).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(true)).length", 1, (new Array(true)).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(false)).length", 1, (new Array(false)).length);
|
||||
array[item++] = new TestCase( SECTION, "(new Array(new Boolean(true)).length", 1, (new Array(new Boolean(true))).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(new Boolean(false)).length", 1, (new Array(new Boolean(false))).length );
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed )
|
||||
? ""
|
||||
: "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.2.3.js
|
||||
ECMA Section: 15.4.2.3 new Array()
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the origianl Array prototype object,
|
||||
the one that is the initial value of Array.prototype.
|
||||
The [[Class]] property of the new object is set to
|
||||
"Array". The length of the object is set to 0.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.2.3";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Array Constructor: new Array()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
array[item++] = new TestCase( SECTION, "new Array() +''", "", (new Array()) +"" );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Array()", "object", (typeof new Array()) );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
|
||||
"[object Array]",
|
||||
eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array()).length", 0, (new Array()).length );
|
||||
array[item++] = new TestCase( SECTION, "(new Array()).toString == Array.prototype.toString", true, (new Array()).toString == Array.prototype.toString );
|
||||
array[item++] = new TestCase( SECTION, "(new Array()).join == Array.prototype.join", true, (new Array()).join == Array.prototype.join );
|
||||
array[item++] = new TestCase( SECTION, "(new Array()).reverse == Array.prototype.reverse", true, (new Array()).reverse == Array.prototype.reverse );
|
||||
array[item++] = new TestCase( SECTION, "(new Array()).sort == Array.prototype.sort", true, (new Array()).sort == Array.prototype.sort );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.3.1-1.js
|
||||
ECMA Section: 15.4.3.1 Array.prototype
|
||||
Description: The initial value of Array.prototype is the built-in
|
||||
Array prototype object (15.4.4).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.3.1-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.prototype";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
var ARRAY_PROTO = Array.prototype;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "var props = ''; for ( p in Array ) { props += p } props", "", eval("var props = ''; for ( p in Array ) { props += p } props") );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Array.prototype = null; Array.prototype", ARRAY_PROTO, eval("Array.prototype = null; Array.prototype") );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "delete Array.prototype", false, delete Array.prototype );
|
||||
array[item++] = new TestCase( SECTION, "delete Array.prototype; Array.prototype", ARRAY_PROTO, eval("delete Array.prototype; Array.prototype") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.3.2.js
|
||||
ECMA Section: 15.4.3.2 Array.length
|
||||
Description: The length property is 1.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.3.2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.length";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
array[item++] = new TestCase( SECTION, "Array.length", 1, Array.length );
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.3.js
|
||||
ECMA Section: 15.4.3 Properties of the Array Constructor
|
||||
Description: The value of the internal [[Prototype]] property of the
|
||||
Array constructor is the Function prototype object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.3";
|
||||
var VERSION = "ECMA_2";
|
||||
startTest();
|
||||
var TITLE = "Properties of the Array Constructor";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for (tc=0 ; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
|
||||
stopTest();
|
||||
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.1.js
|
||||
ECMA Section: 15.4.4.1 Array.prototype.constructor
|
||||
Description: The initial value of Array.prototype.constructor
|
||||
is the built-in Array constructor.
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.4.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.prototype.constructor";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
array[item++] = new TestCase( SECTION, "Array.prototype.constructor == Array", true, Array.prototype.constructor == Array);
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for (tc=0 ; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.2.js
|
||||
ECMA Section: 15.4.4.2 Array.prototype.toString()
|
||||
Description: The elements of this object are converted to strings
|
||||
and these strings are then concatenated, separated by
|
||||
comma characters. The result is the same as if the
|
||||
built-in join method were invoiked for this object
|
||||
with no argument.
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.4.2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.prototype.toString";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Array.prototype.toString.length", 0, Array.prototype.toString.length );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array()).toString()", "", (new Array()).toString() );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(2)).toString()", ",", (new Array(2)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(0,1)).toString()", "0,1", (new Array(0,1)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", "NaN,Infinity,-Infinity", (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array( Boolean(1), Boolean(0))).toString()", "true,false", (new Array(Boolean(1),Boolean(0))).toString() );
|
||||
array[item++] = new TestCase( SECTION, "(new Array(void 0,null)).toString()", ",", (new Array(void 0,null)).toString() );
|
||||
|
||||
var EXPECT_STRING = "";
|
||||
var MYARR = new Array();
|
||||
|
||||
for ( var i = -50; i < 50; i+= 0.25 ) {
|
||||
MYARR[MYARR.length] = i;
|
||||
EXPECT_STRING += i +",";
|
||||
}
|
||||
|
||||
EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "MYARR.toString()", EXPECT_STRING, MYARR.toString() );
|
||||
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0 ; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.3-1.js
|
||||
ECMA Section: 15.4.4.3-1 Array.prototype.join()
|
||||
Description: The elements of this object are converted to strings
|
||||
and these strings are then concatenated, separated by
|
||||
comma characters. The result is the same as if the
|
||||
built-in join method were invoiked for this object
|
||||
with no argument.
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.4.3-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
|
||||
writeHeaderToLog( SECTION + " Array.prototype.join()");
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
var ARR_PROTOTYPE = Array.prototype;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length );
|
||||
array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length );
|
||||
array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") );
|
||||
|
||||
// case where array length is 0
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(); TEST_ARRAY.join()",
|
||||
"",
|
||||
eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join()") );
|
||||
|
||||
// array length is 0, but spearator is specified
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')",
|
||||
"",
|
||||
eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')") );
|
||||
|
||||
// length is greater than 0, separator is supplied
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')",
|
||||
"&&true&false&123&[object Object]&true",
|
||||
eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')") );
|
||||
|
||||
// length is greater than 0, separator is empty string
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')",
|
||||
"truefalse123[object Object]true",
|
||||
eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')") );
|
||||
// length is greater than 0, separator is undefined
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)",
|
||||
"undefinedundefinedtrueundefinedfalseundefined123undefined[object Object]undefinedtrue",
|
||||
eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)") );
|
||||
|
||||
// length is greater than 0, separator is not supplied
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()",
|
||||
",,true,false,123,[object Object],true",
|
||||
eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()") );
|
||||
|
||||
// separator is a control character
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')",
|
||||
unescape("%u000B%u000Btrue%u000Bfalse%u000B123%u000B[object Object]%u000Btrue"),
|
||||
eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')") );
|
||||
|
||||
// length of array is 1
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var TEST_ARRAY = new Array(true) ); TEST_ARRAY.join('\v')",
|
||||
"true",
|
||||
eval("var TEST_ARRAY = new Array(true); TEST_ARRAY.join('\v')") );
|
||||
|
||||
|
||||
SEPARATOR = "\t"
|
||||
TEST_LENGTH = 100;
|
||||
TEST_STRING = "";
|
||||
ARGUMENTS = "";
|
||||
TEST_RESULT = "";
|
||||
|
||||
for ( var index = 0; index < TEST_LENGTH; index++ ) {
|
||||
ARGUMENTS += index;
|
||||
ARGUMENTS += ( index == TEST_LENGTH -1 ) ? "" : ",";
|
||||
|
||||
TEST_RESULT += index;
|
||||
TEST_RESULT += ( index == TEST_LENGTH -1 ) ? "" : SEPARATOR;
|
||||
}
|
||||
|
||||
TEST_ARRAY = eval( "new Array( "+ARGUMENTS +")" );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "TEST_ARRAY.join("+SEPARATOR+")", TEST_RESULT, TEST_ARRAY.join( SEPARATOR ) );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "(new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join()",
|
||||
"true,false,,,1e+21,1e-7",
|
||||
(new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join() );
|
||||
|
||||
// this is not an Array object
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')",
|
||||
"true:false:111:0.5:1230000:NaN::",
|
||||
eval("var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')") );
|
||||
|
||||
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function Object_1( value ) {
|
||||
this.array = value.split(",");
|
||||
this.length = this.array.length;
|
||||
for ( var i = 0; i < this.length; i++ ) {
|
||||
this[i] = eval(this.array[i]);
|
||||
}
|
||||
this.join = Array.prototype.join;
|
||||
this.getClass = Object.prototype.toString;
|
||||
}
|
|
@ -0,0 +1,269 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.3-1.js
|
||||
ECMA Section: 15.4.4.3-1 Array.prototype.reverse()
|
||||
Description:
|
||||
|
||||
The elements of the array are rearranged so as to reverse their order.
|
||||
This object is returned as the result of the call.
|
||||
|
||||
1. Call the [[Get]] method of this object with argument "length".
|
||||
2. Call ToUint32(Result(1)).
|
||||
3. Compute floor(Result(2)/2).
|
||||
4. Let k be 0.
|
||||
5. If k equals Result(3), return this object.
|
||||
6. Compute Result(2)k1.
|
||||
7. Call ToString(k).
|
||||
8. ToString(Result(6)).
|
||||
9. Call the [[Get]] method of this object with argument Result(7).
|
||||
10. Call the [[Get]] method of this object with argument Result(8).
|
||||
11. If this object has a property named by Result(8), go to step 12; but
|
||||
if this object has no property named by Result(8), then go to either
|
||||
step 12 or step 14, depending on the implementation.
|
||||
12. Call the [[Put]] method of this object with arguments Result(7) and
|
||||
Result(10).
|
||||
13. Go to step 15.
|
||||
14. Call the [[Delete]] method on this object, providing Result(7) as the
|
||||
name of the property to delete.
|
||||
15. If this object has a property named by Result(7), go to step 16; but if
|
||||
this object has no property named by Result(7), then go to either step 16
|
||||
or step 18, depending on the implementation.
|
||||
16. Call the [[Put]] method of this object with arguments Result(8) and
|
||||
Result(9).
|
||||
17. Go to step 19.
|
||||
18. Call the [[Delete]] method on this object, providing Result(8) as the
|
||||
name of the property to delete.
|
||||
19. Increase k by 1.
|
||||
20. Go to step 5.
|
||||
|
||||
Note that the reverse function is intentionally generic; it does not require
|
||||
that its this value be an Array object. Therefore it can be transferred to other
|
||||
kinds of objects for use as a method. Whether the reverse function can be applied
|
||||
successfully to a host object is implementation dependent.
|
||||
|
||||
Note: Array.prototype.reverse allows some flexibility in implementation
|
||||
regarding array indices that have not been populated. This test covers the
|
||||
cases in which unpopulated indices are not deleted, since the JavaScript
|
||||
implementation does not delete uninitialzed indices.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
var SECTION = "15.4.4.4-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var BUGNUMBER="123724";
|
||||
|
||||
writeHeaderToLog( SECTION + " Array.prototype.reverse()");
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var ARR_PROTOTYPE = Array.prototype;
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length );
|
||||
testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length );
|
||||
testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") );
|
||||
|
||||
// length of array is 0
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.reverse(); A.length",
|
||||
0,
|
||||
eval("var A = new Array(); A.reverse(); A.length") );
|
||||
|
||||
// length of array is 1
|
||||
var A = new Array(true);
|
||||
var R = Reverse(A);
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
"var A = new Array(true); A.reverse(); A.length",
|
||||
R.length,
|
||||
eval("var A = new Array(true); A.reverse(); A.length") );
|
||||
CheckItems( R, A );
|
||||
|
||||
// length of array is 2
|
||||
var S = "var A = new Array( true,false )";
|
||||
eval(S);
|
||||
var R = Reverse(A);
|
||||
|
||||
testcases[testcases.length] = new TestCase(
|
||||
SECTION,
|
||||
S +"; A.reverse(); A.length",
|
||||
R.length,
|
||||
eval( S + "; A.reverse(); A.length") );
|
||||
|
||||
CheckItems( R, A );
|
||||
|
||||
// length of array is 3
|
||||
var S = "var A = new Array( true,false,null )";
|
||||
eval(S);
|
||||
var R = Reverse(A);
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.reverse(); A.length",
|
||||
R.length,
|
||||
eval( S + "; A.reverse(); A.length") );
|
||||
CheckItems( R, A );
|
||||
|
||||
// length of array is 4
|
||||
var S = "var A = new Array( true,false,null,void 0 )";
|
||||
eval(S);
|
||||
var R = Reverse(A);
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.reverse(); A.length",
|
||||
R.length,
|
||||
eval( S + "; A.reverse(); A.length") );
|
||||
CheckItems( R, A );
|
||||
|
||||
|
||||
// some array indexes have not been set
|
||||
var S = "var A = new Array(); A[8] = 'hi', A[3] = 'yo'";
|
||||
eval(S);
|
||||
var R = Reverse(A);
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.reverse(); A.length",
|
||||
R.length,
|
||||
eval( S + "; A.reverse(); A.length") );
|
||||
CheckItems( R, A );
|
||||
|
||||
|
||||
var OBJECT_OBJECT = new Object();
|
||||
var FUNCTION_OBJECT = new Function( 'return this' );
|
||||
var BOOLEAN_OBJECT = new Boolean;
|
||||
var DATE_OBJECT = new Date(0);
|
||||
var STRING_OBJECT = new String('howdy');
|
||||
var NUMBER_OBJECT = new Number(Math.PI);
|
||||
var ARRAY_OBJECT= new Array(1000);
|
||||
|
||||
var args = "null, void 0, Math.pow(2,32), 1.234e-32, OBJECT_OBJECT, BOOLEAN_OBJECT, FUNCTION_OBJECT, DATE_OBJECT, STRING_OBJECT,"+
|
||||
"ARRAY_OBJECT, NUMBER_OBJECT, Math, true, false, 123, '90210'";
|
||||
|
||||
var S = "var A = new Array("+args+")";
|
||||
eval(S);
|
||||
var R = Reverse(A);
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.reverse(); A.length",
|
||||
R.length,
|
||||
eval( S + "; A.reverse(); A.length") );
|
||||
CheckItems( R, A );
|
||||
|
||||
var limit = 1000;
|
||||
var args = "";
|
||||
for (var i = 0; i < limit; i++ ) {
|
||||
args += i +"";
|
||||
if ( i + 1 < limit ) {
|
||||
args += ",";
|
||||
}
|
||||
}
|
||||
|
||||
var S = "var A = new Array("+args+")";
|
||||
eval(S);
|
||||
var R = Reverse(A);
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.reverse(); A.length",
|
||||
R.length,
|
||||
eval( S + "; A.reverse(); A.length") );
|
||||
CheckItems( R, A );
|
||||
|
||||
var S = "var MYOBJECT = new Object_1( \"void 0, 1, null, 2, \'\'\" )";
|
||||
eval(S);
|
||||
var R = Reverse( A );
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.reverse(); A.length",
|
||||
R.length,
|
||||
eval( S + "; A.reverse(); A.length") );
|
||||
CheckItems( R, A );
|
||||
|
||||
return ( testcases );
|
||||
}
|
||||
function CheckItems( R, A ) {
|
||||
for ( var i = 0; i < R.length; i++ ) {
|
||||
testcases[testcases.length] = new TestCase(
|
||||
SECTION,
|
||||
"A["+i+ "]",
|
||||
R[i],
|
||||
A[i] );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function Object_1( value ) {
|
||||
this.array = value.split(",");
|
||||
this.length = this.array.length;
|
||||
for ( var i = 0; i < this.length; i++ ) {
|
||||
this[i] = eval(this.array[i]);
|
||||
}
|
||||
this.join = Array.prototype.reverse;
|
||||
this.getClass = Object.prototype.toString;
|
||||
}
|
||||
function Reverse( array ) {
|
||||
var r2 = array.length;
|
||||
var k = 0;
|
||||
var r3 = Math.floor( r2/2 );
|
||||
if ( r3 == k ) {
|
||||
return array;
|
||||
}
|
||||
|
||||
for ( k = 0; k < r3; k++ ) {
|
||||
var r6 = r2 - k - 1;
|
||||
// var r7 = String( k );
|
||||
var r7 = k;
|
||||
var r8 = String( r6 );
|
||||
|
||||
var r9 = array[r7];
|
||||
var r10 = array[r8];
|
||||
|
||||
array[r7] = r10;
|
||||
array[r8] = r9;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
function Iterate( array ) {
|
||||
for ( var i = 0; i < array.length; i++ ) {
|
||||
// print( i+": "+ array[String(i)] );
|
||||
}
|
||||
}
|
||||
|
||||
function Object_1( value ) {
|
||||
this.array = value.split(",");
|
||||
this.length = this.array.length;
|
||||
for ( var i = 0; i < this.length; i++ ) {
|
||||
this[i] = this.array[i];
|
||||
}
|
||||
this.reverse = Array.prototype.reverse;
|
||||
this.getClass = Object.prototype.toString;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.3-1.js
|
||||
ECMA Section: 15.4.4.3-1 Array.prototype.reverse()
|
||||
Description:
|
||||
|
||||
The elements of the array are rearranged so as to reverse their order.
|
||||
This object is returned as the result of the call.
|
||||
|
||||
1. Call the [[Get]] method of this object with argument "length".
|
||||
2. Call ToUint32(Result(1)).
|
||||
3. Compute floor(Result(2)/2).
|
||||
4. Let k be 0.
|
||||
5. If k equals Result(3), return this object.
|
||||
6. Compute Result(2)k1.
|
||||
7. Call ToString(k).
|
||||
8. ToString(Result(6)).
|
||||
9. Call the [[Get]] method of this object with argument Result(7).
|
||||
10. Call the [[Get]] method of this object with argument Result(8).
|
||||
11. If this object has a property named by Result(8), go to step 12; but
|
||||
if this object has no property named by Result(8), then go to either
|
||||
step 12 or step 14, depending on the implementation.
|
||||
12. Call the [[Put]] method of this object with arguments Result(7) and
|
||||
Result(10).
|
||||
13. Go to step 15.
|
||||
14. Call the [[Delete]] method on this object, providing Result(7) as the
|
||||
name of the property to delete.
|
||||
15. If this object has a property named by Result(7), go to step 16; but if
|
||||
this object has no property named by Result(7), then go to either step 16
|
||||
or step 18, depending on the implementation.
|
||||
16. Call the [[Put]] method of this object with arguments Result(8) and
|
||||
Result(9).
|
||||
17. Go to step 19.
|
||||
18. Call the [[Delete]] method on this object, providing Result(8) as the
|
||||
name of the property to delete.
|
||||
19. Increase k by 1.
|
||||
20. Go to step 5.
|
||||
|
||||
Note that the reverse function is intentionally generic; it does not require
|
||||
that its this value be an Array object. Therefore it can be transferred to other
|
||||
kinds of objects for use as a method. Whether the reverse function can be applied
|
||||
successfully to a host object is implementation dependent.
|
||||
|
||||
Note: Array.prototype.reverse allows some flexibility in implementation
|
||||
regarding array indices that have not been populated. This test covers the
|
||||
cases in which unpopulated indices are not deleted, since the JavaScript
|
||||
implementation does not delete uninitialzed indices.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.4.4-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var testcases = new Array();
|
||||
|
||||
writeHeaderToLog( SECTION + " Array.prototype.reverse()");
|
||||
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var ARR_PROTOTYPE = Array.prototype;
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length );
|
||||
testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length );
|
||||
testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") );
|
||||
|
||||
// length of array is 0
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.reverse(); A.length",
|
||||
0,
|
||||
eval("var A = new Array(); A.reverse(); A.length") );
|
||||
return ( testcases );
|
||||
}
|
||||
function CheckItems( R, A ) {
|
||||
for ( var i = 0; i < R.length; i++ ) {
|
||||
testcases[testcases.length] = new TestCase(
|
||||
SECTION,
|
||||
"A["+i+ "]",
|
||||
R[i],
|
||||
A[i] );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function Object_1( value ) {
|
||||
this.array = value.split(",");
|
||||
this.length = this.array.length;
|
||||
for ( var i = 0; i < this.length; i++ ) {
|
||||
this[i] = eval(this.array[i]);
|
||||
}
|
||||
this.join = Array.prototype.reverse;
|
||||
this.getClass = Object.prototype.toString;
|
||||
}
|
||||
function Reverse( array ) {
|
||||
var r2 = array.length;
|
||||
var k = 0;
|
||||
var r3 = Math.floor( r2/2 );
|
||||
if ( r3 == k ) {
|
||||
return array;
|
||||
}
|
||||
|
||||
for ( k = 0; k < r3; k++ ) {
|
||||
var r6 = r2 - k - 1;
|
||||
// var r7 = String( k );
|
||||
var r7 = k;
|
||||
var r8 = String( r6 );
|
||||
|
||||
var r9 = array[r7];
|
||||
var r10 = array[r8];
|
||||
|
||||
array[r7] = r10;
|
||||
array[r8] = r9;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
function Iterate( array ) {
|
||||
for ( var i = 0; i < array.length; i++ ) {
|
||||
// print( i+": "+ array[String(i)] );
|
||||
}
|
||||
}
|
||||
|
||||
function Object_1( value ) {
|
||||
this.array = value.split(",");
|
||||
this.length = this.array.length;
|
||||
for ( var i = 0; i < this.length; i++ ) {
|
||||
this[i] = this.array[i];
|
||||
}
|
||||
this.reverse = Array.prototype.reverse;
|
||||
this.getClass = Object.prototype.toString;
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.5.js
|
||||
ECMA Section: Array.prototype.sort(comparefn)
|
||||
Description:
|
||||
|
||||
This test file tests cases in which the compare function is not supplied.
|
||||
|
||||
The elements of this array are sorted. The sort is not necessarily stable.
|
||||
If comparefn is provided, it should be a function that accepts two arguments
|
||||
x and y and returns a negative value if x < y, zero if x = y, or a positive
|
||||
value if x > y.
|
||||
|
||||
1. Call the [[Get]] method of this object with argument "length".
|
||||
2. Call ToUint32(Result(1)).
|
||||
1. Perform an implementation-dependent sequence of calls to the
|
||||
[[Get]] , [[Put]], and [[Delete]] methods of this object and
|
||||
toSortCompare (described below), where the first argument for each call
|
||||
to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less
|
||||
than Result(2) and where the arguments for calls to SortCompare are
|
||||
results of previous calls to the [[Get]] method. After this sequence
|
||||
is complete, this object must have the following two properties.
|
||||
(1) There must be some mathematical permutation of the nonnegative
|
||||
integers less than Result(2), such that for every nonnegative integer
|
||||
j less than Result(2), if property old[j] existed, then new[(j)] is
|
||||
exactly the same value as old[j],. but if property old[j] did not exist,
|
||||
then new[(j)] either does not exist or exists with value undefined.
|
||||
(2) If comparefn is not supplied or is a consistent comparison
|
||||
function for the elements of this array, then for all nonnegative
|
||||
integers j and k, each less than Result(2), if old[j] compares less
|
||||
than old[k] (see SortCompare below), then (j) < (k). Here we use the
|
||||
notation old[j] to refer to the hypothetical result of calling the [
|
||||
[Get]] method of this object with argument j before this step is
|
||||
executed, and the notation new[j] to refer to the hypothetical result
|
||||
of calling the [[Get]] method of this object with argument j after this
|
||||
step has been completely executed. A function is a consistent
|
||||
comparison function for a set of values if (a) for any two of those
|
||||
values (possibly the same value) considered as an ordered pair, it
|
||||
always returns the same value when given that pair of values as its
|
||||
two arguments, and the result of applying ToNumber to this value is
|
||||
not NaN; (b) when considered as a relation, where the pair (x, y) is
|
||||
considered to be in the relation if and only if applying the function
|
||||
to x and y and then applying ToNumber to the result produces a
|
||||
negative value, this relation is a partial order; and (c) when
|
||||
considered as a different relation, where the pair (x, y) is considered
|
||||
to be in the relation if and only if applying the function to x and y
|
||||
and then applying ToNumber to the result produces a zero value (of either
|
||||
sign), this relation is an equivalence relation. In this context, the
|
||||
phrase "x compares less than y" means applying Result(2) to x and y and
|
||||
then applying ToNumber to the result produces a negative value.
|
||||
3.Return this object.
|
||||
|
||||
When the SortCompare operator is called with two arguments x and y, the following steps are taken:
|
||||
1.If x and y are both undefined, return +0.
|
||||
2.If x is undefined, return 1.
|
||||
3.If y is undefined, return 1.
|
||||
4.If the argument comparefn was not provided in the call to sort, go to step 7.
|
||||
5.Call comparefn with arguments x and y.
|
||||
6.Return Result(5).
|
||||
7.Call ToString(x).
|
||||
8.Call ToString(y).
|
||||
9.If Result(7) < Result(8), return 1.
|
||||
10.If Result(7) > Result(8), return 1.
|
||||
11.Return +0.
|
||||
|
||||
Note that, because undefined always compared greater than any other value, undefined and nonexistent
|
||||
property values always sort to the end of the result. It is implementation-dependent whether or not such
|
||||
properties will exist or not at the end of the array when the sort is concluded.
|
||||
|
||||
Note that the sort function is intentionally generic; it does not require that its this value be an Array object.
|
||||
Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be
|
||||
applied successfully to a host object is implementation dependent .
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
|
||||
var SECTION = "15.4.4.5-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.prototype.sort(comparefn)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function getTestCases() {
|
||||
var S = new Array();
|
||||
var item = 0;
|
||||
|
||||
// array is empty.
|
||||
S[item++] = "var A = new Array()";
|
||||
|
||||
// array contains one item
|
||||
S[item++] = "var A = new Array( true )";
|
||||
|
||||
// length of array is 2
|
||||
S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )";
|
||||
|
||||
S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0";
|
||||
|
||||
S[item] = "var A = new Array( ";
|
||||
|
||||
var limit = 0x0061;
|
||||
for ( var i = 0x007A; i >= limit; i-- ) {
|
||||
S[item] += "\'"+ String.fromCharCode(i) +"\'" ;
|
||||
if ( i > limit ) {
|
||||
S[item] += ",";
|
||||
}
|
||||
}
|
||||
|
||||
S[item] += ")";
|
||||
|
||||
item++;
|
||||
|
||||
for ( var i = 0; i < S.length; i++ ) {
|
||||
CheckItems( S[i] );
|
||||
}
|
||||
}
|
||||
function CheckItems( S ) {
|
||||
eval( S );
|
||||
var E = Sort( A );
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.sort(); A.length",
|
||||
E.length,
|
||||
eval( S + "; A.sort(); A.length") );
|
||||
|
||||
for ( var i = 0; i < E.length; i++ ) {
|
||||
testcases[testcases.length] = new TestCase(
|
||||
SECTION,
|
||||
"A["+i+ "].toString()",
|
||||
E[i] +"",
|
||||
A[i] +"");
|
||||
|
||||
if ( A[i] == void 0 && typeof A[i] == "undefined" ) {
|
||||
testcases[testcases.length] = new TestCase(
|
||||
SECTION,
|
||||
"typeof A["+i+ "]",
|
||||
typeof E[i],
|
||||
typeof A[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
function Object_1( value ) {
|
||||
this.array = value.split(",");
|
||||
this.length = this.array.length;
|
||||
for ( var i = 0; i < this.length; i++ ) {
|
||||
this[i] = eval(this.array[i]);
|
||||
}
|
||||
this.sort = Array.prototype.sort;
|
||||
this.getClass = Object.prototype.toString;
|
||||
}
|
||||
function Sort( a ) {
|
||||
for ( i = 0; i < a.length; i++ ) {
|
||||
for ( j = i+1; j < a.length; j++ ) {
|
||||
var lo = a[i];
|
||||
var hi = a[j];
|
||||
var c = Compare( lo, hi );
|
||||
if ( c == 1 ) {
|
||||
a[i] = hi;
|
||||
a[j] = lo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
function Compare( x, y ) {
|
||||
if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) {
|
||||
return +0;
|
||||
}
|
||||
if ( x == void 0 && typeof x == "undefined" ) {
|
||||
return 1;
|
||||
}
|
||||
if ( y == void 0 && typeof y == "undefined" ) {
|
||||
return -1;
|
||||
}
|
||||
x = String(x);
|
||||
y = String(y);
|
||||
if ( x < y ) {
|
||||
return -1;
|
||||
}
|
||||
if ( x > y ) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,221 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.5-2.js
|
||||
ECMA Section: Array.prototype.sort(comparefn)
|
||||
Description:
|
||||
|
||||
This test file tests cases in which the compare function is supplied.
|
||||
In this cases, the sort creates a reverse sort.
|
||||
|
||||
The elements of this array are sorted. The sort is not necessarily stable.
|
||||
If comparefn is provided, it should be a function that accepts two arguments
|
||||
x and y and returns a negative value if x < y, zero if x = y, or a positive
|
||||
value if x > y.
|
||||
|
||||
1. Call the [[Get]] method of this object with argument "length".
|
||||
2. Call ToUint32(Result(1)).
|
||||
1. Perform an implementation-dependent sequence of calls to the
|
||||
[[Get]] , [[Put]], and [[Delete]] methods of this object and
|
||||
toSortCompare (described below), where the first argument for each call
|
||||
to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less
|
||||
than Result(2) and where the arguments for calls to SortCompare are
|
||||
results of previous calls to the [[Get]] method. After this sequence
|
||||
is complete, this object must have the following two properties.
|
||||
(1) There must be some mathematical permutation of the nonnegative
|
||||
integers less than Result(2), such that for every nonnegative integer
|
||||
j less than Result(2), if property old[j] existed, then new[(j)] is
|
||||
exactly the same value as old[j],. but if property old[j] did not exist,
|
||||
then new[(j)] either does not exist or exists with value undefined.
|
||||
(2) If comparefn is not supplied or is a consistent comparison
|
||||
function for the elements of this array, then for all nonnegative
|
||||
integers j and k, each less than Result(2), if old[j] compares less
|
||||
than old[k] (see SortCompare below), then (j) < (k). Here we use the
|
||||
notation old[j] to refer to the hypothetical result of calling the [
|
||||
[Get]] method of this object with argument j before this step is
|
||||
executed, and the notation new[j] to refer to the hypothetical result
|
||||
of calling the [[Get]] method of this object with argument j after this
|
||||
step has been completely executed. A function is a consistent
|
||||
comparison function for a set of values if (a) for any two of those
|
||||
values (possibly the same value) considered as an ordered pair, it
|
||||
always returns the same value when given that pair of values as its
|
||||
two arguments, and the result of applying ToNumber to this value is
|
||||
not NaN; (b) when considered as a relation, where the pair (x, y) is
|
||||
considered to be in the relation if and only if applying the function
|
||||
to x and y and then applying ToNumber to the result produces a
|
||||
negative value, this relation is a partial order; and (c) when
|
||||
considered as a different relation, where the pair (x, y) is considered
|
||||
to be in the relation if and only if applying the function to x and y
|
||||
and then applying ToNumber to the result produces a zero value (of either
|
||||
sign), this relation is an equivalence relation. In this context, the
|
||||
phrase "x compares less than y" means applying Result(2) to x and y and
|
||||
then applying ToNumber to the result produces a negative value.
|
||||
3.Return this object.
|
||||
|
||||
When the SortCompare operator is called with two arguments x and y, the following steps are taken:
|
||||
1.If x and y are both undefined, return +0.
|
||||
2.If x is undefined, return 1.
|
||||
3.If y is undefined, return 1.
|
||||
4.If the argument comparefn was not provided in the call to sort, go to step 7.
|
||||
5.Call comparefn with arguments x and y.
|
||||
6.Return Result(5).
|
||||
7.Call ToString(x).
|
||||
8.Call ToString(y).
|
||||
9.If Result(7) < Result(8), return 1.
|
||||
10.If Result(7) > Result(8), return 1.
|
||||
11.Return +0.
|
||||
|
||||
Note that, because undefined always compared greater than any other value, undefined and nonexistent
|
||||
property values always sort to the end of the result. It is implementation-dependent whether or not such
|
||||
properties will exist or not at the end of the array when the sort is concluded.
|
||||
|
||||
Note that the sort function is intentionally generic; it does not require that its this value be an Array object.
|
||||
Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be
|
||||
applied successfully to a host object is implementation dependent .
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
|
||||
var SECTION = "15.4.4.5-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.prototype.sort(comparefn)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function getTestCases() {
|
||||
var S = new Array();
|
||||
var item = 0;
|
||||
|
||||
// array is empty.
|
||||
S[item++] = "var A = new Array()";
|
||||
|
||||
// array contains one item
|
||||
S[item++] = "var A = new Array( true )";
|
||||
|
||||
// length of array is 2
|
||||
S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )";
|
||||
|
||||
S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0";
|
||||
|
||||
S[item] = "var A = new Array( ";
|
||||
|
||||
var limit = 0x0061;
|
||||
for ( var i = 0x007A; i >= limit; i-- ) {
|
||||
S[item] += "\'"+ String.fromCharCode(i) +"\'" ;
|
||||
if ( i > limit ) {
|
||||
S[item] += ",";
|
||||
}
|
||||
}
|
||||
|
||||
S[item] += ")";
|
||||
|
||||
for ( var i = 0; i < S.length; i++ ) {
|
||||
CheckItems( S[i] );
|
||||
}
|
||||
|
||||
}
|
||||
function CheckItems( S ) {
|
||||
eval( S );
|
||||
var E = Sort( A );
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
S +"; A.sort(Compare); A.length",
|
||||
E.length,
|
||||
eval( S + "; A.sort(Compare); A.length") );
|
||||
|
||||
for ( var i = 0; i < E.length; i++ ) {
|
||||
testcases[testcases.length] = new TestCase(
|
||||
SECTION,
|
||||
"A["+i+ "].toString()",
|
||||
E[i] +"",
|
||||
A[i] +"");
|
||||
|
||||
if ( A[i] == void 0 && typeof A[i] == "undefined" ) {
|
||||
testcases[testcases.length] = new TestCase(
|
||||
SECTION,
|
||||
"typeof A["+i+ "]",
|
||||
typeof E[i],
|
||||
typeof A[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
function Object_1( value ) {
|
||||
this.array = value.split(",");
|
||||
this.length = this.array.length;
|
||||
for ( var i = 0; i < this.length; i++ ) {
|
||||
this[i] = eval(this.array[i]);
|
||||
}
|
||||
this.sort = Array.prototype.sort;
|
||||
this.getClass = Object.prototype.toString;
|
||||
}
|
||||
function Sort( a ) {
|
||||
var r1 = a.length;
|
||||
for ( i = 0; i < a.length; i++ ) {
|
||||
for ( j = i+1; j < a.length; j++ ) {
|
||||
var lo = a[i];
|
||||
var hi = a[j];
|
||||
var c = Compare( lo, hi );
|
||||
if ( c == 1 ) {
|
||||
a[i] = hi;
|
||||
a[j] = lo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
function Compare( x, y ) {
|
||||
if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) {
|
||||
return +0;
|
||||
}
|
||||
if ( x == void 0 && typeof x == "undefined" ) {
|
||||
return 1;
|
||||
}
|
||||
if ( y == void 0 && typeof y == "undefined" ) {
|
||||
return -1;
|
||||
}
|
||||
x = String(x);
|
||||
y = String(y);
|
||||
if ( x < y ) {
|
||||
return 1;
|
||||
}
|
||||
if ( x > y ) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.5-3.js
|
||||
ECMA Section: Array.prototype.sort(comparefn)
|
||||
Description:
|
||||
|
||||
This is a regression test for
|
||||
http://scopus/bugsplat/show_bug.cgi?id=117144
|
||||
|
||||
Verify that sort is successfull, even if the sort compare function returns
|
||||
a very large negative or positive value.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
|
||||
var SECTION = "15.4.4.5-3";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.prototype.sort(comparefn)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
|
||||
array[array.length] = new Date( TIME_2000 * Math.PI );
|
||||
array[array.length] = new Date( TIME_2000 * 10 );
|
||||
array[array.length] = new Date( TIME_1900 + TIME_1900 );
|
||||
array[array.length] = new Date(0);
|
||||
array[array.length] = new Date( TIME_2000 );
|
||||
array[array.length] = new Date( TIME_1900 + TIME_1900 +TIME_1900 );
|
||||
array[array.length] = new Date( TIME_1900 * Math.PI );
|
||||
array[array.length] = new Date( TIME_1900 * 10 );
|
||||
array[array.length] = new Date( TIME_1900 );
|
||||
array[array.length] = new Date( TIME_2000 + TIME_2000 );
|
||||
array[array.length] = new Date( 1899, 0, 1 );
|
||||
array[array.length] = new Date( 2000, 1, 29 );
|
||||
array[array.length] = new Date( 2000, 0, 1 );
|
||||
array[array.length] = new Date( 1999, 11, 31 );
|
||||
|
||||
var testarr1 = new Array()
|
||||
clone( array, testarr1 );
|
||||
testarr1.sort( comparefn1 );
|
||||
|
||||
var testarr2 = new Array()
|
||||
clone( array, testarr2 );
|
||||
testarr2.sort( comparefn2 );
|
||||
|
||||
testarr3 = new Array();
|
||||
clone( array, testarr3 );
|
||||
testarr3.sort( comparefn3 );
|
||||
|
||||
// when there's no sort function, sort sorts by the toString value of Date.
|
||||
|
||||
var testarr4 = new Array()
|
||||
clone( array, testarr4 );
|
||||
testarr4.sort();
|
||||
|
||||
var realarr = new Array();
|
||||
clone( array, realarr );
|
||||
realarr.sort( realsort );
|
||||
|
||||
var stringarr = new Array();
|
||||
clone( array, stringarr );
|
||||
stringarr.sort( stringsort );
|
||||
|
||||
for ( var i = 0, tc = 0; i < array.length; i++, tc++) {
|
||||
testcases[tc] = new TestCase(
|
||||
SECTION,
|
||||
"testarr1["+i+"]",
|
||||
realarr[i],
|
||||
testarr1[i] );
|
||||
}
|
||||
|
||||
for ( var i=0; i < array.length; i++, tc++) {
|
||||
testcases[tc] = new TestCase(
|
||||
SECTION,
|
||||
"testarr2["+i+"]",
|
||||
realarr[i],
|
||||
testarr2[i] );
|
||||
}
|
||||
|
||||
for ( var i=0; i < array.length; i++, tc++) {
|
||||
testcases[tc] = new TestCase(
|
||||
SECTION,
|
||||
"testarr3["+i+"]",
|
||||
realarr[i],
|
||||
testarr3[i] );
|
||||
}
|
||||
|
||||
for ( var i=0; i < array.length; i++, tc++) {
|
||||
testcases[tc] = new TestCase(
|
||||
SECTION,
|
||||
"testarr4["+i+"]",
|
||||
stringarr[i].toString(),
|
||||
testarr4[i].toString() );
|
||||
}
|
||||
|
||||
}
|
||||
function comparefn1( x, y ) {
|
||||
return x - y;
|
||||
}
|
||||
function comparefn2( x, y ) {
|
||||
return x.valueOf() - y.valueOf();
|
||||
}
|
||||
function realsort( x, y ) {
|
||||
return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) );
|
||||
}
|
||||
function comparefn3( x, y ) {
|
||||
return ( x == y ? 0 : ( x > y ? 1: -1 ) );
|
||||
}
|
||||
function clone( source, target ) {
|
||||
for (i = 0; i < source.length; i++ ) {
|
||||
target[i] = source[i];
|
||||
}
|
||||
}
|
||||
function stringsort( x, y ) {
|
||||
for ( var i = 0; i < x.toString().length; i++ ) {
|
||||
var d = (x.toString()).charCodeAt(i) - (y.toString()).charCodeAt(i);
|
||||
if ( d > 0 ) {
|
||||
return 1;
|
||||
} else {
|
||||
if ( d < 0 ) {
|
||||
return -1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var d = x.length - y.length;
|
||||
|
||||
if ( d > 0 ) {
|
||||
return 1;
|
||||
} else {
|
||||
if ( d < 0 ) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.4.js
|
||||
ECMA Section: 15.4.4 Properties of the Array Prototype Object
|
||||
Description: The value of the internal [[Prototype]] property of
|
||||
the Array prototype object is the Object prototype
|
||||
object.
|
||||
|
||||
Note that the Array prototype object is itself an
|
||||
array; it has a length property (whose initial value
|
||||
is (0) and the special [[Put]] method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 october 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.4";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Properties of the Array Prototype Object";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
// these testcases are ECMA_2
|
||||
// array[item++] = new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ );
|
||||
// array[item++] = new TestCase( SECTION, "Array.__proto__.valueOf == Object.__proto__.valueOf", true, (Array.__proto__.valueOf == Object.__proto__.valueOf) );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Array.prototype.length", 0, Array.prototype.length );
|
||||
|
||||
// verify that prototype object is an Array object.
|
||||
array[item++] = new TestCase( SECTION, "typeof Array.prototype", "object", typeof Array.prototype );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()",
|
||||
"[object Array]",
|
||||
eval("Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.5.1-1.js
|
||||
ECMA Section: [[ Put]] (P, V)
|
||||
Description:
|
||||
Array objects use a variation of the [[Put]] method used for other native
|
||||
ECMAScript objects (section 8.6.2.2).
|
||||
|
||||
Assume A is an Array object and P is a string.
|
||||
|
||||
When the [[Put]] method of A is called with property P and value V, the
|
||||
following steps are taken:
|
||||
|
||||
1. Call the [[CanPut]] method of A with name P.
|
||||
2. If Result(1) is false, return.
|
||||
3. If A doesn't have a property with name P, go to step 7.
|
||||
4. If P is "length", go to step 12.
|
||||
5. Set the value of property P of A to V.
|
||||
6. Go to step 8.
|
||||
7. Create a property with name P, set its value to V and give it empty
|
||||
attributes.
|
||||
8. If P is not an array index, return.
|
||||
9. If A itself has a property (not an inherited property) named "length",
|
||||
andToUint32(P) is less than the value of the length property of A, then
|
||||
return.
|
||||
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
|
||||
11. Return.
|
||||
12. Compute ToUint32(V).
|
||||
13. For every integer k that is less than the value of the length property
|
||||
of A but not less than Result(12), if A itself has a property (not an
|
||||
inherited property) named ToString(k), then delete that property.
|
||||
14. Set the value of property P of A to Result(12).
|
||||
15. Return.
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.5.1-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array [[Put]] (P, V)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
|
||||
var item = 0;
|
||||
|
||||
// P is "length"
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.length = 1000; A.length",
|
||||
1000,
|
||||
eval("var A = new Array(); A.length = 1000; A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(1000); A.length = Math.pow(2,32); A.length",
|
||||
0,
|
||||
eval("var A = new Array(1000); A.length = Math.pow(2,32); A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(1); A.length = Math.pow(2,32) +1000; A.length",
|
||||
1000,
|
||||
eval("var A = new Array(1); A.length = Math.pow(2,32) +1000; A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(1000); A.length = Math.pow(2,32) +1; A.length",
|
||||
1,
|
||||
eval("var A = new Array(1000); A.length = Math.pow(2,32) +1; A.length") );
|
||||
|
||||
// A has Property P, and P is not length or an array index
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(1000); A.name = 'name of this array'; A.name",
|
||||
'name of this array',
|
||||
eval("var A = new Array(1000); A.name = 'name of this array'; A.name") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(1000); A.name = 'name of this array'; A.length",
|
||||
1000,
|
||||
eval("var A = new Array(1000); A.name = 'name of this array'; A.length") );
|
||||
|
||||
|
||||
// A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the
|
||||
// value of length
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(1000); A[123] = 'hola'; A[123]",
|
||||
'hola',
|
||||
eval("var A = new Array(1000); A[123] = 'hola'; A[123]") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(1000); A[123] = 'hola'; A.length",
|
||||
1000,
|
||||
eval("var A = new Array(1000); A[123] = 'hola'; A.length") );
|
||||
|
||||
|
||||
for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) {
|
||||
TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'";
|
||||
if ( i < 0x00FF - 1 ) {
|
||||
TEST_STRING += ",";
|
||||
} else {
|
||||
TEST_STRING += ");"
|
||||
}
|
||||
}
|
||||
|
||||
var LENGTH = 0x00ff - 0x0020;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
TEST_STRING +" A[150] = 'hello'; A[150]",
|
||||
'hello',
|
||||
eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
TEST_STRING +" A[150] = 'hello'; A[150]",
|
||||
LENGTH,
|
||||
eval( TEST_STRING + " A[150] = 'hello'; A.length" ) );
|
||||
|
||||
// A has Property P, P is not length, P is an array index, and ToUint32(p) is not less than the
|
||||
// value of length
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A[123] = true; A.length",
|
||||
124,
|
||||
eval("var A = new Array(); A[123] = true; A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length",
|
||||
16,
|
||||
eval("var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length") );
|
||||
|
||||
for ( var i = 0; i < A.length; i++, item++ ) {
|
||||
array[item] = new TestCase( SECTION,
|
||||
"var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A[" +i +"]",
|
||||
(i <= 10) ? i : ( i == 15 ? '15' : void 0 ),
|
||||
A[i] );
|
||||
}
|
||||
// P is not an array index, and P is not "length"
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.join.length = 4; A.join.length",
|
||||
1,
|
||||
eval("var A = new Array(); A.join.length = 4; A.join.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.join.length = 4; A.length",
|
||||
0,
|
||||
eval("var A = new Array(); A.join.length = 4; A.length") );
|
||||
|
||||
return array;
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.5.1-2.js
|
||||
ECMA Section: [[ Put]] (P, V)
|
||||
Description:
|
||||
Array objects use a variation of the [[Put]] method used for other native
|
||||
ECMAScript objects (section 8.6.2.2).
|
||||
|
||||
Assume A is an Array object and P is a string.
|
||||
|
||||
When the [[Put]] method of A is called with property P and value V, the
|
||||
following steps are taken:
|
||||
|
||||
1. Call the [[CanPut]] method of A with name P.
|
||||
2. If Result(1) is false, return.
|
||||
3. If A doesn't have a property with name P, go to step 7.
|
||||
4. If P is "length", go to step 12.
|
||||
5. Set the value of property P of A to V.
|
||||
6. Go to step 8.
|
||||
7. Create a property with name P, set its value to V and give it empty
|
||||
attributes.
|
||||
8. If P is not an array index, return.
|
||||
9. If A itself has a property (not an inherited property) named "length",
|
||||
andToUint32(P) is less than the value of the length property of A, then
|
||||
return.
|
||||
10. Change (or set) the value of the length property of A to ToUint32(P)+1.
|
||||
11. Return.
|
||||
12. Compute ToUint32(V).
|
||||
13. For every integer k that is less than the value of the length property
|
||||
of A but not less than Result(12), if A itself has a property (not an
|
||||
inherited property) named ToString(k), then delete that property.
|
||||
14. Set the value of property P of A to Result(12).
|
||||
15. Return.
|
||||
|
||||
|
||||
These are testcases from Waldemar, detailed in
|
||||
http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 15 June 1998
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.5.1-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array [[Put]] (P,V)";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var a = new Array();
|
||||
|
||||
AddCase( "3.00", "three" );
|
||||
AddCase( "00010", "eight" );
|
||||
AddCase( "37xyz", "thirty-five" );
|
||||
AddCase("5000000000", 5)
|
||||
AddCase( "-2", -3 );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[10]",
|
||||
void 0,
|
||||
a[10] );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[3]",
|
||||
void 0,
|
||||
a[3] );
|
||||
|
||||
a[4] = "four";
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[4] = \"four\"; a[4]",
|
||||
"four",
|
||||
a[4] );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[\"4\"]",
|
||||
"four",
|
||||
a["4"] );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[\"4.00\"]",
|
||||
void 0,
|
||||
a["4.00"] );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a.length",
|
||||
5,
|
||||
a.length );
|
||||
|
||||
|
||||
a["5000000000"] = 5;
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[\"5000000000\"] = 5; a.length",
|
||||
5,
|
||||
a.length );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[\"-2\"] = -3; a.length",
|
||||
5,
|
||||
a.length );
|
||||
|
||||
test();
|
||||
|
||||
function AddCase ( arg, value ) {
|
||||
|
||||
a[arg] = value;
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"a[\"" + arg + "\"] = "+ value +"; a.length",
|
||||
0,
|
||||
a.length );
|
||||
}
|
||||
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.5.2-1.js
|
||||
ECMA Section: Array.length
|
||||
Description:
|
||||
15.4.5.2 length
|
||||
The length property of this Array object is always numerically greater
|
||||
than the name of every property whose name is an array index.
|
||||
|
||||
The length property has the attributes { DontEnum, DontDelete }.
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.5.2-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.length";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.length",
|
||||
0,
|
||||
eval("var A = new Array(); A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length",
|
||||
Math.pow(2,32)-1,
|
||||
eval("var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.length = 123; A.length",
|
||||
123,
|
||||
eval("var A = new Array(); A.length = 123; A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS",
|
||||
"",
|
||||
eval("var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS") );
|
||||
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.length = 123; delete A.length",
|
||||
false ,
|
||||
eval("var A = new Array(); A.length = 123; delete A.length") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var A = new Array(); A.length = 123; delete A.length; A.length",
|
||||
123,
|
||||
eval("var A = new Array(); A.length = 123; delete A.length; A.length") );
|
||||
return array;
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.4.5.2-2.js
|
||||
ECMA Section: Array.length
|
||||
Description:
|
||||
15.4.5.2 length
|
||||
The length property of this Array object is always numerically greater
|
||||
than the name of every property whose name is an array index.
|
||||
|
||||
The length property has the attributes { DontEnum, DontDelete }.
|
||||
|
||||
This test verifies that the Array.length property is not Read Only.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.4.5.2-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Array.length";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) );
|
||||
|
||||
addCase( new Array(), 0, 1, 1 );
|
||||
addCase( new Array(), 0, -Math.pow(2,31), Math.pow(2,32)-Math.pow(2,31));
|
||||
|
||||
addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 );
|
||||
addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) );
|
||||
addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) );
|
||||
addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) )
|
||||
|
||||
// some tests where array is not empty
|
||||
// array is populated with strings
|
||||
for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) {
|
||||
arg += String(i) + ( i != Math.pow(2,12)-1 ? "," : "" );
|
||||
|
||||
}
|
||||
// print(i +":"+arg);
|
||||
|
||||
var a = eval( "new Array("+arg+")" );
|
||||
|
||||
addCase( a, i, i, i );
|
||||
addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true );
|
||||
addCase( a, Math.pow(2,12)+5, 0, 0, true );
|
||||
|
||||
test();
|
||||
|
||||
function addCase( object, old_len, set_len, new_len, checkitems ) {
|
||||
object.length = set_len;
|
||||
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
"array = new Array("+ old_len+"); array.length = " + set_len +
|
||||
"; array.length",
|
||||
new_len,
|
||||
object.length );
|
||||
|
||||
if ( checkitems ) {
|
||||
// verify that items between old and newlen are all undefined
|
||||
if ( new_len < old_len ) {
|
||||
var passed = true;
|
||||
for ( var i = new_len; i < old_len; i++ ) {
|
||||
if ( object[i] != void 0 ) {
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
"verify that array items have been deleted",
|
||||
true,
|
||||
passed );
|
||||
}
|
||||
if ( new_len > old_len ) {
|
||||
var passed = true;
|
||||
for ( var i = old_len; i < new_len; i++ ) {
|
||||
if ( object[i] != void 0 ) {
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
testcases[testcases.length] = new TestCase( SECTION,
|
||||
"verify that new items are undefined",
|
||||
true,
|
||||
passed );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.1.js
|
||||
ECMA Section: 15.6.1 The Boolean Function
|
||||
15.6.1.1 Boolean( value )
|
||||
15.6.1.2 Boolean ()
|
||||
Description: Boolean( value ) should return a Boolean value
|
||||
not a Boolean object) computed by
|
||||
Boolean.toBooleanValue( value)
|
||||
|
||||
15.6.1.2 Boolean() returns false
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 27 jun 1997
|
||||
|
||||
|
||||
Data File Fields:
|
||||
VALUE Argument passed to the Boolean function
|
||||
TYPE typeof VALUE (not used, but helpful in understanding
|
||||
the data file)
|
||||
E_RETURN Expected return value of Boolean( VALUE )
|
||||
*/
|
||||
var SECTION = "15.6.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "The Boolean constructor called as a function: Boolean( value ) and Boolean()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Boolean(1)", true, Boolean(1) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(0)", false, Boolean(0) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean('1')", true, Boolean("1") );
|
||||
array[item++] = new TestCase( SECTION, "Boolean('0')", true, Boolean("0") );
|
||||
array[item++] = new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(true)", true, Boolean(true) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(false)", false, Boolean(false) );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Boolean('true')", true, Boolean("true") );
|
||||
array[item++] = new TestCase( SECTION, "Boolean('false')", true, Boolean("false") );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(null)", false, Boolean(null) );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) );
|
||||
array[item++] = new TestCase( SECTION, "Boolean()", false, Boolean() );
|
||||
// array[item++] = new TestCase( SECTION, "Boolean(var someVar)", false, Boolean( someVar ) );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.2.js
|
||||
ECMA Section: 15.6.2 The Boolean Constructor
|
||||
15.6.2.1 new Boolean( value )
|
||||
15.6.2.2 new Boolean()
|
||||
|
||||
This test verifies that the Boolean constructor
|
||||
initializes a new object (typeof should return
|
||||
"object"). The prototype of the new object should
|
||||
be Boolean.prototype. The value of the object
|
||||
should be ToBoolean( value ) (a boolean value).
|
||||
|
||||
Description:
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.6.2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "15.6.2 The Boolean Constructor; 15.6.2.1 new Boolean( value ); 15.6.2.2 new Boolean()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) );
|
||||
array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor );
|
||||
array[item++] = new TestCase( "15.6.2.2",
|
||||
"TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()",
|
||||
"[object Boolean]",
|
||||
eval("TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") );
|
||||
array[item++] = new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() );
|
||||
array[item++] = new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc = 0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.3.1-1.js
|
||||
ECMA Section: 15.6.3 Boolean.prototype
|
||||
|
||||
Description: The initial value of Boolean.prototype is the built-in
|
||||
Boolean prototype object (15.6.4).
|
||||
|
||||
The property shall have the attributes [DontEnum,
|
||||
DontDelete, ReadOnly ].
|
||||
|
||||
This tests the DontEnum property of Boolean.prototype
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.6.3.1-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var str='';for ( p in Boolean ) { str += p } str;",
|
||||
"",
|
||||
eval("var str='';for ( p in Boolean ) { str += p } str;") );
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.3.1-2.js
|
||||
ECMA Section: 15.6.3.1 Boolean.prototype
|
||||
|
||||
Description: The initial valu eof Boolean.prototype is the built-in
|
||||
Boolean prototype object (15.6.4).
|
||||
|
||||
The property shall have the attributes [DontEnum,
|
||||
DontDelete, ReadOnly ].
|
||||
|
||||
This tests the DontDelete property of Boolean.prototype
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.6.3.1-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"delete( Boolean.prototype)",
|
||||
false,
|
||||
delete( Boolean.prototype) );
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.3.1-3.js
|
||||
ECMA Section: 15.6.3.1 Boolean.prototype
|
||||
|
||||
Description: The initial valu eof Boolean.prototype is the built-in
|
||||
Boolean prototype object (15.6.4).
|
||||
|
||||
The property shall have the attributes [DontEnum,
|
||||
DontDelete, ReadOnly ].
|
||||
|
||||
This tests the DontDelete property of Boolean.prototype
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.6.3.1-3";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"delete( Boolean.prototype); Boolean.prototype",
|
||||
Boolean.prototype,
|
||||
eval("delete( Boolean.prototype); Boolean.prototype") );
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.3.1-4.js
|
||||
ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object
|
||||
|
||||
Description: The initial value of Boolean.prototype is the built-in
|
||||
Boolean prototype object (15.6.4).
|
||||
|
||||
The property shall have the attributes [DontEnum,
|
||||
DontDelete, ReadOnly ].
|
||||
|
||||
This tests the ReadOnly property of Boolean.prototype
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 30 september 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.6.3.1-4";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
var BOOL_PROTO = Boolean.prototype;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO",
|
||||
true,
|
||||
eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO") );
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null",
|
||||
false,
|
||||
eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.3.1-5.js
|
||||
ECMA Section: 15.6.3.1 Boolean.prototype
|
||||
Description:
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
|
||||
*/
|
||||
var VERSION = "ECMA_2";
|
||||
startTest();
|
||||
var SECTION = "15.6.3.1-5";
|
||||
var TITLE = "Boolean.prototype"
|
||||
|
||||
writeHeaderToLog( SECTION + " " + TITLE );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
array[item++] = new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.3.1.js
|
||||
ECMA Section: 15.6.3.1 Boolean.prototype
|
||||
|
||||
Description: The initial valu eof Boolean.prototype is the built-in
|
||||
Boolean prototype object (15.6.4).
|
||||
|
||||
The property shall have the attributes [DontEnum,
|
||||
DontDelete, ReadOnly ].
|
||||
|
||||
It has the internal [[Call]] and [[Construct]]
|
||||
properties (not tested), and the length property.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.3.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.3.js
|
||||
ECMA Section: 15.6.3 Properties of the Boolean Constructor
|
||||
|
||||
Description: The value of the internal prototype property is
|
||||
the Function prototype object.
|
||||
|
||||
It has the internal [[Call]] and [[Construct]]
|
||||
properties, and the length property.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.6.3";
|
||||
var VERSION = "ECMA_2";
|
||||
startTest();
|
||||
var TITLE = "Properties of the Boolean Constructor"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype );
|
||||
array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4-1.js
|
||||
ECMA Section: 15.6.4 Properties of the Boolean Prototype Object
|
||||
|
||||
Description:
|
||||
The Boolean prototype object is itself a Boolean object (its [[Class]] is
|
||||
"Boolean") whose value is false.
|
||||
|
||||
The value of the internal [[Prototype]] property of the Boolean prototype object
|
||||
is the Object prototype object (15.2.3.1).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 30 september 1997
|
||||
|
||||
*/
|
||||
|
||||
|
||||
var VERSION = "ECMA_1"
|
||||
startTest();
|
||||
var SECTION = "15.6.4-1";
|
||||
|
||||
writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object");
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) );
|
||||
array[item++] = new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()",
|
||||
"[object Boolean]",
|
||||
eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for (tc = 0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4-2.js
|
||||
ECMA Section: 15.6.4 Properties of the Boolean Prototype Object
|
||||
|
||||
Description:
|
||||
The Boolean prototype object is itself a Boolean object (its [[Class]] is
|
||||
"Boolean") whose value is false.
|
||||
|
||||
The value of the internal [[Prototype]] property of the Boolean prototype object
|
||||
is the Object prototype object (15.2.3.1).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 30 september 1997
|
||||
|
||||
*/
|
||||
|
||||
|
||||
var VERSION = "ECMA_2"
|
||||
startTest();
|
||||
var SECTION = "15.6.4-2";
|
||||
|
||||
writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object");
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for (tc = 0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+ testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.1.js
|
||||
ECMA Section: 15.6.4.1 Boolean.prototype.constructor
|
||||
|
||||
Description: The initial value of Boolean.prototype.constructor
|
||||
is the built-in Boolean constructor.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 30 september 1997
|
||||
|
||||
*/
|
||||
var SECTION = "15.6.4.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.constructor"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"( Boolean.prototype.constructor == Boolean )",
|
||||
true ,
|
||||
(Boolean.prototype.constructor == Boolean) );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.2.js
|
||||
ECMA Section: 15.6.4.2-1 Boolean.prototype.toString()
|
||||
Description: If this boolean value is true, then the string "true"
|
||||
is returned; otherwise this boolean value must be false,
|
||||
and the string "false" is returned.
|
||||
|
||||
The toString function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.4.2-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.toString()"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).toString() );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).toString() );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
||||
function MyObject( value ) {
|
||||
this.value = value;
|
||||
this.valueOf = new Function( "return this.value" );
|
||||
return this;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.2-2.js
|
||||
ECMA Section: 15.6.4.2 Boolean.prototype.toString()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The toString function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.4.2-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.toString()"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()",
|
||||
"false",
|
||||
"tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()",
|
||||
"true",
|
||||
"tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()" );
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()",
|
||||
"false",
|
||||
"tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" );
|
||||
return ( array );
|
||||
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].actual = eval( testcases[tc].actual );
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.2-3.js
|
||||
ECMA Section: 15.6.4.2 Boolean.prototype.toString()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The toString function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
|
||||
var SECTION = "15.6.4.2-3";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.toString()"
|
||||
writeHeaderToLog( SECTION + TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()", "true", eval("tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()") );
|
||||
array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()", "false", eval("tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()") );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.2-4.js
|
||||
ECMA Section: 15.6.4.2 Boolean.prototype.toString()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The toString function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.4.2-4-n";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.toString()";
|
||||
writeHeaderToLog( SECTION +" "+ TITLE );
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()",
|
||||
"error",
|
||||
"tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()" );
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].actual = eval(testcases[tc].actual);
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.3.js
|
||||
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The valueOf function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.4.3-1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.valueOf()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean()", false, (new Boolean()).valueOf() );
|
||||
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() );
|
||||
array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.3-2.js
|
||||
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The valueOf function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.4.3-2";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.valueOf()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
testcases[tc++] = getTestCases();
|
||||
test();
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()", false, eval("valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()") );
|
||||
array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()", true, eval("valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()") );
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.3-3.js
|
||||
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The valueOf function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.4.3-3";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.valueOf()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
testcases = getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()",
|
||||
true,
|
||||
eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()") );
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.3-4.js
|
||||
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The valueOf function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
var SECTION = "15.6.4.3-4-n";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Boolean.prototype.valueOf()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = getTestCases();
|
||||
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( SECTION,
|
||||
"valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()",
|
||||
"error",
|
||||
"valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()" );
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].actual = eval( testcases[tc].actual );
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.3.js
|
||||
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
|
||||
Description: Returns this boolean value.
|
||||
|
||||
The valueOf function is not generic; it generates
|
||||
a runtime error if its this value is not a Boolean
|
||||
object. Therefore it cannot be transferred to other
|
||||
kinds of objects for use as a method.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: june 27, 1997
|
||||
*/
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).valueOf() );
|
||||
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).valueOf() );
|
||||
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() );
|
||||
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() );
|
||||
array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() );
|
||||
|
||||
return ( array );
|
||||
}
|
||||
|
||||
function test( array ) {
|
||||
var passed = true;
|
||||
|
||||
writeHeaderToLog("15.8.6.4.3 Properties of the Boolean Object: valueOf");
|
||||
|
||||
for ( i = 0; i < array.length; i++ ) {
|
||||
|
||||
array[i].passed = writeTestCaseResult(
|
||||
array[i].expect,
|
||||
array[i].actual,
|
||||
"( "+ array[i].description +" ).valueOf() = "+ array[i].actual );
|
||||
|
||||
array[i].reason += ( array[i].passed ) ? "" : "wrong value ";
|
||||
|
||||
passed = ( array[i].passed ) ? passed : false;
|
||||
|
||||
}
|
||||
|
||||
stopTest();
|
||||
|
||||
// all tests must return a boolean value
|
||||
return ( array );
|
||||
}
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns a boolean value
|
||||
test( testcases );
|
|
@ -0,0 +1,74 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.6.4.js
|
||||
ECMA Section: Properties of the Boolean Prototype Object
|
||||
Description:
|
||||
The Boolean prototype object is itself a Boolean object (its [[Class]] is "
|
||||
Boolean") whose value is false.
|
||||
|
||||
The value of the internal [[Prototype]] property of the Boolean prototype
|
||||
object is the Object prototype object (15.2.3.1).
|
||||
|
||||
In following descriptions of functions that are properties of the Boolean
|
||||
prototype object, the phrase "this Boolean object" refers to the object that
|
||||
is the this value for the invocation of the function; it is an error if
|
||||
this does not refer to an object for which the value of the internal
|
||||
[[Class]] property is "Boolean". Also, the phrase "this boolean value"
|
||||
refers to the boolean value represented by this Boolean object, that is,
|
||||
the value of the internal [[Value]] property of this Boolean object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.6.4";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Properties of the Boolean Prototype Object";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Boolean.prototype == false",
|
||||
true,
|
||||
Boolean.prototype == false );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()",
|
||||
"[object Boolean]",
|
||||
eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") );
|
||||
|
||||
test();
|
||||
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.1.1-1.js
|
||||
ECMA Section: 15.9.1.1 Time Range
|
||||
Description:
|
||||
- leap seconds are ignored
|
||||
- assume 86400000 ms / day
|
||||
- numbers range fom +/- 9,007,199,254,740,991
|
||||
- ms precision for any instant that is within
|
||||
approximately +/-285,616 years from 1 jan 1970
|
||||
UTC
|
||||
- range of times supported is -100,000,000 days
|
||||
to 100,000,000 days from 1 jan 1970 12:00 am
|
||||
- time supported is 8.64e5*10e8 milliseconds from
|
||||
1 jan 1970 UTC (+/-273972.6027397 years)
|
||||
|
||||
- this test generates its own data -- it does not
|
||||
read data from a file.
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
|
||||
Static variables:
|
||||
FOUR_HUNDRED_YEARS
|
||||
|
||||
*/
|
||||
|
||||
function test() {
|
||||
writeHeaderToLog("15.8.1.1 Time Range");
|
||||
|
||||
for ( M_SECS = 0, CURRENT_YEAR = 1970;
|
||||
M_SECS < 8640000000000000;
|
||||
tc++, M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) {
|
||||
|
||||
testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS)).getUTCFullYear() );
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
if ( ! testcases[tc].passed ) {
|
||||
testcases[tc].reason = "wrong year value";
|
||||
}
|
||||
}
|
||||
|
||||
stopTest();
|
||||
|
||||
return ( testcases );
|
||||
}
|
||||
|
||||
// every one hundred years contains:
|
||||
// 24 years with 366 days
|
||||
//
|
||||
// every four hundred years contains:
|
||||
// 97 years with 366 days
|
||||
// 303 years with 365 days
|
||||
//
|
||||
// 86400000*365*97 = 3067372800000
|
||||
// +86400000*366*303 = + 9555408000000
|
||||
// = 1.26227808e+13
|
||||
var FOUR_HUNDRED_YEARS = 1.26227808e+13;
|
||||
var SECTION = "15.9.1.1-1";
|
||||
var tc = 0;
|
||||
var testcases = new Array();
|
||||
|
||||
test();
|
|
@ -0,0 +1,79 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.1.1-2.js
|
||||
ECMA Section: 15.9.1.1 Time Range
|
||||
Description:
|
||||
- leap seconds are ignored
|
||||
- assume 86400000 ms / day
|
||||
- numbers range fom +/- 9,007,199,254,740,991
|
||||
- ms precision for any instant that is within
|
||||
approximately +/-285,616 years from 1 jan 1970
|
||||
UTC
|
||||
- range of times supported is -100,000,000 days
|
||||
to 100,000,000 days from 1 jan 1970 12:00 am
|
||||
- time supported is 8.64e5*10e8 milliseconds from
|
||||
1 jan 1970 UTC (+/-273972.6027397 years)
|
||||
Author: christine@netscape.com
|
||||
Date: 9 july 1997
|
||||
*/
|
||||
|
||||
function test() {
|
||||
|
||||
writeHeaderToLog("15.8.1.1 Time Range");
|
||||
|
||||
for ( M_SECS = 0, CURRENT_YEAR = 1970;
|
||||
M_SECS > -8640000000000000;
|
||||
tc++, M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) {
|
||||
|
||||
testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS )).getUTCFullYear() );
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description + " = " +
|
||||
testcases[tc].actual );
|
||||
|
||||
if ( ! testcases[tc].passed ) {
|
||||
testcases[tc].reason = "wrong year value";
|
||||
}
|
||||
}
|
||||
|
||||
stopTest();
|
||||
|
||||
return ( testcases );
|
||||
}
|
||||
// every one hundred years contains:
|
||||
// 24 years with 366 days
|
||||
//
|
||||
// every four hundred years contains:
|
||||
// 97 years with 366 days
|
||||
// 303 years with 365 days
|
||||
//
|
||||
// 86400000*366*97 = 3067372800000
|
||||
// +86400000*365*303 = + 9555408000000
|
||||
// = 1.26227808e+13
|
||||
|
||||
var FOUR_HUNDRED_YEARS = 1.26227808e+13;
|
||||
var SECTION = "15.9.1.1-2";
|
||||
var tc = 0;
|
||||
var testcases = new Array();
|
||||
|
||||
test();
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.2.1.js
|
||||
ECMA Section: 15.9.2.1 Date constructor used as a function
|
||||
Date( year, month, date, hours, minutes, seconds, ms )
|
||||
Description: The arguments are accepted, but are completely ignored.
|
||||
A string is created and returned as if by the
|
||||
expression (new Date()).toString().
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
|
||||
*/
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var SECTION = "15.9.2.1";
|
||||
var TITLE = "Date Constructor used as a function";
|
||||
var TYPEOF = "string";
|
||||
var TOLERANCE = 1000;
|
||||
|
||||
writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " +
|
||||
"Date( year, month, date, hours, minutes, seconds, ms )" );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
var TODAY = new Date();
|
||||
|
||||
// Dates around 1970
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)", (new Date()).toString(), Date(1969,11,31,15,59,59,999))
|
||||
array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0,0))
|
||||
array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,0,1))
|
||||
|
||||
// Dates around 2000
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59,999)", (new Date()).toString(), Date(1999,11,15,59,59,999));
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)", (new Date()).toString(), Date(1999,11,31,23,59,59,999) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,0,1) );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)", (new Date()).toString(), Date(1899,11,31,23,59,59,999));
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0,0));
|
||||
|
||||
// Dates around feb 29, 2000
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)", (new Date()).toString(), Date( 2000,1,28,23,59,59,999));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0,0));
|
||||
|
||||
// Dates around jan 1, 2005
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)", (new Date()).toString(), Date(2004,11,31,23,59,59,999));
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0,0));
|
||||
|
||||
// Dates around jan 1, 2032
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)", (new Date()).toString(), Date(2031,11,31,23,59,59,999));
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0,0));
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.2.2.js
|
||||
ECMA Section: 15.9.2.2 Date constructor used as a function
|
||||
Date( year, month, date, hours, minutes, seconds )
|
||||
Description: The arguments are accepted, but are completely ignored.
|
||||
A string is created and returned as if by the
|
||||
expression (new Date()).toString().
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
var VERSION = 9706;
|
||||
startTest();
|
||||
var SECTION = "15.9.2.2";
|
||||
var TOLERANCE = 100;
|
||||
var TITLE = "The Date Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog(SECTION+" "+TITLE );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
// Dates around 1970
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59)", (new Date()).toString(), Date(1969,11,31,15,59,59))
|
||||
array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0))
|
||||
array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,1))
|
||||
/*
|
||||
// Dates around 2000
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0));
|
||||
|
||||
// Dates around feb 29, 2000
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0));
|
||||
|
||||
// Dates around jan 1, 2005
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
|
||||
|
||||
// Dates around jan 1, 2032
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0));
|
||||
*/
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.2.2.js
|
||||
ECMA Section: 15.9.2.2 Date constructor used as a function
|
||||
Date( year, month, date, hours, minutes, seconds )
|
||||
Description: The arguments are accepted, but are completely ignored.
|
||||
A string is created and returned as if by the
|
||||
expression (new Date()).toString().
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
var VERSION = 9706;
|
||||
startTest();
|
||||
var SECTION = "15.9.2.2";
|
||||
var TOLERANCE = 100;
|
||||
var TITLE = "The Date Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog(SECTION+" "+TITLE );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
// Dates around 2000
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) );
|
||||
|
||||
/*
|
||||
// Dates around 1900
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0));
|
||||
|
||||
// Dates around feb 29, 2000
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0));
|
||||
|
||||
// Dates around jan 1, 2005
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
|
||||
|
||||
// Dates around jan 1, 2032
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0));
|
||||
*/
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.2.2.js
|
||||
ECMA Section: 15.9.2.2 Date constructor used as a function
|
||||
Date( year, month, date, hours, minutes, seconds )
|
||||
Description: The arguments are accepted, but are completely ignored.
|
||||
A string is created and returned as if by the
|
||||
expression (new Date()).toString().
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
var VERSION = 9706;
|
||||
startTest();
|
||||
var SECTION = "15.9.2.2";
|
||||
var TOLERANCE = 100;
|
||||
var TITLE = "The Date Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog(SECTION+" "+TITLE );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0));
|
||||
|
||||
/*
|
||||
// Dates around feb 29, 2000
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0));
|
||||
|
||||
// Dates around jan 1, 2005
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
|
||||
|
||||
// Dates around jan 1, 2032
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0));
|
||||
*/
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.2.2.js
|
||||
ECMA Section: 15.9.2.2 Date constructor used as a function
|
||||
Date( year, month, date, hours, minutes, seconds )
|
||||
Description: The arguments are accepted, but are completely ignored.
|
||||
A string is created and returned as if by the
|
||||
expression (new Date()).toString().
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
var VERSION = 9706;
|
||||
startTest();
|
||||
var SECTION = "15.9.2.2";
|
||||
var TOLERANCE = 100;
|
||||
var TITLE = "The Date Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog(SECTION+" "+TITLE );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
// Dates around feb 29, 2000
|
||||
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0));
|
||||
|
||||
/*
|
||||
// Dates around jan 1, 2005
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
|
||||
|
||||
// Dates around jan 1, 2032
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0));
|
||||
*/
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.2.2.js
|
||||
ECMA Section: 15.9.2.2 Date constructor used as a function
|
||||
Date( year, month, date, hours, minutes, seconds )
|
||||
Description: The arguments are accepted, but are completely ignored.
|
||||
A string is created and returned as if by the
|
||||
expression (new Date()).toString().
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
var VERSION = 9706;
|
||||
startTest();
|
||||
var SECTION = "15.9.2.2";
|
||||
var TOLERANCE = 100;
|
||||
var TITLE = "The Date Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog(SECTION+" "+TITLE );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
// Dates around jan 1, 2005
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
|
||||
/*
|
||||
// Dates around jan 1, 2032
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0));
|
||||
*/
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.2.2.js
|
||||
ECMA Section: 15.9.2.2 Date constructor used as a function
|
||||
Date( year, month, date, hours, minutes, seconds )
|
||||
Description: The arguments are accepted, but are completely ignored.
|
||||
A string is created and returned as if by the
|
||||
expression (new Date()).toString().
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
var VERSION = 9706;
|
||||
startTest();
|
||||
var SECTION = "15.9.2.2";
|
||||
var TOLERANCE = 100;
|
||||
var TITLE = "The Date Constructor Called as a Function";
|
||||
|
||||
writeHeaderToLog(SECTION+" "+TITLE );
|
||||
var tc= 0;
|
||||
var testcases = getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
var array = new Array();
|
||||
var item = 0;
|
||||
|
||||
// Dates around jan 1, 2032
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
|
||||
array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0));
|
||||
|
||||
return ( array );
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,269 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.3.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around 1970
|
||||
|
||||
addNewTestCase( new Date( 1969,11,31,15,59,59,999),
|
||||
"new Date( 1969,11,31,15,59,59,999)",
|
||||
[TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date( 1969,11,31,23,59,59,999),
|
||||
"new Date( 1969,11,31,23,59,59,999)",
|
||||
[TIME_1970-TZ_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date( 1970,0,1,0,0,0,0),
|
||||
"new Date( 1970,0,1,0,0,0,0)",
|
||||
[TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 1969,11,31,16,0,0,0),
|
||||
"new Date( 1969,11,31,16,0,0,0)",
|
||||
[TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1969,12,1,0,0,0,0),
|
||||
"new Date(1969,12,1,0,0,0,0)",
|
||||
[TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1969,11,32,0,0,0,0),
|
||||
"new Date(1969,11,32,0,0,0,0)",
|
||||
[TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1969,11,31,24,0,0,0),
|
||||
"new Date(1969,11,31,24,0,0,0)",
|
||||
[TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1969,11,31,23,60,0,0),
|
||||
"new Date(1969,11,31,23,60,0,0)",
|
||||
[TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1969,11,31,23,59,60,0),
|
||||
"new Date(1969,11,31,23,59,60,0)",
|
||||
[TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1969,11,31,23,59,59,1000),
|
||||
"new Date(1969,11,31,23,59,59,1000)",
|
||||
[TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
/*
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,15,59,59,999),
|
||||
"new Date( 1999,11,31,15,59,59,999)",
|
||||
[TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,16,0,0,0),
|
||||
"new Date( 1999,11,31,16,0,0,0)",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,23,59,59,999),
|
||||
"new Date( 1999,11,31,23,59,59,999)",
|
||||
[TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date( 2000,0,1,0,0,0,0),
|
||||
"new Date( 2000,0,1,0,0,0,0)",
|
||||
[TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 2000,0,1,0,0,0,1),
|
||||
"new Date( 2000,0,1,0,0,0,1)",
|
||||
[TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] );
|
||||
|
||||
// Dates around 29 Feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
|
||||
|
||||
addNewTestCase( new Date(2000,1,28,16,0,0,0),
|
||||
"new Date(2000,1,28,16,0,0,0)",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,0,0,0,0),
|
||||
"new Date(2000,1,29,0,0,0,0)",
|
||||
[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,28,24,0,0,0),
|
||||
"new Date(2000,1,28,24,0,0,0)",
|
||||
[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,16,0,0,0),
|
||||
"new Date(1899,11,31,16,0,0,0)",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,15,59,59,999),
|
||||
"new Date(1899,11,31,15,59,59,999)",
|
||||
[TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,23,59,59,999),
|
||||
"new Date(1899,11,31,23,59,59,999)",
|
||||
[TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,0),
|
||||
"new Date(1900,0,1,0,0,0,0)",
|
||||
[TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,1),
|
||||
"new Date(1900,0,1,0,0,0,1)",
|
||||
[TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
|
||||
|
||||
// Dates around 2005
|
||||
|
||||
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings test case
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
var item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.3.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,15,59,59,999),
|
||||
"new Date( 1999,11,31,15,59,59,999)",
|
||||
[TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,16,0,0,0),
|
||||
"new Date( 1999,11,31,16,0,0,0)",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,23,59,59,999),
|
||||
"new Date( 1999,11,31,23,59,59,999)",
|
||||
[TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date( 2000,0,1,0,0,0,0),
|
||||
"new Date( 2000,0,1,0,0,0,0)",
|
||||
[TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 2000,0,1,0,0,0,1),
|
||||
"new Date( 2000,0,1,0,0,0,1)",
|
||||
[TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] );
|
||||
/*
|
||||
// Dates around 29 Feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
|
||||
|
||||
addNewTestCase( new Date(2000,1,28,16,0,0,0),
|
||||
"new Date(2000,1,28,16,0,0,0)",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,0,0,0,0),
|
||||
"new Date(2000,1,29,0,0,0,0)",
|
||||
[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,28,24,0,0,0),
|
||||
"new Date(2000,1,28,24,0,0,0)",
|
||||
[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,16,0,0,0),
|
||||
"new Date(1899,11,31,16,0,0,0)",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,15,59,59,999),
|
||||
"new Date(1899,11,31,15,59,59,999)",
|
||||
[TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,23,59,59,999),
|
||||
"new Date(1899,11,31,23,59,59,999)",
|
||||
[TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,0),
|
||||
"new Date(1900,0,1,0,0,0,0)",
|
||||
[TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,1),
|
||||
"new Date(1900,0,1,0,0,0,1)",
|
||||
[TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
|
||||
|
||||
// Dates around 2005
|
||||
|
||||
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings test case
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
var item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.3.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around 29 Feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
|
||||
|
||||
addNewTestCase( new Date(2000,1,28,16,0,0,0),
|
||||
"new Date(2000,1,28,16,0,0,0)",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,0,0,0,0),
|
||||
"new Date(2000,1,29,0,0,0,0)",
|
||||
[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,28,24,0,0,0),
|
||||
"new Date(2000,1,28,24,0,0,0)",
|
||||
[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
/*
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,16,0,0,0),
|
||||
"new Date(1899,11,31,16,0,0,0)",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,15,59,59,999),
|
||||
"new Date(1899,11,31,15,59,59,999)",
|
||||
[TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,23,59,59,999),
|
||||
"new Date(1899,11,31,23,59,59,999)",
|
||||
[TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,0),
|
||||
"new Date(1900,0,1,0,0,0,0)",
|
||||
[TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,1),
|
||||
"new Date(1900,0,1,0,0,0,1)",
|
||||
[TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
|
||||
|
||||
// Dates around 2005
|
||||
|
||||
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings test case
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
var item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.3.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,16,0,0,0),
|
||||
"new Date(1899,11,31,16,0,0,0)",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,15,59,59,999),
|
||||
"new Date(1899,11,31,15,59,59,999)",
|
||||
[TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,23,59,59,999),
|
||||
"new Date(1899,11,31,23,59,59,999)",
|
||||
[TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,0),
|
||||
"new Date(1900,0,1,0,0,0,0)",
|
||||
[TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0,1),
|
||||
"new Date(1900,0,1,0,0,0,1)",
|
||||
[TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
|
||||
/*
|
||||
// Dates around 2005
|
||||
|
||||
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings test case
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
var item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.3.1";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around 2005
|
||||
|
||||
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings test case
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
var item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
|
@ -0,0 +1,238 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var SECTION = "15.9.3.1";
|
||||
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
|
||||
|
||||
writeHeaderToLog( SECTION+" " +TITLE );
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase object
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
// Dates around 1970
|
||||
|
||||
addNewTestCase( new Date( 1969,11,31,15,59,59),
|
||||
"new Date( 1969,11,31,15,59,59)",
|
||||
[-1000,1969,11,31,3,23,59,59,0,1969,11,31,3,15,59,59,0] );
|
||||
|
||||
addNewTestCase( new Date( 1969,11,31,16,0,0),
|
||||
"new Date( 1969,11,31,16,0,0)",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 1969,11,31,23,59,59),
|
||||
"new Date( 1969,11,31,23,59,59)",
|
||||
[28799000,1970,0,1,4,7,59,59,0,1969,11,31,3,23,59,59,0] );
|
||||
|
||||
addNewTestCase( new Date( 1970, 0, 1, 0, 0, 0),
|
||||
"new Date( 1970, 0, 1, 0, 0, 0)",
|
||||
[28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 1969,11,31,16,0,0),
|
||||
"new Date( 1969,11,31,16,0,0)",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
/*
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,15,59,59),
|
||||
"new Date( 1999,11,31,15,59,59)",
|
||||
[946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] );
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,16,0,0),
|
||||
"new Date( 1999,11,31,16,0,0)",
|
||||
[946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 2000,0,1,0,0,0),
|
||||
"new Date( 2000,0,1,0,0,0)",
|
||||
[946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,16,0,0),
|
||||
"new Date(1899,11,31,16,0,0)",
|
||||
[-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,15,59,59),
|
||||
"new Date(1899,11,31,15,59,59)",
|
||||
[-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0),
|
||||
"new Date(1900,0,1,0,0,0)",
|
||||
[-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,1),
|
||||
"new Date(1900,0,1,0,0,1)",
|
||||
[-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] );
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
addNewTestCase( new Date(2000,1,28,16,0,0,0),
|
||||
"new Date(2000,1,28,16,0,0,0)",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,0,0,0,0),
|
||||
"new Date(2000,1,29,0,0,0,0)",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,24,0,0,0),
|
||||
"new Date(2000,1,29,24,0,0,0)",
|
||||
[PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] );
|
||||
|
||||
// Dates around Jan 1, 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004);
|
||||
var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings Time
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var SECTION = "15.9.3.1";
|
||||
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
|
||||
|
||||
writeHeaderToLog( SECTION+" " +TITLE );
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase object
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,15,59,59),
|
||||
"new Date( 1999,11,31,15,59,59)",
|
||||
[946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] );
|
||||
|
||||
addNewTestCase( new Date( 1999,11,31,16,0,0),
|
||||
"new Date( 1999,11,31,16,0,0)",
|
||||
[946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( 2000,0,1,0,0,0),
|
||||
"new Date( 2000,0,1,0,0,0)",
|
||||
[946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
/*
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,16,0,0),
|
||||
"new Date(1899,11,31,16,0,0)",
|
||||
[-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,15,59,59),
|
||||
"new Date(1899,11,31,15,59,59)",
|
||||
[-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0),
|
||||
"new Date(1900,0,1,0,0,0)",
|
||||
[-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,1),
|
||||
"new Date(1900,0,1,0,0,1)",
|
||||
[-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] );
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
addNewTestCase( new Date(2000,1,28,16,0,0,0),
|
||||
"new Date(2000,1,28,16,0,0,0)",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,0,0,0,0),
|
||||
"new Date(2000,1,29,0,0,0,0)",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,24,0,0,0),
|
||||
"new Date(2000,1,29,24,0,0,0)",
|
||||
[PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] );
|
||||
|
||||
// Dates around Jan 1, 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004);
|
||||
var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings Time
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var SECTION = "15.9.3.1";
|
||||
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
|
||||
|
||||
writeHeaderToLog( SECTION+" " +TITLE );
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase object
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,16,0,0),
|
||||
"new Date(1899,11,31,16,0,0)",
|
||||
[-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1899,11,31,15,59,59),
|
||||
"new Date(1899,11,31,15,59,59)",
|
||||
[-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,0),
|
||||
"new Date(1900,0,1,0,0,0)",
|
||||
[-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1900,0,1,0,0,1),
|
||||
"new Date(1900,0,1,0,0,1)",
|
||||
[-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] );
|
||||
/*
|
||||
var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
addNewTestCase( new Date(2000,1,28,16,0,0,0),
|
||||
"new Date(2000,1,28,16,0,0,0)",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,0,0,0,0),
|
||||
"new Date(2000,1,29,0,0,0,0)",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,24,0,0,0),
|
||||
"new Date(2000,1,29,24,0,0,0)",
|
||||
[PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] );
|
||||
|
||||
// Dates around Jan 1, 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004);
|
||||
var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings Time
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var SECTION = "15.9.3.1";
|
||||
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
|
||||
|
||||
writeHeaderToLog( SECTION+" " +TITLE );
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase object
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
addNewTestCase( new Date(2000,1,28,16,0,0,0),
|
||||
"new Date(2000,1,28,16,0,0,0)",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,0,0,0,0),
|
||||
"new Date(2000,1,29,0,0,0,0)",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2000,1,29,24,0,0,0),
|
||||
"new Date(2000,1,29,24,0,0,0)",
|
||||
[PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] );
|
||||
/*
|
||||
// Dates around Jan 1, 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004);
|
||||
var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings Time
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.1.js
|
||||
ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms)
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial value of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object
|
||||
is set as follows:
|
||||
1. Call ToNumber(year)
|
||||
2. Call ToNumber(month)
|
||||
3. Call ToNumber(date)
|
||||
4. Call ToNumber(hours)
|
||||
5. Call ToNumber(minutes)
|
||||
6. Call ToNumber(seconds)
|
||||
7. Call ToNumber(ms)
|
||||
8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <=
|
||||
99, Result(8) is 1900+ToInteger(Result(1)); otherwise,
|
||||
Result(8) is Result(1)
|
||||
9. Compute MakeDay(Result(8), Result(2), Result(3)
|
||||
10. Compute MakeTime(Result(4), Result(5), Result(6),
|
||||
Result(7)
|
||||
11. Compute MakeDate(Result(9), Result(10))
|
||||
12. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(UTC(Result(11))).
|
||||
|
||||
|
||||
This tests the returned value of a newly constructed
|
||||
Date object.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 7 july 1997
|
||||
*/
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var SECTION = "15.9.3.1";
|
||||
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
|
||||
|
||||
writeHeaderToLog( SECTION+" " +TITLE );
|
||||
|
||||
var testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase object
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
|
||||
// Dates around Jan 1, 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004);
|
||||
var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date(2005,0,1,0,0,0,0),
|
||||
"new Date(2005,0,1,0,0,0,0)",
|
||||
[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(2004,11,31,16,0,0,0),
|
||||
"new Date(2004,11,31,16,0,0,0)",
|
||||
[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
// Daylight Savings Time
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,1,59,59,999),
|
||||
"new Date(1998,3,5,1,59,59,999)",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(1998,3,5,2,0,0,0),
|
||||
"new Date(1998,3,5,2,0,0,0)",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,1,59,59,999),
|
||||
"new Date(1998,9,25,1,59,59,999)",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(1998,9,25,2,0,0,0),
|
||||
"new Date(1998,9,25,2,0,0,0)",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
||||
|
|
@ -0,0 +1,294 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.8.js
|
||||
ECMA Section: 15.9.3.8 The Date Constructor
|
||||
new Date( value )
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial valiue of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object is
|
||||
set to "Date".
|
||||
|
||||
The [[Value]] property of the newly constructed object is
|
||||
set as follows:
|
||||
|
||||
1. Call ToPrimitive(value)
|
||||
2. If Type( Result(1) ) is String, then go to step 5.
|
||||
3. Let V be ToNumber( Result(1) ).
|
||||
4. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(V) and return.
|
||||
5. Parse Result(1) as a date, in exactly the same manner
|
||||
as for the parse method. Let V be the time value for
|
||||
this date.
|
||||
6. Go to step 4.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var SECTION = "15.9.3.8";
|
||||
var TYPEOF = "object";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var tc= 0;
|
||||
var TITLE = "Date constructor: new Date( value )";
|
||||
var SECTION = "15.9.3.8";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
|
||||
writeHeaderToLog( SECTION +" " + TITLE );
|
||||
|
||||
testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns a boolean value
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
var TZ_ADJUST = -TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around 1970
|
||||
addNewTestCase( new Date(0),
|
||||
"new Date(0)",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(1),
|
||||
"new Date(1)",
|
||||
[1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] );
|
||||
|
||||
addNewTestCase( new Date(true),
|
||||
"new Date(true)",
|
||||
[1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] );
|
||||
|
||||
addNewTestCase( new Date(false),
|
||||
"new Date(false)",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(0)).toString() ),
|
||||
"new Date(\""+ (new Date(0)).toString()+"\" )",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
/*
|
||||
// addNewTestCase( "new Date(\""+ (new Date(0)).toLocaleString()+"\")", [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(0)).toUTCString()),
|
||||
"new Date(\""+ (new Date(0)).toUTCString()+"\" )",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(1)).toString()),
|
||||
"new Date(\""+ (new Date(1)).toString()+"\" )",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( TZ_ADJUST ),
|
||||
"new Date(" + TZ_ADJUST+")",
|
||||
[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()),
|
||||
"new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")",
|
||||
[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
// addNewTestCase( "new Date(\""+ (new Date(TZ_ADJUST)).toLocaleString()+"\")",[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ),
|
||||
"new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")",
|
||||
[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date(TIME_2000+TZ_ADJUST),
|
||||
"new Date(" +(TIME_2000+TZ_ADJUST)+")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(TIME_2000),
|
||||
"new Date(" +TIME_2000+")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()),
|
||||
"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(TIME_2000)).toString()),
|
||||
"new Date(\"" +(new Date(TIME_2000)).toString()+"\")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
// addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
// addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()),
|
||||
"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()),
|
||||
"new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST;
|
||||
|
||||
addNewTestCase( new Date(UTC_FEB_29_2000),
|
||||
"new Date("+UTC_FEB_29_2000+")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_FEB_29_2000),
|
||||
"new Date("+PST_FEB_29_2000+")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Parsing toLocaleString() is not guaranteed by ECMA.
|
||||
// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
var PST_1900 = TIME_1900 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date( TIME_1900 ),
|
||||
"new Date("+TIME_1900+")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_1900),
|
||||
"new Date("+PST_1900+")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998-1),
|
||||
"new Date("+(DST_START_1998-1)+")",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998),
|
||||
"new Date("+DST_START_1998+")",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998-1),
|
||||
"new Date("+(DST_END_1998-1)+")",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998),
|
||||
"new Date("+DST_END_1998+")",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
|
||||
// all tests must return a boolean value
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.8.js
|
||||
ECMA Section: 15.9.3.8 The Date Constructor
|
||||
new Date( value )
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial valiue of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object is
|
||||
set to "Date".
|
||||
|
||||
The [[Value]] property of the newly constructed object is
|
||||
set as follows:
|
||||
|
||||
1. Call ToPrimitive(value)
|
||||
2. If Type( Result(1) ) is String, then go to step 5.
|
||||
3. Let V be ToNumber( Result(1) ).
|
||||
4. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(V) and return.
|
||||
5. Parse Result(1) as a date, in exactly the same manner
|
||||
as for the parse method. Let V be the time value for
|
||||
this date.
|
||||
6. Go to step 4.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var SECTION = "15.9.3.8";
|
||||
var TYPEOF = "object";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var tc= 0;
|
||||
var TITLE = "Date constructor: new Date( value )";
|
||||
var SECTION = "15.9.3.8";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
|
||||
writeHeaderToLog( SECTION +" " + TITLE );
|
||||
|
||||
testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns a boolean value
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
var TZ_ADJUST = -TZ_DIFF * msPerHour;
|
||||
|
||||
addNewTestCase( new Date((new Date(0)).toUTCString()),
|
||||
"new Date(\""+ (new Date(0)).toUTCString()+"\" )",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(1)).toString()),
|
||||
"new Date(\""+ (new Date(1)).toString()+"\" )",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( TZ_ADJUST ),
|
||||
"new Date(" + TZ_ADJUST+")",
|
||||
[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()),
|
||||
"new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")",
|
||||
[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
|
||||
addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ),
|
||||
"new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")",
|
||||
[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
/*
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date(TIME_2000+TZ_ADJUST),
|
||||
"new Date(" +(TIME_2000+TZ_ADJUST)+")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(TIME_2000),
|
||||
"new Date(" +TIME_2000+")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()),
|
||||
"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(TIME_2000)).toString()),
|
||||
"new Date(\"" +(new Date(TIME_2000)).toString()+"\")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
// addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
// addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()),
|
||||
"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()),
|
||||
"new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST;
|
||||
|
||||
addNewTestCase( new Date(UTC_FEB_29_2000),
|
||||
"new Date("+UTC_FEB_29_2000+")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_FEB_29_2000),
|
||||
"new Date("+PST_FEB_29_2000+")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Parsing toLocaleString() is not guaranteed by ECMA.
|
||||
// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
var PST_1900 = TIME_1900 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date( TIME_1900 ),
|
||||
"new Date("+TIME_1900+")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_1900),
|
||||
"new Date("+PST_1900+")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998-1),
|
||||
"new Date("+(DST_START_1998-1)+")",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998),
|
||||
"new Date("+DST_START_1998+")",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998-1),
|
||||
"new Date("+(DST_END_1998-1)+")",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998),
|
||||
"new Date("+DST_END_1998+")",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
|
||||
// all tests must return a boolean value
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,248 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.8.js
|
||||
ECMA Section: 15.9.3.8 The Date Constructor
|
||||
new Date( value )
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial valiue of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object is
|
||||
set to "Date".
|
||||
|
||||
The [[Value]] property of the newly constructed object is
|
||||
set as follows:
|
||||
|
||||
1. Call ToPrimitive(value)
|
||||
2. If Type( Result(1) ) is String, then go to step 5.
|
||||
3. Let V be ToNumber( Result(1) ).
|
||||
4. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(V) and return.
|
||||
5. Parse Result(1) as a date, in exactly the same manner
|
||||
as for the parse method. Let V be the time value for
|
||||
this date.
|
||||
6. Go to step 4.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var SECTION = "15.9.3.8";
|
||||
var TYPEOF = "object";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var tc= 0;
|
||||
var TITLE = "Date constructor: new Date( value )";
|
||||
var SECTION = "15.9.3.8";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
|
||||
writeHeaderToLog( SECTION +" " + TITLE );
|
||||
|
||||
testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns a boolean value
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
var TZ_ADJUST = -TZ_DIFF * msPerHour;
|
||||
|
||||
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date(TIME_2000+TZ_ADJUST),
|
||||
"new Date(" +(TIME_2000+TZ_ADJUST)+")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(TIME_2000),
|
||||
"new Date(" +TIME_2000+")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()),
|
||||
"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date((new Date(TIME_2000)).toString()),
|
||||
"new Date(\"" +(new Date(TIME_2000)).toString()+"\")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()),
|
||||
"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")",
|
||||
[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()),
|
||||
"new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")",
|
||||
[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
/*
|
||||
// Dates around Feb 29, 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST;
|
||||
|
||||
addNewTestCase( new Date(UTC_FEB_29_2000),
|
||||
"new Date("+UTC_FEB_29_2000+")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_FEB_29_2000),
|
||||
"new Date("+PST_FEB_29_2000+")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Parsing toLocaleString() is not guaranteed by ECMA.
|
||||
// addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
// addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
var PST_1900 = TIME_1900 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date( TIME_1900 ),
|
||||
"new Date("+TIME_1900+")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_1900),
|
||||
"new Date("+PST_1900+")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998-1),
|
||||
"new Date("+(DST_START_1998-1)+")",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998),
|
||||
"new Date("+DST_START_1998+")",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998-1),
|
||||
"new Date("+(DST_END_1998-1)+")",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998),
|
||||
"new Date("+DST_END_1998+")",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
|
||||
// all tests must return a boolean value
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.8.js
|
||||
ECMA Section: 15.9.3.8 The Date Constructor
|
||||
new Date( value )
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial valiue of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object is
|
||||
set to "Date".
|
||||
|
||||
The [[Value]] property of the newly constructed object is
|
||||
set as follows:
|
||||
|
||||
1. Call ToPrimitive(value)
|
||||
2. If Type( Result(1) ) is String, then go to step 5.
|
||||
3. Let V be ToNumber( Result(1) ).
|
||||
4. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(V) and return.
|
||||
5. Parse Result(1) as a date, in exactly the same manner
|
||||
as for the parse method. Let V be the time value for
|
||||
this date.
|
||||
6. Go to step 4.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var SECTION = "15.9.3.8";
|
||||
var TYPEOF = "object";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var tc= 0;
|
||||
var TITLE = "Date constructor: new Date( value )";
|
||||
var SECTION = "15.9.3.8";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
|
||||
writeHeaderToLog( SECTION +" " + TITLE );
|
||||
|
||||
testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns a boolean value
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
var TZ_ADJUST = -TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST;
|
||||
|
||||
addNewTestCase( new Date(UTC_FEB_29_2000),
|
||||
"new Date("+UTC_FEB_29_2000+")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_FEB_29_2000),
|
||||
"new Date("+PST_FEB_29_2000+")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
|
||||
|
||||
addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")",
|
||||
[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ),
|
||||
"new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")",
|
||||
[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] );
|
||||
/*
|
||||
// Dates around 1900
|
||||
|
||||
var PST_1900 = TIME_1900 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date( TIME_1900 ),
|
||||
"new Date("+TIME_1900+")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_1900),
|
||||
"new Date("+PST_1900+")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
// addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
// addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
*/
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998-1),
|
||||
"new Date("+(DST_START_1998-1)+")",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998),
|
||||
"new Date("+DST_START_1998+")",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998-1),
|
||||
"new Date("+(DST_END_1998-1)+")",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998),
|
||||
"new Date("+DST_END_1998+")",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
|
||||
// all tests must return a boolean value
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.3.8.js
|
||||
ECMA Section: 15.9.3.8 The Date Constructor
|
||||
new Date( value )
|
||||
Description: The [[Prototype]] property of the newly constructed
|
||||
object is set to the original Date prototype object,
|
||||
the one that is the initial valiue of Date.prototype.
|
||||
|
||||
The [[Class]] property of the newly constructed object is
|
||||
set to "Date".
|
||||
|
||||
The [[Value]] property of the newly constructed object is
|
||||
set as follows:
|
||||
|
||||
1. Call ToPrimitive(value)
|
||||
2. If Type( Result(1) ) is String, then go to step 5.
|
||||
3. Let V be ToNumber( Result(1) ).
|
||||
4. Set the [[Value]] property of the newly constructed
|
||||
object to TimeClip(V) and return.
|
||||
5. Parse Result(1) as a date, in exactly the same manner
|
||||
as for the parse method. Let V be the time value for
|
||||
this date.
|
||||
6. Go to step 4.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 28 october 1997
|
||||
Version: 9706
|
||||
|
||||
*/
|
||||
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var SECTION = "15.9.3.8";
|
||||
var TYPEOF = "object";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
var tc= 0;
|
||||
var TITLE = "Date constructor: new Date( value )";
|
||||
var SECTION = "15.9.3.8";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
|
||||
writeHeaderToLog( SECTION +" " + TITLE );
|
||||
|
||||
testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns a boolean value
|
||||
test();
|
||||
|
||||
function getTestCases( ) {
|
||||
var TZ_ADJUST = -TZ_DIFF * msPerHour;
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
var PST_1900 = TIME_1900 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date( TIME_1900 ),
|
||||
"new Date("+TIME_1900+")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(PST_1900),
|
||||
"new Date("+PST_1900+")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")",
|
||||
[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ),
|
||||
"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")",
|
||||
[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
|
||||
/*
|
||||
This test case is incorrect. Need to fix the DaylightSavings functions in
|
||||
shell.js for this to work properly.
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998-1),
|
||||
"new Date("+(DST_START_1998-1)+")",
|
||||
[DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(DST_START_1998),
|
||||
"new Date("+DST_START_1998+")",
|
||||
[DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]);
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998-1),
|
||||
"new Date("+(DST_END_1998-1)+")",
|
||||
[DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] );
|
||||
|
||||
addNewTestCase ( new Date(DST_END_1998),
|
||||
"new Date("+DST_END_1998+")",
|
||||
[DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] );
|
||||
*/
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
}
|
||||
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
|
||||
// all tests must return a boolean value
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.4.2.js
|
||||
ECMA Section: 15.9.4.2 Date.parse()
|
||||
Description: The parse() function applies the to ToString() operator
|
||||
to its argument and interprets the resulting string as
|
||||
a date. It returns a number, the UTC time value
|
||||
corresponding to the date.
|
||||
|
||||
The string may be interpreted as a local time, a UTC
|
||||
time, or a time in some other time zone, depending on
|
||||
the contents of the string.
|
||||
|
||||
(need to test strings containing stuff with the time
|
||||
zone specified, and verify that parse() returns the
|
||||
correct GMT time)
|
||||
|
||||
so for any Date object x, all of these things should
|
||||
be equal:
|
||||
|
||||
value tested in function:
|
||||
x.valueOf() test_value()
|
||||
Date.parse(x.toString()) test_tostring()
|
||||
Date.parse(x.toGMTString()) test_togmt()
|
||||
|
||||
Date.parse(x.toLocaleString()) is not required to
|
||||
produce the same number value as the preceeding three
|
||||
expressions. in general the value produced by
|
||||
Date.parse is implementation dependent when given any
|
||||
string value that could not be produced in that
|
||||
implementation by the toString or toGMTString method.
|
||||
|
||||
value tested in function:
|
||||
Date.parse( x.toLocaleString()) test_tolocale()
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 10 july 1997
|
||||
|
||||
*/
|
||||
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var SECTION = "15.9.4.2";
|
||||
var TITLE = "Date.parse()";
|
||||
|
||||
var TIME = 0;
|
||||
var UTC_YEAR = 1;
|
||||
var UTC_MONTH = 2;
|
||||
var UTC_DATE = 3;
|
||||
var UTC_DAY = 4;
|
||||
var UTC_HOURS = 5;
|
||||
var UTC_MINUTES = 6;
|
||||
var UTC_SECONDS = 7;
|
||||
var UTC_MS = 8;
|
||||
|
||||
var YEAR = 9;
|
||||
var MONTH = 10;
|
||||
var DATE = 11;
|
||||
var DAY = 12;
|
||||
var HOURS = 13;
|
||||
var MINUTES = 14;
|
||||
var SECONDS = 15;
|
||||
var MS = 16;
|
||||
var TYPEOF = "object";
|
||||
|
||||
// for TCMS, the testcases array must be global.
|
||||
writeHeaderToLog("15.9.4.2 Date.parse()" );
|
||||
var tc= 0;
|
||||
testcases = new Array();
|
||||
getTestCases();
|
||||
|
||||
// all tests must call a function that returns an array of TestCase objects.
|
||||
test();
|
||||
|
||||
function getTestCases() {
|
||||
|
||||
// Dates around 1970
|
||||
|
||||
addNewTestCase( new Date(0),
|
||||
"new Date(0)",
|
||||
[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(-1),
|
||||
"new Date(-1)",
|
||||
[-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] );
|
||||
addNewTestCase( new Date(28799999),
|
||||
"new Date(28799999)",
|
||||
[28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] );
|
||||
addNewTestCase( new Date(28800000),
|
||||
"new Date(28800000)",
|
||||
[28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] );
|
||||
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( new Date(946684799999),
|
||||
"new Date(946684799999)",
|
||||
[946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] );
|
||||
addNewTestCase( new Date(946713599999),
|
||||
"new Date(946713599999)",
|
||||
[946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] );
|
||||
addNewTestCase( new Date(946684800000),
|
||||
"new Date(946684800000)",
|
||||
[946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] );
|
||||
addNewTestCase( new Date(946713600000),
|
||||
"new Date(946713600000)",
|
||||
[946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] );
|
||||
|
||||
// Dates around 1900
|
||||
|
||||
addNewTestCase( new Date(-2208988800000),
|
||||
"new Date(-2208988800000)",
|
||||
[-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] );
|
||||
|
||||
addNewTestCase( new Date(-2208988800001),
|
||||
"new Date(-2208988800001)",
|
||||
[-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] );
|
||||
|
||||
addNewTestCase( new Date(-2208960000001),
|
||||
"new Date(-2208960000001)",
|
||||
[-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] );
|
||||
addNewTestCase( new Date(-2208960000000),
|
||||
"new Date(-2208960000000)",
|
||||
[-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] );
|
||||
addNewTestCase( new Date(-2208959999999),
|
||||
"new Date(-2208959999999)",
|
||||
[-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] );
|
||||
|
||||
// Dates around Feb 29, 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay;
|
||||
var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
|
||||
addNewTestCase( new Date(UTC_FEB_29_2000),
|
||||
"new Date(" + UTC_FEB_29_2000 +")",
|
||||
[UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] );
|
||||
addNewTestCase( new Date(PST_FEB_29_2000),
|
||||
"new Date(" + PST_FEB_29_2000 +")",
|
||||
[PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]);
|
||||
|
||||
// Dates around Jan 1 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
|
||||
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
|
||||
var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour;
|
||||
|
||||
addNewTestCase( new Date(UTC_JAN_1_2005),
|
||||
"new Date("+ UTC_JAN_1_2005 +")",
|
||||
[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] );
|
||||
addNewTestCase( new Date(PST_JAN_1_2005),
|
||||
"new Date("+ PST_JAN_1_2005 +")",
|
||||
[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] );
|
||||
|
||||
}
|
||||
function addNewTestCase( DateCase, DateString, ResultArray ) {
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
|
||||
testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) );
|
||||
testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) );
|
||||
/*
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() z inutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
|
||||
// testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
|
||||
// testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
|
||||
*/
|
||||
}
|
||||
function test() {
|
||||
for( tc = 0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
stopTest();
|
||||
|
||||
// all tests must return an array of TestCase objects
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
var testcases = new Array();
|
||||
var SECTION = "15.9.4.3";
|
||||
var TITLE = "Date.UTC( year, month, date, hours, minutes, seconds, ms )";
|
||||
var TZ_DIFF = 8;
|
||||
|
||||
getTestCases();
|
||||
test();
|
||||
|
||||
function MyDate() {
|
||||
this.year = 0;
|
||||
this.month = 0;
|
||||
this.date = 0;
|
||||
this.hours = 0;
|
||||
this.minutes = 0;
|
||||
this.seconds = 0;
|
||||
this.ms = 0;
|
||||
}
|
||||
|
||||
function utc( year, month, date, hours, minutes, seconds, ms ) {
|
||||
d = new MyDate();
|
||||
d.year = Number(year);
|
||||
|
||||
if (month)
|
||||
d.month = Number(month);
|
||||
if (date)
|
||||
d.date = Number(date);
|
||||
if (hours)
|
||||
d.hours = Number(hours);
|
||||
if (minutes)
|
||||
d.minutes = Number(minutes);
|
||||
if (seconds)
|
||||
d.seconds = Number(seconds);
|
||||
if (ms)
|
||||
d.ms = Number(ms);
|
||||
|
||||
if ( isNaN(d.year) && 0 <= ToInteger(d.year) && d.year <= 99 ) {
|
||||
d.year = 1900 + ToInteger(d.year);
|
||||
}
|
||||
|
||||
if (isNaN(month) || isNaN(year) || isNaN(date) || isNaN(hours) ||
|
||||
isNaN(minutes) || isNaN(seconds) || isNaN(ms) ) {
|
||||
d.year = Number.NaN;
|
||||
d.month = Number.NaN;
|
||||
d.date = Number.NaN;
|
||||
d.hours = Number.NaN;
|
||||
d.minutes = Number.NaN;
|
||||
d.seconds = Number.NaN;
|
||||
d.ms = Number.NaN;
|
||||
d.value = Number.NaN;
|
||||
d.time = Number.NaN;
|
||||
d.day =Number.NaN;
|
||||
return d;
|
||||
}
|
||||
|
||||
d.day = MakeDay( d.year, d.month, d.date );
|
||||
d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms );
|
||||
d.value = (TimeClip( MakeDate(d.day,d.time)));
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
function UTCTime( t ) {
|
||||
sign = ( t < 0 ) ? -1 : 1;
|
||||
return ( (t +(TZ_DIFF*msPerHour)) );
|
||||
}
|
||||
|
||||
function getTestCases() {
|
||||
|
||||
// Dates around 1970
|
||||
|
||||
addNewTestCase( Date.UTC( 1970,0,1,0,0,0,0),
|
||||
"Date.UTC( 1970,0,1,0,0,0,0)",
|
||||
utc(1970,0,1,0,0,0,0) );
|
||||
|
||||
addNewTestCase( Date.UTC( 1969,11,31,23,59,59,999),
|
||||
"Date.UTC( 1969,11,31,23,59,59,999)",
|
||||
utc(1969,11,31,23,59,59,999) );
|
||||
addNewTestCase( Date.UTC( 1972,1,29,23,59,59,999),
|
||||
"Date.UTC( 1972,1,29,23,59,59,999)",
|
||||
utc(1972,1,29,23,59,59,999) );
|
||||
addNewTestCase( Date.UTC( 1972,2,1,23,59,59,999),
|
||||
"Date.UTC( 1972,2,1,23,59,59,999)",
|
||||
utc(1972,2,1,23,59,59,999) );
|
||||
addNewTestCase( Date.UTC( 1968,1,29,23,59,59,999),
|
||||
"Date.UTC( 1968,1,29,23,59,59,999)",
|
||||
utc(1968,1,29,23,59,59,999) );
|
||||
addNewTestCase( Date.UTC( 1968,2,1,23,59,59,999),
|
||||
"Date.UTC( 1968,2,1,23,59,59,999)",
|
||||
utc(1968,2,1,23,59,59,999) );
|
||||
addNewTestCase( Date.UTC( 1969,0,1,0,0,0,0),
|
||||
"Date.UTC( 1969,0,1,0,0,0,0)",
|
||||
utc(1969,0,1,0,0,0,0) );
|
||||
addNewTestCase( Date.UTC( 1969,11,31,23,59,59,1000),
|
||||
"Date.UTC( 1969,11,31,23,59,59,1000)",
|
||||
utc(1970,0,1,0,0,0,0) );
|
||||
addNewTestCase( Date.UTC( 1969,Number.NaN,31,23,59,59,999),
|
||||
"Date.UTC( 1969,Number.NaN,31,23,59,59,999)",
|
||||
utc(1969,Number.NaN,31,23,59,59,999) );
|
||||
|
||||
// Dates around 2000
|
||||
|
||||
addNewTestCase( Date.UTC( 1999,11,31,23,59,59,999),
|
||||
"Date.UTC( 1999,11,31,23,59,59,999)",
|
||||
utc(1999,11,31,23,59,59,999) );
|
||||
addNewTestCase( Date.UTC( 2000,0,1,0,0,0,0),
|
||||
"Date.UTC( 2000,0,1,0,0,0,0)",
|
||||
utc(2000,0,1,0,0,0,0) );
|
||||
|
||||
// Dates around 1900
|
||||
addNewTestCase( Date.UTC( 1899,11,31,23,59,59,999),
|
||||
"Date.UTC( 1899,11,31,23,59,59,999)",
|
||||
utc(1899,11,31,23,59,59,999) );
|
||||
addNewTestCase( Date.UTC( 1900,0,1,0,0,0,0),
|
||||
"Date.UTC( 1900,0,1,0,0,0,0)",
|
||||
utc(1900,0,1,0,0,0,0) );
|
||||
addNewTestCase( Date.UTC( 1973,0,1,0,0,0,0),
|
||||
"Date.UTC( 1973,0,1,0,0,0,0)",
|
||||
utc(1973,0,1,0,0,0,0) );
|
||||
addNewTestCase( Date.UTC( 1776,6,4,12,36,13,111),
|
||||
"Date.UTC( 1776,6,4,12,36,13,111)",
|
||||
utc(1776,6,4,12,36,13,111) );
|
||||
addNewTestCase( Date.UTC( 2525,9,18,15,30,1,123),
|
||||
"Date.UTC( 2525,9,18,15,30,1,123)",
|
||||
utc(2525,9,18,15,30,1,123) );
|
||||
|
||||
// Dates around 29 Feb 2000
|
||||
|
||||
addNewTestCase( Date.UTC( 2000,1,29,0,0,0,0 ),
|
||||
"Date.UTC( 2000,1,29,0,0,0,0 )",
|
||||
utc(2000,1,29,0,0,0,0) );
|
||||
addNewTestCase( Date.UTC( 2000,1,29,8,0,0,0 ),
|
||||
"Date.UTC( 2000,1,29,8,0,0,0 )",
|
||||
utc(2000,1,29,8,0,0,0) );
|
||||
|
||||
// Dates around 1 Jan 2005
|
||||
|
||||
addNewTestCase( Date.UTC( 2005,0,1,0,0,0,0 ),
|
||||
"Date.UTC( 2005,0,1,0,0,0,0 )",
|
||||
utc(2005,0,1,0,0,0,0) );
|
||||
addNewTestCase( Date.UTC( 2004,11,31,16,0,0,0 ),
|
||||
"Date.UTC( 2004,11,31,16,0,0,0 )",
|
||||
utc(2004,11,31,16,0,0,0) );
|
||||
}
|
||||
|
||||
function addNewTestCase( DateCase, DateString, ExpectDate) {
|
||||
DateCase = DateCase;
|
||||
|
||||
item = testcases.length;
|
||||
|
||||
// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year;
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase );
|
||||
testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase );
|
||||
/*
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ExpectDate.year, DateCase.getUTCFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ExpectDate.month, DateCase.getUTCMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ExpectDate.date, DateCase.getUTCDate() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ExpectDate.day, DateCase.getUTCDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ExpectDate.hours, DateCase.getUTCHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ExpectDate.minutes,DateCase.getUTCMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ExpectDate.seconds,DateCase.getUTCSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ExpectDate.ms, DateCase.getUTCMilliseconds() );
|
||||
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ExpectDate.year, DateCase.getFullYear() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ExpectDate.month, DateCase.getMonth() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ExpectDate.date, DateCase.getDate() );
|
||||
// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ExpectDate.day, DateCase.getDay() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ExpectDate.hours, DateCase.getHours() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ExpectDate.minutes, DateCase.getMinutes() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ExpectDate.seconds, DateCase.getSeconds() );
|
||||
testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ExpectDate.ms, DateCase.getMilliseconds() );
|
||||
*/
|
||||
}
|
||||
function test() {
|
||||
for( tc=0; tc < testcases.length; tc++ ) {
|
||||
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = " +
|
||||
testcases[tc].actual );
|
||||
}
|
||||
|
||||
stopTest();
|
||||
return testcases;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.1.js
|
||||
ECMA Section: 15.9.5.1 Date.prototype.constructor
|
||||
Description:
|
||||
The initial value of Date.prototype.constructor is the built-in Date
|
||||
constructor.
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.1.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.constructor";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.constructor == Date",
|
||||
true,
|
||||
Date.prototype.constructor == Date );
|
||||
test();
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( now );
|
||||
/*
|
||||
addTestCase( time );
|
||||
addTestCase( TIME_1970 );
|
||||
addTestCase( TIME_1900 );
|
||||
addTestCase( TIME_2000 );
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
addTestCase( DST_START_1998 );
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( DST_START_1998+1 );
|
||||
/*
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( DST_END_1998 );
|
||||
/*
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( DST_END_1998-1 );
|
||||
/*
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( DST_END_1998+1 );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( time );
|
||||
/*
|
||||
addTestCase( TIME_1970 );
|
||||
addTestCase( TIME_1900 );
|
||||
addTestCase( TIME_2000 );
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
addTestCase( DST_START_1998 );
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( TIME_1970 );
|
||||
/*
|
||||
addTestCase( TIME_1900 );
|
||||
addTestCase( TIME_2000 );
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
addTestCase( DST_START_1998 );
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( TIME_1900 );
|
||||
/*
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
addTestCase( DST_START_1998 );
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( TIME_2000 );
|
||||
/*
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
addTestCase( DST_START_1998 );
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
/*
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
addTestCase( DST_START_1998 );
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
/*
|
||||
addTestCase( DST_START_1998 );
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( DST_START_1998 );
|
||||
/*
|
||||
addTestCase( DST_START_1998-1 );
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.10.js
|
||||
ECMA Section: 15.9.5.10
|
||||
Description: Date.prototype.getDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
3.Return DateFromTime(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.10.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
// some daylight savings time cases
|
||||
|
||||
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
|
||||
|
||||
var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour );
|
||||
|
||||
addTestCase( DST_START_1998-1 );
|
||||
/*
|
||||
addTestCase( DST_START_1998+1 );
|
||||
addTestCase( DST_END_1998 );
|
||||
addTestCase( DST_END_1998-1 );
|
||||
addTestCase( DST_END_1998+1 );
|
||||
*/
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDate()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDate.length",
|
||||
0,
|
||||
Date.prototype.getDate.length );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDate()",
|
||||
DateFromTime(LocalTime(t)),
|
||||
(new Date(t)).getDate() );
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.11.js
|
||||
ECMA Section: 15.9.5.11
|
||||
Description: Date.prototype.getUTCDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
1.Return DateFromTime(t).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.11.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getUTCDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
addTestCase( now );
|
||||
|
||||
test()
|
||||
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 11; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getUTCDate()",
|
||||
DateFromTime((t)),
|
||||
(new Date(t)).getUTCDate() );
|
||||
/*
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+1)+")).getUTCDate()",
|
||||
DateFromTime((t+1)),
|
||||
(new Date(t+1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-1)+")).getUTCDate()",
|
||||
DateFromTime((t-1)),
|
||||
(new Date(t-1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t-TZ_ADJUST)),
|
||||
(new Date(t-TZ_ADJUST)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t+TZ_ADJUST)),
|
||||
(new Date(t+TZ_ADJUST)).getUTCDate() );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.11.js
|
||||
ECMA Section: 15.9.5.11
|
||||
Description: Date.prototype.getUTCDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
1.Return DateFromTime(t).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.11.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getUTCDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
|
||||
addTestCase( time );
|
||||
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 11; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getUTCDate()",
|
||||
DateFromTime((t)),
|
||||
(new Date(t)).getUTCDate() );
|
||||
/*
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+1)+")).getUTCDate()",
|
||||
DateFromTime((t+1)),
|
||||
(new Date(t+1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-1)+")).getUTCDate()",
|
||||
DateFromTime((t-1)),
|
||||
(new Date(t-1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t-TZ_ADJUST)),
|
||||
(new Date(t-TZ_ADJUST)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t+TZ_ADJUST)),
|
||||
(new Date(t+TZ_ADJUST)).getUTCDate() );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.11.js
|
||||
ECMA Section: 15.9.5.11
|
||||
Description: Date.prototype.getUTCDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
1.Return DateFromTime(t).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.11.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getUTCDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
addTestCase( TIME_1970 );
|
||||
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 11; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getUTCDate()",
|
||||
DateFromTime((t)),
|
||||
(new Date(t)).getUTCDate() );
|
||||
/*
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+1)+")).getUTCDate()",
|
||||
DateFromTime((t+1)),
|
||||
(new Date(t+1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-1)+")).getUTCDate()",
|
||||
DateFromTime((t-1)),
|
||||
(new Date(t-1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t-TZ_ADJUST)),
|
||||
(new Date(t-TZ_ADJUST)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t+TZ_ADJUST)),
|
||||
(new Date(t+TZ_ADJUST)).getUTCDate() );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.11.js
|
||||
ECMA Section: 15.9.5.11
|
||||
Description: Date.prototype.getUTCDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
1.Return DateFromTime(t).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.11.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getUTCDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
addTestCase( TIME_1900 );
|
||||
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 11; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( var d = 0; d < TimeInMonth( m ); d += 7* msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getUTCDate()",
|
||||
DateFromTime((t)),
|
||||
(new Date(t)).getUTCDate() );
|
||||
/*
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+1)+")).getUTCDate()",
|
||||
DateFromTime((t+1)),
|
||||
(new Date(t+1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-1)+")).getUTCDate()",
|
||||
DateFromTime((t-1)),
|
||||
(new Date(t-1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t-TZ_ADJUST)),
|
||||
(new Date(t-TZ_ADJUST)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t+TZ_ADJUST)),
|
||||
(new Date(t+TZ_ADJUST)).getUTCDate() );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.11.js
|
||||
ECMA Section: 15.9.5.11
|
||||
Description: Date.prototype.getUTCDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
1.Return DateFromTime(t).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.11.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getUTCDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
addTestCase( TIME_2000 );
|
||||
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 11; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getUTCDate()",
|
||||
DateFromTime((t)),
|
||||
(new Date(t)).getUTCDate() );
|
||||
/*
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+1)+")).getUTCDate()",
|
||||
DateFromTime((t+1)),
|
||||
(new Date(t+1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-1)+")).getUTCDate()",
|
||||
DateFromTime((t-1)),
|
||||
(new Date(t-1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t-TZ_ADJUST)),
|
||||
(new Date(t-TZ_ADJUST)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t+TZ_ADJUST)),
|
||||
(new Date(t+TZ_ADJUST)).getUTCDate() );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.11.js
|
||||
ECMA Section: 15.9.5.11
|
||||
Description: Date.prototype.getUTCDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
1.Return DateFromTime(t).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.11.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getUTCDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
|
||||
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 11; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getUTCDate()",
|
||||
DateFromTime((t)),
|
||||
(new Date(t)).getUTCDate() );
|
||||
/*
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+1)+")).getUTCDate()",
|
||||
DateFromTime((t+1)),
|
||||
(new Date(t+1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-1)+")).getUTCDate()",
|
||||
DateFromTime((t-1)),
|
||||
(new Date(t-1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t-TZ_ADJUST)),
|
||||
(new Date(t-TZ_ADJUST)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t+TZ_ADJUST)),
|
||||
(new Date(t+TZ_ADJUST)).getUTCDate() );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.11.js
|
||||
ECMA Section: 15.9.5.11
|
||||
Description: Date.prototype.getUTCDate
|
||||
|
||||
1.Let t be this time value.
|
||||
2.If t is NaN, return NaN.
|
||||
1.Return DateFromTime(t).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.11.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getUTCDate()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 11; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) {
|
||||
t += d;
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getUTCDate()",
|
||||
DateFromTime((t)),
|
||||
(new Date(t)).getUTCDate() );
|
||||
/*
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+1)+")).getUTCDate()",
|
||||
DateFromTime((t+1)),
|
||||
(new Date(t+1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-1)+")).getUTCDate()",
|
||||
DateFromTime((t-1)),
|
||||
(new Date(t-1)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t-TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t-TZ_ADJUST)),
|
||||
(new Date(t-TZ_ADJUST)).getUTCDate() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+(t+TZ_ADJUST)+")).getUTCDate()",
|
||||
DateFromTime((t+TZ_ADJUST)),
|
||||
(new Date(t+TZ_ADJUST)).getUTCDate() );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.12.js
|
||||
ECMA Section: 15.9.5.12
|
||||
Description: Date.prototype.getDay
|
||||
|
||||
|
||||
1. Let t be this time value.
|
||||
2. If t is NaN, return NaN.
|
||||
3. Return WeekDay(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.12.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDay()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
addTestCase( now );
|
||||
/*
|
||||
addTestCase( time );
|
||||
addTestCase( TIME_1970 );
|
||||
addTestCase( TIME_1900 );
|
||||
addTestCase( TIME_2000 );
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDay()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDay() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDay.length",
|
||||
0,
|
||||
Date.prototype.getDay.length );
|
||||
*/
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 12; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) {
|
||||
t += d;
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDay()",
|
||||
WeekDay(LocalTime(t)),
|
||||
(new Date(t)).getDay() );
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.12.js
|
||||
ECMA Section: 15.9.5.12
|
||||
Description: Date.prototype.getDay
|
||||
|
||||
|
||||
1. Let t be this time value.
|
||||
2. If t is NaN, return NaN.
|
||||
3. Return WeekDay(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.12.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDay()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
addTestCase( time );
|
||||
/*
|
||||
addTestCase( TIME_1970 );
|
||||
addTestCase( TIME_1900 );
|
||||
addTestCase( TIME_2000 );
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDay()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDay() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDay.length",
|
||||
0,
|
||||
Date.prototype.getDay.length );
|
||||
*/
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 12; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) {
|
||||
t += d;
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDay()",
|
||||
WeekDay(LocalTime(t)),
|
||||
(new Date(t)).getDay() );
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
File Name: 15.9.5.12.js
|
||||
ECMA Section: 15.9.5.12
|
||||
Description: Date.prototype.getDay
|
||||
|
||||
|
||||
1. Let t be this time value.
|
||||
2. If t is NaN, return NaN.
|
||||
3. Return WeekDay(LocalTime(t)).
|
||||
|
||||
Author: christine@netscape.com
|
||||
Date: 12 november 1997
|
||||
*/
|
||||
|
||||
var SECTION = "15.9.5.12.js";
|
||||
var VERSION = "ECMA_1";
|
||||
startTest();
|
||||
var TITLE = "Date.prototype.getDay()";
|
||||
|
||||
writeHeaderToLog( SECTION + " "+ TITLE);
|
||||
|
||||
var testcases = new Array();
|
||||
|
||||
var TZ_ADJUST = TZ_DIFF * msPerHour;
|
||||
|
||||
// get the current time
|
||||
var now = (new Date()).valueOf();
|
||||
|
||||
// calculate time for year 0
|
||||
for ( var time = 0, year = 1969; year >= 0; year-- ) {
|
||||
time -= TimeInYear(year);
|
||||
}
|
||||
// get time for 29 feb 2000
|
||||
|
||||
var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour;
|
||||
|
||||
// get time for 1 jan 2005
|
||||
|
||||
var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
|
||||
TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
|
||||
|
||||
addTestCase( TIME_1970 );
|
||||
/*
|
||||
addTestCase( TIME_1900 );
|
||||
addTestCase( TIME_2000 );
|
||||
addTestCase( UTC_FEB_29_2000 );
|
||||
addTestCase( UTC_JAN_1_2005 );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date(NaN)).getDay()",
|
||||
NaN,
|
||||
(new Date(NaN)).getDay() );
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"Date.prototype.getDay.length",
|
||||
0,
|
||||
Date.prototype.getDay.length );
|
||||
*/
|
||||
test();
|
||||
function addTestCase( t ) {
|
||||
for ( var m = 0; m < 12; m++ ) {
|
||||
t += TimeInMonth(m);
|
||||
|
||||
for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) {
|
||||
t += d;
|
||||
|
||||
testcases[tc++] = new TestCase( SECTION,
|
||||
"(new Date("+t+")).getDay()",
|
||||
WeekDay(LocalTime(t)),
|
||||
(new Date(t)).getDay() );
|
||||
}
|
||||
}
|
||||
}
|
||||
function test() {
|
||||
for ( tc=0; tc < testcases.length; tc++ ) {
|
||||
testcases[tc].passed = writeTestCaseResult(
|
||||
testcases[tc].expect,
|
||||
testcases[tc].actual,
|
||||
testcases[tc].description +" = "+
|
||||
testcases[tc].actual );
|
||||
|
||||
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
|
||||
}
|
||||
stopTest();
|
||||
return ( testcases );
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче