Add ability to run js/tests from browsers. Bug 263119

This commit is contained in:
bob%bclary.com 2005-03-18 19:09:59 +00:00
Родитель c76f2f6ee2
Коммит f5797aeb24
1100 изменённых файлов: 56679 добавлений и 62488 удалений

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

@ -1,8 +1,10 @@
JS = $(shell find . -name '*.js' -print)
testmenu:
all: menu.html
menu.html: menuhead.html menufoot.html $(JS) Makefile
exec perl mklistpage.pl > menubody.html
cat menuhead.html menubody.html menufoot.html > menu.html
testmenu_dos:
perl mklistpage.pl > menubody.html
type menuhead.html menubody.html menufoot.html > menu.html
clean:
rm -f menubody.html menu.html

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

182
js/tests/e4x/browser.js Normal file
Просмотреть файл

@ -0,0 +1,182 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (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.org code.
*
* 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.
*
* Contributor(s):
*/
/*
* JavaScript test library shared functions file for running the tests
* in the browser. Overrides the shell's print function with document.write
* and make everything HTML pretty.
*
* To run the tests in the browser, use the mkhtml.pl script to generate
* html pages that include the shell.js, browser.js (this file), and the
* test js file in script tags.
*
* The source of the page that is generated should look something like this:
* <script src="./../shell.js"></script>
* <script src="./../browser.js"></script>
* <script src="./mytest.js"></script>
*/
function writeLineToLog( string ) {
document.write( string + "<br>\n");
}
function print( string ) {
writeLineToLog( string );
}
var testcases = new Array();
var tc = testcases.length;
var BUGSTR = '';
var SUMMARY = '';
var DESCRIPTION = '';
var EXPECTED = '';
var ACTUAL = '';
var MSG = '';
var SECTION = '';
function TestCase(n, d, e, a)
{
this.name = n;
this.description = d;
this.expect = e;
this.actual = a;
this.passed = ( e == a );
this.reason = '';
this.bugnumber = typeof(BUGSTR) != 'undefined' ? BUGSTR : '';
testcases[tc++] = this;
}
function reportSuccess(section, expected, actual)
{
var testcase = new TestCase(gTestName, SUMMARY + DESCRIPTION + ' Section ' + section, expected, actual);
testcase.passed = true;
};
function reportError(msg, page, line)
{
var testcase;
if (typeof SUMMARY == 'undefined')
{
SUMMARY = 'Unknown';
}
if (typeof SECTION == 'undefined')
{
SECTION = 'Unknown';
}
if (typeof DESCRIPTION == 'undefined')
{
DESCRIPTION = 'Unknown';
}
if (typeof EXPECTED == 'undefined')
{
EXPECTED = 'Unknown';
}
testcase = new TestCase(gTestName, SUMMARY + DESCRIPTION + ' Section ' + SECTION, EXPECTED, "error");
testcase.passed = false;
testcase.reason += msg;
if (typeof(page) != 'undefined')
{
testcase.reason += ' Page: ' + page;
}
if (typeof(line) != 'undefined')
{
testcase.reason += ' Line: ' + line;
}
reportFailure(SECTION, msg);
};
var _reportFailure = reportFailure;
reportFailure = function (section, msg)
{
var testcase;
testcase = new TestCase(gTestName, SUMMARY + DESCRIPTION + ' Section ' + section, EXPECTED, ACTUAL);
testcase.passed = false;
testcase.reason += msg;
_reportFailure(section, msg);
};
var _printBugNumber = printBugNumber;
printBugNumber = function (num)
{
BUGSTR = BUGNUMBER + num;
_printBugNumber(num);
}
var _START = START;
START = function (summary)
{
SUMMARY = summary;
printStatus(summary);
}
var _TEST = TEST;
TEST = function (section, expected, actual)
{
SECTION = section;
EXPECTED = expected;
ACTUAL = actual;
if (_TEST(section, expected, actual))
{
reportSuccess(section, expected, actual);
}
}
var _TEST_XML = TEST_XML;
TEST_XML = function (section, expected, actual)
{
SECTION = section;
EXPECTED = expected;
ACTUAL = actual;
if (_TEST_XML(section, expected, actual))
{
reportSuccess(section, expected, actual);
}
}
function gc()
{
}
function quit()
{
}
// override NL from shell.js.
// assume running either on unix with \n line endings
// or on windows under cygwin with \n line endings.
function NL()
{
return '\n';
}
window.onerror = reportError;

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

@ -138,7 +138,9 @@ function TEST(section, expected, actual)
if (output != "")
{
reportFailure (section, output);
return false;
}
return true;
}
function TEST_XML(section, expected, actual)
@ -148,17 +150,19 @@ function TEST_XML(section, expected, actual)
if (actual_t != "xml") {
// force error on type mismatch
TEST(section, new XML(), actual);
return;
return TEST(section, new XML(), actual);
}
if (expected_t == "string") {
TEST(section, expected, actual.toXMLString());
} else if (expected_t == "number") {
TEST(section, String(expected), actual.toXMLString());
} else {
reportFailure (section, "Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string");
return TEST(section, expected, actual.toXMLString());
}
if (expected_t == "number") {
return TEST(section, String(expected), actual.toXMLString());
}
reportFailure (section, "Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string");
return false;
}
function SHOULD_THROW(section)

49
js/tests/e4x/template.js Executable file
Просмотреть файл

@ -0,0 +1,49 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- *//* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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/MPL/
*
* 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 JavaScript Engine testing utilities.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
START("section - description");
var bug = 99999;
var summary = '';
var actual = '';
var expect = '';
printBugNumber (bug);
printStatus (summary);
// test here
END();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,108 +35,97 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4-1.js
ECMA Section: 15.4 Array Objects
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).
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
Author: christine@netscape.com
Date: 28 october 1997
*/
var SECTION = "15.4-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array Objects";
var SECTION = "15.4-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array Objects";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
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]")
);
function getTestCases() {
var array = new Array();
var item = 0;
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)-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")
);
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,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")
);
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)-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")
);
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]")
);
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)]='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")
);
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,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 );
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")
);
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)]")
);
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")
);
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]")
);
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")
);
test();
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,65 +35,78 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4-2.js
ECMA Section: 15.4 Array Objects
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.
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
Author: christine@netscape.com
Date: 28 october 1997
*/
var SECTION = "15.4-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array Objects";
var SECTION = "15.4-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array Objects";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
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") );
function getTestCases() {
var array = new Array();
var item = 0;
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,16)] = 'hi'; arr.length", Math.pow(2,16)+1, eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") );
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)-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") );
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") );
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") );
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 );
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") );
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") );
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)") );
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)") );
test();
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,70 +35,75 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.1.1.js
ECMA Section: 15.4.1 Array( item0, item1,... )
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.
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, ... ).
An array is created and returned as if by the expression
new Array( item0, item1, ... ).
Author: christine@netscape.com
Date: 7 october 1997
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";
var SECTION = "15.4.1.1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array Constructor Called as a Function";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"typeof Array(1,2)",
"object",
typeof Array(1,2) );
new TestCase( SECTION,
"(Array(1,2)).toString",
Array.prototype.toString,
(Array(1,2)).toString );
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()") );
new TestCase( SECTION,
"(Array(1,2)).length",
2,
(Array(1,2)).length );
new TestCase( SECTION,
"var arr = (Array(1,2)); arr[0]",
1,
eval("var arr = (Array(1,2)); arr[0]") );
new TestCase( SECTION,
"var arr = (Array(1,2)); arr[1]",
2,
eval("var arr = (Array(1,2)); arr[1]") );
new TestCase( SECTION,
"var arr = (Array(1,2)); String(arr)",
"1,2",
eval("var arr = (Array(1,2)); String(arr)") );
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;
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);
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 );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,80 +35,126 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.1.2.js
ECMA Section: 15.4.1.2 Array(len)
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.
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).
An array is created and returned as if by the
expression new Array(len).
Author: christine@netscape.com
Date: 7 october 1997
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)";
var SECTION = "15.4.1.2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array Constructor Called as a Function: Array(len)";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"(Array()).length",
0,
(Array()).length );
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"(Array(0)).length",
0,
(Array(0)).length );
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(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(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", 1, (Array("8589934592")).length );
array[item++] = new TestCase( SECTION, "(Array('4294967296')).length", 1, (Array("4294967296")).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 );
new TestCase( SECTION,
"(Array(1)).length",
1,
(Array(1)).length );
new TestCase( SECTION,
"(Array(10)).length",
10,
(Array(10)).length );
new TestCase( SECTION,
"(Array('1')).length",
1,
(Array('1')).length );
new TestCase( SECTION,
"(Array(1000)).length",
1000,
(Array(1000)).length );
new TestCase( SECTION,
"(Array('1000')).length",
1,
(Array('1000')).length );
new TestCase( SECTION,
"(Array(4294967295)).length",
ToUint32(4294967295),
(Array(4294967295)).length );
new TestCase( SECTION,
"(Array(Math.pow(2,31)-1)).length",
ToUint32(Math.pow(2,31)-1),
(Array(Math.pow(2,31)-1)).length );
new TestCase( SECTION,
"(Array(Math.pow(2,31))).length",
ToUint32(Math.pow(2,31)),
(Array(Math.pow(2,31))).length );
new TestCase( SECTION,
"(Array(Math.pow(2,31)+1)).length",
ToUint32(Math.pow(2,31)+1),
(Array(Math.pow(2,31)+1)).length );
new TestCase( SECTION,
"(Array('8589934592')).length",
1,
(Array("8589934592")).length );
new TestCase( SECTION,
"(Array('4294967296')).length",
1,
(Array("4294967296")).length );
new TestCase( SECTION,
"(Array(1073741823)).length",
ToUint32(1073741823),
(Array(1073741823)).length );
new TestCase( SECTION,
"(Array(1073741824)).length",
ToUint32(1073741824),
(Array(1073741824)).length );
new TestCase( SECTION,
"(Array('a string')).length",
1,
(Array("a string")).length );
test();
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;
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) )
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);
}
if ( n < 0 ){
n += Math.pow(2,32);
}
return ( n );
}
return ( n );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,68 +35,48 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.1.3.js
ECMA Section: 15.4.1.3 Array()
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.
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).
An array is created and returned as if by the
expression new Array(len).
Author: christine@netscape.com
Date: 7 october 1997
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()";
var SECTION = "15.4.1.3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array Constructor Called as a Function: Array()";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"typeof Array()",
"object",
typeof Array() );
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()") );
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"(Array()).length",
0,
(Array()).length );
array[item++] = new TestCase( SECTION,
"typeof Array()",
"object",
typeof Array() );
new TestCase( SECTION,
"Array().toString()",
"",
Array().toString() );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,115 +35,96 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.1.js
ECMA Section: 15.4.1 The Array Constructor Called as a Function
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.
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
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";
var SECTION = "15.4.1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Array Constructor Called as a Function";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"Array() +''",
"",
Array() +"" );
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"typeof Array()",
"object",
typeof Array() );
array[item++] = new TestCase( SECTION,
"Array() +''",
"",
Array() +"" );
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,
"typeof Array()",
"object",
typeof Array() );
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,
"var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
"[object Array]",
eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
new TestCase( SECTION,
"Array().length",
0,
Array().length );
array[item++] = new TestCase( SECTION,
"var arr = Array(); arr.toString == Array.prototype.toString",
true,
eval("var arr = Array(); arr.toString == Array.prototype.toString") );
new TestCase( SECTION,
"Array(1,2,3) +''",
"1,2,3",
Array(1,2,3) +"" );
array[item++] = new TestCase( SECTION,
"Array().length",
0,
Array().length );
new TestCase( SECTION,
"typeof Array(1,2,3)",
"object",
typeof Array(1,2,3) );
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,
"Array(1,2,3) +''",
"1,2,3",
Array(1,2,3) +"" );
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,
"typeof Array(1,2,3)",
"object",
typeof Array(1,2,3) );
new TestCase( SECTION,
"Array(1,2,3).length",
3,
Array(1,2,3).length );
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()") );
new TestCase( SECTION,
"typeof Array(12345)",
"object",
typeof Array(12345) );
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") );
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,
"Array(1,2,3).length",
3,
Array(1,2,3).length );
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,
"typeof Array(12345)",
"object",
typeof Array(12345) );
new TestCase( SECTION,
"Array(12345).length",
12345,
Array(12345).length );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,74 +35,76 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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 [[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 [[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 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.
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.
This file tests the typeof the newly constructed object.
Author: christine@netscape.com
Date: 7 october 1997
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, ...)";
var SECTION = "15.4.2.1-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"typeof new Array(1,2)",
"object",
typeof new Array(1,2) );
new TestCase( SECTION,
"(new Array(1,2)).toString",
Array.prototype.toString,
(new Array(1,2)).toString );
function getTestCases() {
var array = new Array();
var item = 0;
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, "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()") );
new TestCase( SECTION,
"(new Array(1,2)).length",
2,
(new Array(1,2)).length );
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)") );
new TestCase( SECTION,
"var arr = (new Array(1,2)); arr[0]",
1,
eval("var arr = (new Array(1,2)); arr[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 );
new TestCase( SECTION,
"var arr = (new Array(1,2)); arr[1]",
2,
eval("var arr = (new Array(1,2)); arr[1]") );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}
new TestCase( SECTION,
"var arr = (new Array(1,2)); String(arr)",
"1,2",
eval("var arr = (new Array(1,2)); String(arr)") );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,65 +35,65 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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 [[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 [[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 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.
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
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, ...)";
var SECTION = "15.4.2.1-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
testcases = getTestCases();
test();
var TEST_STRING = "new Array(";
var ARGUMENTS = ""
var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
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 );
for ( var index = 0; index < TEST_LENGTH; index++ ) {
ARGUMENTS += index;
ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
}
TEST_STRING += ARGUMENTS + ")";
TEST_ARRAY = eval( TEST_STRING );
for ( var item = 0; item < TEST_LENGTH; item++ ) {
new TestCase( SECTION,
"["+item+"]",
item,
TEST_ARRAY[item] );
}
new TestCase( SECTION,
"new Array( ["+TEST_LENGTH+" arguments] ) +''",
ARGUMENTS,
TEST_ARRAY +"" );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,94 +35,101 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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 [[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 [[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 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.
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.
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.
***Change TEST_LENGTH to Math.pow(2,32) when larger array
lengths are supported.
Author: christine@netscape.com
Date: 7 october 1997
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, ...)";
var SECTION = "15.4.2.1-3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
var TEST_STRING = "new Array(";
var ARGUMENTS = ""
var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
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 );
for ( var index = 0; index < TEST_LENGTH; index++ ) {
ARGUMENTS += index;
ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
}
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 );
TEST_STRING += ARGUMENTS + ")";
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
TEST_ARRAY = eval( TEST_STRING );
for ( var item = 0; item < TEST_LENGTH; item++ ) {
new TestCase( SECTION,
"TEST_ARRAY["+item+"]",
item,
TEST_ARRAY[item] );
}
new TestCase( SECTION,
"new Array( ["+TEST_LENGTH+" arguments] ) +''",
ARGUMENTS,
TEST_ARRAY +"" );
new TestCase( SECTION,
"TEST_ARRAY.toString",
Array.prototype.toString,
TEST_ARRAY.toString );
new TestCase( SECTION,
"TEST_ARRAY.join",
Array.prototype.join,
TEST_ARRAY.join );
new TestCase( SECTION,
"TEST_ARRAY.sort",
Array.prototype.sort,
TEST_ARRAY.sort );
new TestCase( SECTION,
"TEST_ARRAY.reverse",
Array.prototype.reverse,
TEST_ARRAY.reverse );
new TestCase( SECTION,
"TEST_ARRAY.length",
TEST_LENGTH,
TEST_ARRAY.length );
new TestCase( SECTION,
"TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()",
"[object Array]",
eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,106 +35,147 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.2.2-1.js
ECMA Section: 15.4.2.2 new Array(len)
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.
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 [[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".
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 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.
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.
This file tests cases where len is a number.
The cases in this test need to be updated since the
ToUint32 description has changed.
The cases in this test need to be updated since the
ToUint32 description has changed.
Author: christine@netscape.com
Date: 7 october 1997
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 )";
var SECTION = "15.4.2.2-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Array Constructor: new Array( len )";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"new Array(0)",
"",
(new Array(0)).toString() );
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"typeof new Array(0)",
"object",
(typeof new Array(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 );
new TestCase( SECTION,
"(new Array(0)).length",
0,
(new Array(0)).length );
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 );
new TestCase( SECTION,
"(new Array(0)).toString",
Array.prototype.toString,
(new Array(0)).toString );
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 );
new TestCase( SECTION,
"new Array(1)",
"",
(new Array(1)).toString() );
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 );
new TestCase( SECTION,
"new Array(1).length",
1,
(new Array(1)).length );
array[item++] = new TestCase( SECTION, "(new Array(4294967295)).length", ToUint32(4294967295), (new Array(4294967295)).length );
new TestCase( SECTION,
"(new Array(1)).toString",
Array.prototype.toString,
(new Array(1)).toString );
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(1073741824)).length", ToUint32(1073741824), (new Array(1073741824)).length );
new TestCase( SECTION,
"(new Array(-0)).length",
0,
(new Array(-0)).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 );
new TestCase( SECTION,
"(new Array(0)).length",
0,
(new Array(0)).length );
new TestCase( SECTION,
"(new Array(10)).length",
10,
(new Array(10)).length );
new TestCase( SECTION,
"(new Array('1')).length",
1,
(new Array('1')).length );
new TestCase( SECTION,
"(new Array(1000)).length",
1000,
(new Array(1000)).length );
new TestCase( SECTION,
"(new Array('1000')).length",
1,
(new Array('1000')).length );
new TestCase( SECTION,
"(new Array(4294967295)).length",
ToUint32(4294967295),
(new Array(4294967295)).length );
new TestCase( SECTION,
"(new Array('8589934592')).length",
1,
(new Array("8589934592")).length );
new TestCase( SECTION,
"(new Array('4294967296')).length",
1,
(new Array("4294967296")).length );
new TestCase( SECTION,
"(new Array(1073741824)).length",
ToUint32(1073741824),
(new Array(1073741824)).length );
test();
testcases[tc].reason += ( testcases[tc].passed )
? ""
: "wrong value ";
}
stopTest();
return ( testcases );
}
function ToUint32( n ) {
n = Number( n );
var sign = ( n < 0 ) ? -1 : 1;
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) )
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);
}
if ( n < 0 ){
n += Math.pow(2,32);
}
return ( n );
}
return ( n );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,71 +35,82 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.2.2-2.js
ECMA Section: 15.4.2.2 new Array(len)
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.
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 [[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".
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 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.
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.
This file tests length of the newly constructed array
when len is not a number.
Author: christine@netscape.com
Date: 7 october 1997
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 )";
var SECTION = "15.4.2.2-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Array Constructor: new Array( len )";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"(new Array(new Number(1073741823))).length",
1,
(new Array(new Number(1073741823))).length );
function getTestCases() {
var array = new Array();
var item = 0;
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(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 );
}
new TestCase( SECTION,
"(new Array(new Number(1000))).length",
1,
(new Array(new Number(1000))).length );
new TestCase( SECTION,
"(new Array('mozilla, larryzilla, curlyzilla')).length",
1,
(new Array('mozilla, larryzilla, curlyzilla')).length );
new TestCase( SECTION,
"(new Array(true)).length",
1,
(new Array(true)).length );
new TestCase( SECTION,
"(new Array(false)).length",
1,
(new Array(false)).length);
new TestCase( SECTION,
"(new Array(new Boolean(true)).length",
1,
(new Array(new Boolean(true))).length );
new TestCase( SECTION,
"(new Array(new Boolean(false)).length",
1,
(new Array(new Boolean(false))).length );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,56 +35,65 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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()";
var SECTION = "15.4.2.3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Array Constructor: new Array()";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"new Array() +''",
"",
(new Array()) +"" );
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()") );
new TestCase( SECTION,
"typeof new Array()",
"object",
(typeof new Array()) );
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 );
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()") );
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 );
new TestCase( SECTION,
"(new Array()).length",
0,
(new Array()).length );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}
new TestCase( SECTION,
"(new Array()).toString == Array.prototype.toString",
true,
(new Array()).toString == Array.prototype.toString );
new TestCase( SECTION,
"(new Array()).join == Array.prototype.join",
true,
(new Array()).join == Array.prototype.join );
new TestCase( SECTION,
"(new Array()).reverse == Array.prototype.reverse",
true,
(new Array()).reverse == Array.prototype.reverse );
new TestCase( SECTION,
"(new Array()).sort == Array.prototype.sort",
true,
(new Array()).sort == Array.prototype.sort );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,48 +35,45 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
var SECTION = "15.4.3.1-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.prototype";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
function getTestCases() {
var array = new Array();
var item = 0;
var ARRAY_PROTO = Array.prototype;
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") );
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") );
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") );
new TestCase( SECTION,
"delete Array.prototype",
false,
delete 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 );
}
new TestCase( SECTION,
"delete Array.prototype; Array.prototype",
ARRAY_PROTO,
eval("delete Array.prototype; Array.prototype") );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,39 +35,26 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
var SECTION = "15.4.3.2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.length";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"Array.length",
1,
Array.length );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,45 +35,27 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
var SECTION = "15.4.3";
var VERSION = "ECMA_2";
startTest();
var TITLE = "Properties of the Array Constructor";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION,
"Array.__proto__",
Function.prototype,
Array.__proto__ );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,39 +35,27 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
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";
var SECTION = "15.4.4.1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.prototype.constructor";
writeHeaderToLog( SECTION + " "+ TITLE);
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 );
}
new TestCase( SECTION,
"Array.prototype.constructor == Array",
true,
Array.prototype.constructor == Array);
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,65 +35,74 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
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";
var SECTION = "15.4.4.2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.prototype.toString";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
new TestCase( SECTION,
"Array.prototype.toString.length",
0,
Array.prototype.toString.length );
var testcases = getTestCases();
test();
new TestCase( SECTION,
"(new Array()).toString()",
"",
(new Array()).toString() );
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"(new Array(2)).toString()",
",",
(new Array(2)).toString() );
array[item++] = new TestCase( SECTION, "Array.prototype.toString.length", 0, Array.prototype.toString.length );
new TestCase( SECTION,
"(new Array(0,1)).toString()",
"0,1",
(new Array(0,1)).toString() );
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() );
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() );
new TestCase( SECTION,
"(new Array( Boolean(1), Boolean(0))).toString()",
"true,false",
(new Array(Boolean(1),Boolean(0))).toString() );
var EXPECT_STRING = "";
var MYARR = new Array();
new TestCase( SECTION,
"(new Array(void 0,null)).toString()",
",",
(new Array(void 0,null)).toString() );
for ( var i = -50; i < 50; i+= 0.25 ) {
MYARR[MYARR.length] = i;
EXPECT_STRING += i +",";
}
var EXPECT_STRING = "";
var MYARR = new Array();
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 );
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 );
new TestCase( SECTION,
"MYARR.toString()",
EXPECT_STRING,
MYARR.toString() );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,141 +35,127 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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, pschwartau@netscape.com
Date: 07 October 1997
Modified: 14 July 2002
Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155285
ECMA-262 Ed.3 Section 15.4.4.5 Array.prototype.join()
Step 3: If |separator| is |undefined|, let |separator|
be the single-character string ","
*
*/
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, pschwartau@netscape.com
Date: 07 October 1997
Modified: 14 July 2002
Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155285
ECMA-262 Ed.3 Section 15.4.4.5 Array.prototype.join()
Step 3: If |separator| is |undefined|, let |separator|
be the single-character string ","
*
*/
var SECTION = "15.4.4.3-1";
var VERSION = "ECMA_1";
startTest();
var SECTION = "15.4.4.3-1";
var VERSION = "ECMA_1";
startTest();
writeHeaderToLog( SECTION + " Array.prototype.join()");
writeHeaderToLog( SECTION + " Array.prototype.join()");
var testcases = getTestCases();
test();
var ARR_PROTOTYPE = Array.prototype;
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length );
new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length );
new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") );
var ARR_PROTOTYPE = Array.prototype;
// case where array length is 0
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") );
new TestCase( SECTION,
"var TEST_ARRAY = new Array(); TEST_ARRAY.join()",
"",
eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join()") );
// case where array length is 0
// 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()") );
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
// length is greater than 0, separator is supplied
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('&')") );
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 empty string
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 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 undefined
new TestCase( SECTION,
"var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)",
",,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(void 0)") );
// 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)",
",,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(void 0)") );
// length is greater than 0, separator is not supplied
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 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
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')") );
// 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')") );
// length of array is 1
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 = "";
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 ) ? "" : ",";
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 );
TEST_RESULT += index;
TEST_RESULT += ( index == TEST_LENGTH -1 ) ? "" : SEPARATOR;
}
TEST_ARRAY = eval( "new Array( "+ARGUMENTS +")" );
new TestCase( SECTION,
"TEST_ARRAY.join("+SEPARATOR+")",
TEST_RESULT,
TEST_ARRAY.join( SEPARATOR ) );
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
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(':')") );
test();
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;
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -35,12 +36,12 @@
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.4.3-1.js
ECMA Section: 15.4.4.3-1 Array.prototype.reverse()
Description:
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.
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)).
@ -51,237 +52,240 @@
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.
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 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.
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
Author: christine@netscape.com
Date: 7 october 1997
*/
var SECTION = "15.4.4.4-1";
var VERSION = "ECMA_1";
startTest();
var BUGNUMBER="123724";
var SECTION = "15.4.4.4-1";
var VERSION = "ECMA_1";
startTest();
var BUGNUMBER="123724";
writeHeaderToLog( SECTION + " Array.prototype.reverse()");
writeHeaderToLog( SECTION + " Array.prototype.reverse()");
var testcases = new Array();
getTestCases();
test();
var ARR_PROTOTYPE = Array.prototype;
function getTestCases() {
var ARR_PROTOTYPE = Array.prototype;
new TestCase( SECTION,
"Array.prototype.reverse.length",
0,
Array.prototype.reverse.length );
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") );
new TestCase( SECTION,
"delete Array.prototype.reverse.length",
false,
delete 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") );
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 1
var A = new Array(true);
var R = Reverse(A);
// length of array is 0
new TestCase( SECTION,
"var A = new Array(); A.reverse(); A.length",
0,
eval("var A = new Array(); A.reverse(); A.length") );
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 1
var A = new Array(true);
var R = Reverse(A);
// length of array is 2
var S = "var A = new Array( true,false )";
eval(S);
var R = Reverse(A);
new TestCase( SECTION,
"var A = new Array(true); A.reverse(); A.length",
R.length,
eval("var A = new Array(true); A.reverse(); A.length") );
testcases[testcases.length] = new TestCase(
SECTION,
S +"; A.reverse(); A.length",
R.length,
eval( S + "; A.reverse(); A.length") );
CheckItems( R, A );
CheckItems( R, A );
// length of array is 2
var S = "var A = new Array( true,false )";
eval(S);
var R = Reverse(A);
// length of array is 3
var S = "var A = new Array( true,false,null )";
eval(S);
var R = Reverse(A);
new TestCase( SECTION,
S +"; A.reverse(); A.length",
R.length,
eval( S + "; A.reverse(); A.length") );
testcases[testcases.length] = new TestCase( SECTION,
S +"; A.reverse(); A.length",
R.length,
eval( S + "; A.reverse(); A.length") );
CheckItems( R, A );
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);
// 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 );
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);
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);
// 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 );
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 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 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);
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 );
new TestCase( SECTION,
S +"; A.reverse(); A.length",
R.length,
eval( S + "; A.reverse(); A.length") );
var limit = 1000;
var args = "";
for (var i = 0; i < limit; i++ ) {
args += i +"";
if ( i + 1 < limit ) {
args += ",";
}
}
CheckItems( R, A );
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 );
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);
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 );
new TestCase( SECTION,
S +"; A.reverse(); A.length",
R.length,
eval( S + "; A.reverse(); A.length") );
CheckItems( R, A );
test();
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 );
for ( var i = 0; i < R.length; i++ ) {
new TestCase(
SECTION,
"A["+i+ "]",
R[i],
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.join = Array.prototype.reverse;
this.getClass = Object.prototype.toString;
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;
}
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++ ) {
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;
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,13 +35,14 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
/**
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)).
@ -51,128 +53,115 @@
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.
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 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.
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
Author: christine@netscape.com
Date: 7 october 1997
*/
var SECTION = "15.4.4.4-1";
var VERSION = "ECMA_1";
startTest();
var testcases = new Array();
var SECTION = "15.4.4.4-1";
var VERSION = "ECMA_1";
startTest();
writeHeaderToLog( SECTION + " Array.prototype.reverse()");
writeHeaderToLog( SECTION + " Array.prototype.reverse()");
getTestCases();
test();
var ARR_PROTOTYPE = Array.prototype;
function getTestCases() {
var ARR_PROTOTYPE = Array.prototype;
new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length );
new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length );
new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") );
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
new TestCase( SECTION,
"var A = new Array(); A.reverse(); A.length",
0,
eval("var A = new Array(); A.reverse(); A.length") );
test();
// 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 );
for ( var i = 0; i < R.length; i++ ) {
new TestCase(
SECTION,
"A["+i+ "]",
R[i],
A[i] );
}
}
test();
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;
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;
}
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++ ) {
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;
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,205 +35,187 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.4.5.js
ECMA Section: Array.prototype.sort(comparefn)
Description:
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.
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.
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.
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.
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, 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 .
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
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)";
var SECTION = "15.4.4.5-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.prototype.sort(comparefn)";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var S = new Array();
var item = 0;
var testcases = new Array();
getTestCases();
test();
// array is empty.
S[item++] = "var A = new 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 );
// array contains one item
S[item++] = "var A = new Array( true )";
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
// 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] += ",";
}
}
function getTestCases() {
var S = new Array();
var item = 0;
// array is empty.
S[item++] = "var A = new Array()";
S[item] += ")";
// array contains one item
S[item++] = "var A = new Array( true )";
item++;
// 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] );
}
for ( var i = 0; i < S.length; i++ ) {
CheckItems( S[i] );
}
function CheckItems( S ) {
eval( S );
var E = Sort( A );
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") );
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] +"");
for ( var i = 0; i < E.length; i++ ) {
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] );
}
if ( A[i] == void 0 && typeof A[i] == "undefined" ) {
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;
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;
}
}
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;
}
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;
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,206 +35,191 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.4.5-2.js
ECMA Section: Array.prototype.sort(comparefn)
Description:
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.
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.
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.
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.
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, 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 .
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
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)";
var SECTION = "15.4.4.5-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.prototype.sort(comparefn)";
writeHeaderToLog( SECTION + " "+ TITLE);
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 );
var S = new Array();
var item = 0;
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
// 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] += ",";
}
}
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] );
}
S[item] += ")";
for ( var i = 0; i < S.length; i++ ) {
CheckItems( S[i] );
}
test();
function CheckItems( S ) {
eval( S );
var E = Sort( A );
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") );
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] +"");
for ( var i = 0; i < E.length; i++ ) {
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] );
}
if ( A[i] == void 0 && typeof A[i] == "undefined" ) {
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;
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;
}
}
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;
}
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;
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,163 +35,146 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.4.4.5-3.js
ECMA Section: Array.prototype.sort(comparefn)
Description:
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
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.
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
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)";
var SECTION = "15.4.4.5-3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.prototype.sort(comparefn)";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
getTestCases();
test();
var array = new 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 );
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 );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
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; i < array.length; i++) {
new TestCase(
SECTION,
"testarr1["+i+"]",
realarr[i],
testarr1[i] );
}
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() );
}
for ( var i=0; i < array.length; i++) {
new TestCase(
SECTION,
"testarr2["+i+"]",
realarr[i],
testarr2[i] );
}
for ( var i=0; i < array.length; i++) {
new TestCase(
SECTION,
"testarr3["+i+"]",
realarr[i],
testarr3[i] );
}
for ( var i=0; i < array.length; i++) {
new TestCase(
SECTION,
"testarr4["+i+"]",
stringarr[i].toString(),
testarr4[i].toString() );
}
test();
function comparefn1( x, y ) {
return x - y;
return x - y;
}
function comparefn2( x, y ) {
return x.valueOf() - y.valueOf();
return x.valueOf() - y.valueOf();
}
function realsort( x, y ) {
return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) );
return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) );
}
function comparefn3( x, y ) {
return ( x == y ? 0 : ( x > y ? 1: -1 ) );
return ( x == y ? 0 : ( x > y ? 1: -1 ) );
}
function clone( source, target ) {
for (i = 0; i < source.length; i++ ) {
target[i] = source[i];
}
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;
}
}
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;
var d = x.length - y.length;
if ( d > 0 ) {
return 1;
} else {
if ( d < 0 ) {
return -1;
}
}
}
return 0;
}
if ( d > 0 ) {
return 1;
} else {
if ( d < 0 ) {
return -1;
}
}
}
return 0;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,59 +35,38 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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.
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
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";
var SECTION = "15.4.4";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Properties of the Array Prototype Object";
writeHeaderToLog( SECTION + " "+ TITLE);
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 );
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 );
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()") );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,154 +35,134 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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).
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.
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:
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
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)";
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") );
// 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") );
writeHeaderToLog( SECTION + " "+ TITLE);
// A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the
// value of length
// P is "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]") );
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[123] = 'hola'; A.length",
1000,
eval("var A = new Array(1000); A[123] = 'hola'; A.length") );
// A has Property P, and P is not length or an array index
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") );
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") );
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 += ");"
}
}
// A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the
// value of length
var LENGTH = 0x00ff - 0x0020;
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,
TEST_STRING +" A[150] = 'hello'; A[150]",
'hello',
eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) );
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") );
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;
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 += ");"
}
}
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 );
var LENGTH = 0x00ff - 0x0020;
new TestCase( SECTION,
TEST_STRING +" A[150] = 'hello'; A[150]",
'hello',
eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) );
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
new TestCase( SECTION,
"var A = new Array(); A[123] = true; A.length",
124,
eval("var A = new Array(); A[123] = true; A.length") );
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++ ) {
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"
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") );
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") );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,132 +35,116 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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).
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.
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:
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.
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
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
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)";
var SECTION = "15.4.5.1-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array [[Put]] (P,V)";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
var a = new Array();
var a = new Array();
AddCase( "3.00", "three" );
AddCase( "00010", "eight" );
AddCase( "37xyz", "thirty-five" );
AddCase("5000000000", 5)
AddCase( "-2", -3 );
AddCase( "3.00", "three" );
AddCase( "00010", "eight" );
AddCase( "37xyz", "thirty-five" );
AddCase("5000000000", 5)
AddCase( "-2", -3 );
new TestCase( SECTION,
"a[10]",
void 0,
a[10] );
testcases[tc++] = new TestCase( SECTION,
"a[10]",
void 0,
a[10] );
new TestCase( SECTION,
"a[3]",
void 0,
a[3] );
testcases[tc++] = new TestCase( SECTION,
"a[3]",
void 0,
a[3] );
a[4] = "four";
a[4] = "four";
new TestCase( SECTION,
"a[4] = \"four\"; a[4]",
"four",
a[4] );
testcases[tc++] = new TestCase( SECTION,
"a[4] = \"four\"; a[4]",
"four",
a[4] );
new TestCase( SECTION,
"a[\"4\"]",
"four",
a["4"] );
testcases[tc++] = new TestCase( SECTION,
"a[\"4\"]",
"four",
a["4"] );
new TestCase( SECTION,
"a[\"4.00\"]",
void 0,
a["4.00"] );
testcases[tc++] = new TestCase( SECTION,
"a[\"4.00\"]",
void 0,
a["4.00"] );
testcases[tc++] = new TestCase( SECTION,
"a.length",
5,
a.length );
new TestCase( SECTION,
"a.length",
5,
a.length );
a["5000000000"] = 5;
a["5000000000"] = 5;
testcases[tc++] = new TestCase( SECTION,
"a[\"5000000000\"] = 5; a.length",
5,
a.length );
new TestCase( SECTION,
"a[\"5000000000\"] = 5; a.length",
5,
a.length );
testcases[tc++] = new TestCase( SECTION,
"a[\"-2\"] = -3; a.length",
5,
a.length );
new TestCase( SECTION,
"a[\"-2\"] = -3; a.length",
5,
a.length );
test();
test();
function AddCase ( arg, value ) {
a[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 );
new TestCase( SECTION,
"a[\"" + arg + "\"] = "+ value +"; a.length",
0,
a.length );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,75 +35,50 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
var SECTION = "15.4.5.2-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.length";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"var A = new Array(); A.length",
0,
eval("var A = new Array(); A.length") );
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") );
new TestCase( SECTION,
"var A = new Array(); A.length = 123; A.length",
123,
eval("var A = new Array(); A.length = 123; A.length") );
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") );
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") );
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") );
test();
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 );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,105 +35,91 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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 }.
The length property has the attributes { DontEnum, DontDelete }.
This test verifies that the Array.length property is not Read Only.
This test verifies that the Array.length property is not Read Only.
Author: christine@netscape.com
Date: 12 november 1997
Author: christine@netscape.com
Date: 12 november 1997
*/
var SECTION = "15.4.5.2-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.length";
var SECTION = "15.4.5.2-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Array.length";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) );
addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) );
addCase( new Array(), 0, 1, 1 );
addCase( new Array(), 0, 1, 1 );
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) )
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 ? "," : "" );
// 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+")" );
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 );
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();
test();
function addCase( object, old_len, set_len, new_len, checkitems ) {
object.length = set_len;
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 );
new TestCase( SECTION,
"array = new Array("+ old_len+"); array.length = " + set_len +
"; array.length",
new_len,
object.length );
if ( checkitems ) {
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 );
var passed = true;
for ( var i = new_len; i < old_len; i++ ) {
if ( object[i] != void 0 ) {
passed = false;
}
}
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 );
}
var passed = true;
for ( var i = old_len; i < new_len; i++ ) {
if ( object[i] != void 0 ) {
passed = false;
}
}
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 );
}

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

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

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,78 +35,60 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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)
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
15.6.1.2 Boolean() returns false
Author: christine@netscape.com
Date: 27 jun 1997
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 )
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()";
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);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
var array = new Array();
var item = 0;
test();
new TestCase( SECTION, "Boolean(1)", true, Boolean(1) );
new TestCase( SECTION, "Boolean(0)", false, Boolean(0) );
new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) );
new TestCase( SECTION, "Boolean('1')", true, Boolean("1") );
new TestCase( SECTION, "Boolean('0')", true, Boolean("0") );
new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") );
new TestCase( SECTION, "Boolean(true)", true, Boolean(true) );
new TestCase( SECTION, "Boolean(false)", false, Boolean(false) );
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION, "Boolean('true')", true, Boolean("true") );
new TestCase( SECTION, "Boolean('false')", true, Boolean("false") );
new TestCase( SECTION, "Boolean(null)", false, Boolean(null) );
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() );
new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) );
new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) );
new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) );
new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) );
new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) );
new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) );
new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) );
new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,142 +35,125 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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()
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).
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
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()";
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);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
var array = new Array();
var item = 0;
test();
new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) );
new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) );
new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) );
new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) );
new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor );
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()") );
new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() );
new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') );
new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor );
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()") );
new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() );
new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') );
new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor );
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()") );
new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() );
new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') );
new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() );
new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) );
new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) );
new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) );
new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) );
new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) );
new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor );
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()") );
new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() );
new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) );
new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor );
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()") );
new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() );
new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,54 +35,36 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.3.1-1.js
ECMA Section: 15.6.3 Boolean.prototype
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).
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 ].
The property shall have the attributes [DontEnum,
DontDelete, ReadOnly ].
This tests the DontEnum property of Boolean.prototype
This tests the DontEnum property of Boolean.prototype
Author: christine@netscape.com
Date: june 27, 1997
Author: christine@netscape.com
Date: june 27, 1997
*/
var SECTION = "15.6.3.1-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype";
var SECTION = "15.6.3.1-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
var array = new Array();
var item = 0;
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 );
}
new TestCase( SECTION,
"var str='';for ( p in Boolean ) { str += p } str;",
"",
eval("var str='';for ( p in Boolean ) { str += p } str;") );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,51 +35,35 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.3.1-2.js
ECMA Section: 15.6.3.1 Boolean.prototype
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).
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 ].
The property shall have the attributes [DontEnum,
DontDelete, ReadOnly ].
This tests the DontDelete property of Boolean.prototype
This tests the DontDelete property of Boolean.prototype
Author: christine@netscape.com
Date: june 27, 1997
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 SECTION = "15.6.3.1-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype"
writeHeaderToLog( SECTION + TITLE );
var testcases = getTestCases();
test();
var array = new Array();
var item = 0;
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"delete( Boolean.prototype)",
false,
delete( Boolean.prototype) );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,51 +35,35 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.3.1-3.js
ECMA Section: 15.6.3.1 Boolean.prototype
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).
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 ].
The property shall have the attributes [DontEnum,
DontDelete, ReadOnly ].
This tests the DontDelete property of Boolean.prototype
This tests the DontDelete property of Boolean.prototype
Author: christine@netscape.com
Date: june 27, 1997
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 SECTION = "15.6.3.1-3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype"
writeHeaderToLog( SECTION + TITLE );
var testcases = getTestCases();
test();
var array = new Array();
var item = 0;
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"delete( Boolean.prototype); Boolean.prototype",
Boolean.prototype,
eval("delete( Boolean.prototype); Boolean.prototype") );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,61 +35,39 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.3.1-4.js
ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object
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).
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 ].
The property shall have the attributes [DontEnum,
DontDelete, ReadOnly ].
This tests the ReadOnly property of Boolean.prototype
This tests the ReadOnly property of Boolean.prototype
Author: christine@netscape.com
Date: 30 september 1997
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 SECTION = "15.6.3.1-4";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype"
writeHeaderToLog( SECTION + TITLE );
var testcases = getTestCases();
test();
var BOOL_PROTO = Boolean.prototype;
function getTestCases() {
var array = new Array();
var item = 0;
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") );
var BOOL_PROTO = Boolean.prototype;
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") );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,43 +35,22 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
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"
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();
writeHeaderToLog( SECTION + " " + TITLE );
// all tests must call a function that returns an array of TestCase objects.
test();
new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,54 +35,33 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.3.1.js
ECMA Section: 15.6.3.1 Boolean.prototype
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).
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 ].
The property shall have the attributes [DontEnum,
DontDelete, ReadOnly ].
It has the internal [[Call]] and [[Construct]]
properties (not tested), and the length property.
It has the internal [[Call]] and [[Construct]]
properties (not tested), and the length property.
Author: christine@netscape.com
Date: june 27, 1997
Author: christine@netscape.com
Date: june 27, 1997
*/
var SECTION = "15.6.3.1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype";
var SECTION = "15.6.3.1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() );
new TestCase( SECTION, "Boolean.length", 1, Boolean.length );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,49 +35,29 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.3.js
ECMA Section: 15.6.3 Properties of the Boolean Constructor
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.
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.
It has the internal [[Call]] and [[Construct]]
properties, and the length property.
Author: christine@netscape.com
Date: june 27, 1997
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 SECTION = "15.6.3";
var VERSION = "ECMA_2";
startTest();
var TITLE = "Properties of the Boolean Constructor"
writeHeaderToLog( SECTION + TITLE );
var testcases = getTestCases();
test();
new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype );
new TestCase( SECTION, "Boolean.length", 1, Boolean.length );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,55 +35,36 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4-1.js
ECMA Section: 15.6.4 Properties of the Boolean Prototype Object
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.
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).
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
Author: christine@netscape.com
Date: 30 september 1997
*/
var VERSION = "ECMA_1"
startTest();
var SECTION = "15.6.4-1";
var VERSION = "ECMA_1"
startTest();
var SECTION = "15.6.4-1";
writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object");
var testcases = getTestCases();
test();
writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object");
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) );
new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) );
new TestCase( SECTION,
"Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()",
"[object Boolean]",
eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") );
new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,49 +35,30 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4-2.js
ECMA Section: 15.6.4 Properties of the Boolean Prototype Object
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.
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).
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
Author: christine@netscape.com
Date: 30 september 1997
*/
var VERSION = "ECMA_2"
startTest();
var SECTION = "15.6.4-2";
var VERSION = "ECMA_2"
startTest();
var SECTION = "15.6.4-2";
writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object");
var testcases = getTestCases();
test();
writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object");
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,47 +35,26 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.1.js
ECMA Section: 15.6.4.1 Boolean.prototype.constructor
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.
Description: The initial value of Boolean.prototype.constructor
is the built-in Boolean constructor.
Author: christine@netscape.com
Date: 30 september 1997
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 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 );
}
new TestCase( SECTION,
"( Boolean.prototype.constructor == Boolean )",
true ,
(Boolean.prototype.constructor == Boolean) );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,79 +35,61 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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.
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
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 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;
new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() );
new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() );
new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() );
new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() );
new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() );
new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() );
new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() );
new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() );
new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() );
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() );
new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() );
new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() );
new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() );
new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() );
new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() );
new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() );
new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() );
new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() );
new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() );
new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() );
new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() );
new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() );
new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).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() );
new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() );
new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).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() );
test();
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;
}
this.value = value;
this.valueOf = new Function( "return this.value" );
return this;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,61 +35,37 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.2-2.js
ECMA Section: 15.6.4.2 Boolean.prototype.toString()
Description: Returns this boolean value.
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.
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
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 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 );
}
new TestCase( SECTION,
"tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()",
"false",
eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") );
new TestCase( SECTION,
"tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()",
"true",
eval("tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()") );
new TestCase( SECTION,
"tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()",
"false",
eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,49 +35,29 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.2-3.js
ECMA Section: 15.6.4.2 Boolean.prototype.toString()
Description: Returns this boolean value.
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.
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
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 SECTION = "15.6.4.2-3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype.toString()"
writeHeaderToLog( SECTION + TITLE );
var testcases = getTestCases();
test();
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()") );
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()") );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,52 +35,33 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.2-4.js
ECMA Section: 15.6.4.2 Boolean.prototype.toString()
Description: Returns this boolean value.
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.
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
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 SECTION = "15.6.4.2-4-n";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype.toString()";
writeHeaderToLog( SECTION +" "+ TITLE );
var testcases = getTestCases();
test();
DESCRIPTION = "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()";
EXPECTED = "error";
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION,
"tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()",
"error",
eval("tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()") );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,73 +35,52 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.3.js
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
Description: Returns this boolean value.
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.
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
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()";
var SECTION = "15.6.4.3-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype.valueOf()";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() );
function getTestCases() {
var array = new Array();
var item = 0;
new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() );
new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() );
new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() );
new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() );
new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() );
new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() );
new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() );
new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() );
array[item++] = new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() );
new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() );
new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() );
new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() );
new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() );
new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() );
new TestCase( SECTION, "new Boolean()", false, (new Boolean()).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() );
new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() );
new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() );
new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() );
new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() );
new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() );
new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() );
new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,49 +35,31 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.3-2.js
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
Description: Returns this boolean value.
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.
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
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()";
var SECTION = "15.6.4.3-2";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype.valueOf()";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
function getTestCases() {
var array = new Array();
var item = 0;
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()") );
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()") );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,53 +35,30 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.3-3.js
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
Description: Returns this boolean value.
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.
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
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()";
var SECTION = "15.6.4.3-3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype.valueOf()";
writeHeaderToLog( SECTION + " "+ TITLE);
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 );
}
new TestCase( SECTION,
"x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()",
true,
eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()") );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,53 +35,33 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.3-4.js
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
Description: Returns this boolean value.
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.
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
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()";
var SECTION = "15.6.4.3-4-n";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Boolean.prototype.valueOf()";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
DESCRIPTION = "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()"
EXPECTED = "error";
test();
new TestCase( SECTION,
"valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()",
"error",
eval("valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()") );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,79 +35,47 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
File Name: 15.6.4.3.js
ECMA Section: 15.6.4.3 Boolean.prototype.valueOf()
Description: Returns this boolean value.
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.
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
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() );
new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).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() );
new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() );
new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() );
new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).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() );
new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() );
return ( array );
}
new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() );
new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() );
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 );
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,59 +35,44 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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).
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.
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
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";
var SECTION = "15.6.4";
var VERSION = "ECMA_1";
startTest();
var TITLE = "Properties of the Boolean Prototype Object";
writeHeaderToLog( SECTION + " "+ TITLE);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
new TestCase( SECTION,
"Boolean.prototype == false",
true,
Boolean.prototype == false );
testcases[tc++] = new TestCase( SECTION,
"Boolean.prototype == false",
true,
Boolean.prototype == false );
new TestCase( SECTION,
"Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()",
"[object Boolean]",
eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") );
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 );
}
test();

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

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

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,56 +35,32 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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)
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
- 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
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
//
@ -94,9 +71,23 @@ function test() {
// 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();
var FOUR_HUNDRED_YEARS = 1.26227808e+13;
var SECTION = "15.9.1.1-1";
writeHeaderToLog("15.8.1.1 Time Range");
var M_SECS;
var CURRENT_YEAR;
for ( M_SECS = 0, CURRENT_YEAR = 1970;
M_SECS < 8640000000000000;
M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) {
new TestCase( SECTION,
"new Date("+M_SECS+")",
CURRENT_YEAR,
(new Date( M_SECS)).getUTCFullYear() );
}
test();
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,64 +35,54 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
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() {
// 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
writeHeaderToLog("15.8.1.1 Time Range");
var FOUR_HUNDRED_YEARS = 1.26227808e+13;
var SECTION = "15.9.1.1-2";
for ( M_SECS = 0, CURRENT_YEAR = 1970;
M_SECS > -8640000000000000;
tc++, M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) {
writeHeaderToLog("15.8.1.1 Time Range");
testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS )).getUTCFullYear() );
var M_SECS;
var CURRENT_YEAR;
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description + " = " +
testcases[tc].actual );
for ( M_SECS = 0, CURRENT_YEAR = 1970;
M_SECS > -8640000000000000;
M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) {
if ( ! testcases[tc].passed ) {
testcases[tc].reason = "wrong year value";
}
}
new TestCase( SECTION,
"new Date("+M_SECS+")",
CURRENT_YEAR,
(new Date( M_SECS )).getUTCFullYear() );
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();
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,90 +35,68 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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;
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();
writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " +
"Date( year, month, date, hours, minutes, seconds, ms )" );
// all tests must call a function that returns an array of TestCase objects.
test();
var TODAY = new Date();
function getTestCases() {
var array = new Array();
var item = 0;
// Dates around 1970
var TODAY = new Date();
new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0,0) );
new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)", (new Date()).toString(), Date(1969,11,31,15,59,59,999));
new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0,0));
new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,0,1));
// Dates around 1970
// Dates around 2000
new TestCase( SECTION, "Date(1999,11,15,59,59,999)", (new Date()).toString(), Date(1999,11,15,59,59,999));
new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0,0));
new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)", (new Date()).toString(), Date(1999,11,31,23,59,59,999) );
new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0,0) );
new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,0,1) );
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 1900
// 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) );
new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)", (new Date()).toString(), Date(1899,11,31,23,59,59,999));
new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0,0) );
new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,0,1) );
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 1900
// Dates around feb 29, 2000
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));
new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0,0));
new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)", (new Date()).toString(), Date( 2000,1,28,23,59,59,999));
new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0,0));
// Dates around feb 29, 2000
// Dates around jan 1, 2005
new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)", (new Date()).toString(), Date(2004,11,31,23,59,59,999));
new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,0,1) );
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0,0));
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, 2032
new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)", (new Date()).toString(), Date(2031,11,31,23,59,59,999));
new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0,0) );
new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,0,1) );
new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,87 +35,66 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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().
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
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";
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();
writeHeaderToLog(SECTION+" "+TITLE );
// all tests must call a function that returns an array of TestCase objects.
test();
// Dates around 1970
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))
new TestCase( SECTION, "Date(1970,0,1,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0) );
new TestCase( SECTION, "Date(1969,11,31,15,59,59)", (new Date()).toString(), Date(1969,11,31,15,59,59));
new TestCase( SECTION, "Date(1969,11,31,16,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0));
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 2000
new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59));
new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0));
new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) );
new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) );
new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) );
// Dates around 1900
// 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));
new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59));
new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) );
new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) );
new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0));
// Dates around feb 29, 2000
// 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));
new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
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, 2005
new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
// 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));
// Dates around jan 1, 2032
new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,81 +35,60 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
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();
writeHeaderToLog(SECTION+" "+TITLE );
// 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 2000
new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59));
new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0));
new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) );
new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) );
new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) );
/*
// Dates around 1900
// 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));
new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59));
new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) );
new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) );
new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0));
// Dates around feb 29, 2000
// 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));
new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
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, 2005
new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
// 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));
// Dates around jan 1, 2032
new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,74 +35,53 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
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();
writeHeaderToLog(SECTION+" "+TITLE );
// all tests must call a function that returns an array of TestCase objects.
test();
// Dates around 1900
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));
new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59));
new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) );
new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) );
new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0));
/*
// Dates around feb 29, 2000
// 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));
new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
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, 2005
new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
// 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));
// Dates around jan 1, 2032
new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,67 +35,46 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
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();
writeHeaderToLog(SECTION+" "+TITLE );
// all tests must call a function that returns an array of TestCase objects.
test();
// Dates around feb 29, 2000
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));
new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0));
new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59));
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, 2005
new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
// 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));
// Dates around jan 1, 2032
new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,60 +35,39 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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().
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
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";
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();
writeHeaderToLog(SECTION+" "+TITLE );
// 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, 2005
new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59));
new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) );
new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) );
new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0));
/*
// 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));
// Dates around jan 1, 2032
new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
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 );
}
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,54 +35,31 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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
/**
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";
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();
writeHeaderToLog(SECTION+" "+TITLE );
// 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 );
}
// Dates around jan 1, 2032
new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59));
new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) );
new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) );
new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0));
test();

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -35,255 +36,234 @@
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 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);
writeHeaderToLog( SECTION + " "+ TITLE);
var TZ_ADJUST = TZ_PST * msPerHour;
var testcases = new Array();
// Dates around 1970
getTestCases();
test();
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] );
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
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] );
// Dates around 1970
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,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,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,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(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( 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,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,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,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,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,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,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,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,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,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] );
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] );
// Dates around 2000
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( 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(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] );
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] );
// Dates around 2000
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( 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( 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( 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( 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] );
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] );
// Dates around 29 Feb 2000
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] );
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
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] );
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] );
// Dates around 29 Feb 2000
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] );
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
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] );
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] );
// Dates around 1900
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(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(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] );
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] );
// Dates around 1900
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(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(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(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(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] );
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] );
// Dates around 2005
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] );
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
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] );
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] );
// 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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings test case
// Daylight Savings test case
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
var item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,213 +35,195 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 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);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
getTestCases();
test();
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
// Dates around 2000
// 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,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,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( 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,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] );
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
// Dates around 29 Feb 2000
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
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,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,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] );
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
// 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,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,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(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,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] );
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
// Dates around 2005
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
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(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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings test case
// Daylight Savings test case
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
var item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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;
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,191 +35,173 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 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);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
getTestCases();
test();
// Dates around 29 Feb 2000
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
// Dates around 29 Feb 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] );
var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay );
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,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] );
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
// 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,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,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(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,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] );
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
// Dates around 2005
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
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(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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings test case
// Daylight Savings test case
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
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() );
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
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() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
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;
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,175 +35,156 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 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);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
getTestCases();
test();
// Dates around 1900
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
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] );
// Dates around 1900
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,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,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(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(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(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] );
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
// Dates around 2005
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
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(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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings test case
// Daylight Savings test case
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
var item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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;
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,152 +35,134 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 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);
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = new Array();
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
getTestCases();
test();
// Dates around 2005
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = TZ_PST * msPerHour;
var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) +
TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004);
// Dates around 2005
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] );
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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings test case
// Daylight Savings test case
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
var item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,223 +35,203 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 )";
var SECTION = "15.9.3.1";
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
writeHeaderToLog( SECTION+" " +TITLE );
writeHeaderToLog( SECTION+" " +TITLE );
var testcases = new Array();
getTestCases();
// Dates around 1970
// all tests must call a function that returns an array of TestCase object
test();
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] );
function getTestCases( ) {
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 1970
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( 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( 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] );
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] );
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
// 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,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( 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] );
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
// 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,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(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,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] );
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;
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] );
// 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,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] );
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
// 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;
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(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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings Time
// Daylight Savings Time
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
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() );
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
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() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
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() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,201 +35,180 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 )";
var SECTION = "15.9.3.1";
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
writeHeaderToLog( SECTION+" " +TITLE );
writeHeaderToLog( SECTION+" " +TITLE );
var testcases = new Array();
getTestCases();
// Dates around 2000
// all tests must call a function that returns an array of TestCase object
test();
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] );
function getTestCases( ) {
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] );
// 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] );
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
// 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,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(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,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] );
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;
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] );
// 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,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] );
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
// 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;
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(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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings Time
// Daylight Savings Time
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,187 +35,166 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 )";
var SECTION = "15.9.3.1";
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
writeHeaderToLog( SECTION+" " +TITLE );
writeHeaderToLog( SECTION+" " +TITLE );
var testcases = new Array();
getTestCases();
// Dates around 1900
// all tests must call a function that returns an array of TestCase object
test();
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] );
function getTestCases( ) {
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] );
// Dates around 1900
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(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] );
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;
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] );
// 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,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] );
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
// 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;
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(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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings Time
// Daylight Savings Time
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,170 +35,148 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 )";
var SECTION = "15.9.3.1";
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
writeHeaderToLog( SECTION+" " +TITLE );
writeHeaderToLog( SECTION+" " +TITLE );
var testcases = new Array();
getTestCases();
var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28;
var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour;
// all tests must call a function that returns an array of TestCase object
test();
// 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] );
function getTestCases( ) {
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] );
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] );
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
// 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;
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(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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings Time
// Daylight Savings Time
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,152 +35,131 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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))).
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.
This tests the returned value of a newly constructed
Date object.
Author: christine@netscape.com
Date: 7 july 1997
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 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 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 )";
var SECTION = "15.9.3.1";
var TITLE = "Date( year, month, date, hours, minutes, seconds )";
writeHeaderToLog( SECTION+" " +TITLE );
writeHeaderToLog( SECTION+" " +TITLE );
var testcases = new Array();
getTestCases();
// Dates around Jan 1, 2005
// all tests must call a function that returns an array of TestCase object
test();
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;
function getTestCases( ) {
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] );
// 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] );
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.
This test case is incorrect. Need to fix the DaylightSavings functions in
shell.js for this to work properly.
// Daylight Savings Time
// Daylight Savings Time
var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour )
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,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]);
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 );
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,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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray);
item = testcases.length;
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
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() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
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;
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -35,281 +36,259 @@
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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 [[Class]] property of the newly constructed object is
set to "Date".
The [[Value]] property of the newly constructed object is
set as follows:
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.
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
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 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 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 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();
var tc= 0;
var TITLE = "Date constructor: new Date( value )";
var SECTION = "15.9.3.8";
var VERSION = "ECMA_1";
startTest();
writeHeaderToLog( SECTION +" " + TITLE );
writeHeaderToLog( SECTION +" " + TITLE );
testcases = new Array();
getTestCases();
// all tests must call a function that returns a boolean value
test();
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = -TZ_PST * msPerHour;
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = -TZ_PST * 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] );
// 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(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(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(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)).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(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((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( 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)).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] );
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
// 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+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(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+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)).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+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] );
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
// 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;
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(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(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(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(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(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] );
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
// Dates around 1900
var PST_1900 = TIME_1900 + 8*msPerHour;
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( 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(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(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(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(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(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.
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 )
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-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]);
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 );
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-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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray, 'msMode');
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray, 'msMode');
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 );
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -35,256 +36,233 @@
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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 [[Class]] property of the newly constructed object is
set to "Date".
The [[Value]] property of the newly constructed object is
set as follows:
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.
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
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 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 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 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();
var tc= 0;
var TITLE = "Date constructor: new Date( value )";
var SECTION = "15.9.3.8";
var VERSION = "ECMA_1";
startTest();
writeHeaderToLog( SECTION +" " + TITLE );
writeHeaderToLog( SECTION +" " + TITLE );
testcases = new Array();
getTestCases();
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = -TZ_PST * msPerHour;
// all tests must call a function that returns a boolean value
test();
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] );
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = -TZ_PST * msPerHour;
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((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( 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(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)).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] );
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
// 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+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(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+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)).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+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] );
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
// 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;
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(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(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(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(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(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] );
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
// Dates around 1900
var PST_1900 = TIME_1900 + 8*msPerHour;
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( 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(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(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(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(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(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.
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 )
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-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]);
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 );
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-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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray, 'msMode');
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray, 'msMode');
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 );
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
}

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

@ -1,3 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -34,235 +35,213 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
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.
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 [[Class]] property of the newly constructed object is
set to "Date".
The [[Value]] property of the newly constructed object is
set as follows:
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.
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
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 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 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 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();
var tc= 0;
var TITLE = "Date constructor: new Date( value )";
var SECTION = "15.9.3.8";
var VERSION = "ECMA_1";
startTest();
writeHeaderToLog( SECTION +" " + TITLE );
writeHeaderToLog( SECTION +" " + TITLE );
testcases = new Array();
getTestCases();
// all tests must call a function that returns a boolean value
test();
function getTestCases( ) {
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = -TZ_PST * msPerHour;
// all the "ResultArrays" below are hard-coded to Pacific Standard Time values -
var TZ_ADJUST = -TZ_PST * msPerHour;
// Dates around 2000
// 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+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(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+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)).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+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] );
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
// 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;
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(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(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(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(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(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] );
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
// Dates around 1900
var PST_1900 = TIME_1900 + 8*msPerHour;
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( 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(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(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(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(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(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.
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 )
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-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]);
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 );
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-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] );
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] );
*/
}
test();
function addNewTestCase( DateCase, DateString, ResultArray ) {
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray, 'msMode');
//adjust hard-coded ResultArray for tester's timezone instead of PST
adjustResultArray(ResultArray, 'msMode');
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 );
new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() );
new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() );
new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() );
new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() );
new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() );
new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() );
new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() );
new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() );
new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() );
new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() );
new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() );
new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() );
new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() );
new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() );
new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() );
new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() );
new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() );
new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() );
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше