зеркало из https://github.com/mozilla/gecko-dev.git
Initial add. Testcase for the internal [[Class]] property of Objects.
This commit is contained in:
Родитель
1260fc471b
Коммит
c728cf55e2
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* 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 expressed
|
||||
* 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): pschwartau@netscape.com
|
||||
* Date: 14 Mar 2001
|
||||
*
|
||||
* SUMMARY: Testing the internal [[Class]] property of objects
|
||||
* See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2
|
||||
*
|
||||
* The getClass() function we use is in a utility file, e.g. "shell.js".
|
||||
*/
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
var i = 0;
|
||||
var UBound = 0;
|
||||
var bug = '(none)';
|
||||
var summary = 'Testing the internal [[Class]] property of objects';
|
||||
var statprefix = 'Current object is: ';
|
||||
var status = ''; var statusList = [ ];
|
||||
var actual = ''; var actualvalue = [ ];
|
||||
var expect= ''; var expectedvalue = [ ];
|
||||
|
||||
|
||||
status = 'the global object';
|
||||
actual = getClass(this);
|
||||
expect = 'global';
|
||||
addThis();
|
||||
|
||||
status = 'new Object()';
|
||||
actual = getClass(new Object());
|
||||
expect = 'Object';
|
||||
addThis();
|
||||
|
||||
status = 'new Function()';
|
||||
actual = getClass(new Function());
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'new Array()';
|
||||
actual = getClass(new Array());
|
||||
expect = 'Array';
|
||||
addThis();
|
||||
|
||||
status = 'new String()';
|
||||
actual = getClass(new String());
|
||||
expect = 'String';
|
||||
addThis();
|
||||
|
||||
status = 'new Boolean()';
|
||||
actual = getClass(new Boolean());
|
||||
expect = 'Boolean';
|
||||
addThis();
|
||||
|
||||
status = 'new Number()';
|
||||
actual = getClass(new Number());
|
||||
expect = 'Number';
|
||||
addThis();
|
||||
|
||||
status = 'Math';
|
||||
actual = getClass(Math); // can't use 'new' with the Math object (EMCA3, 15.8)
|
||||
expect = 'Math';
|
||||
addThis();
|
||||
|
||||
status = 'new Date()';
|
||||
actual = getClass(new Date());
|
||||
expect = 'Date';
|
||||
addThis();
|
||||
|
||||
status = 'new RegExp()';
|
||||
actual = getClass(new RegExp());
|
||||
expect = 'RegExp';
|
||||
addThis();
|
||||
|
||||
status = 'new Error()';
|
||||
actual = getClass(new Error());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
test();
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
function addThis()
|
||||
{
|
||||
statusList[UBound] = status;
|
||||
actualvalue[UBound] = actual;
|
||||
expectedvalue[UBound] = expect;
|
||||
UBound++;
|
||||
}
|
||||
|
||||
|
||||
function test()
|
||||
{
|
||||
enterFunc ('test');
|
||||
printBugNumber (bug);
|
||||
printStatus (summary);
|
||||
|
||||
for (i = 0; i < UBound; i++)
|
||||
{
|
||||
reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
|
||||
}
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
||||
|
||||
function getStatus(i)
|
||||
{
|
||||
return statprefix + statusList[i];
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* 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 expressed
|
||||
* 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): pschwartau@netscape.com
|
||||
* Date: 14 Mar 2001
|
||||
*
|
||||
* SUMMARY: Testing the [[Class]] property of native constructors.
|
||||
* See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property.
|
||||
*
|
||||
* Same as class-001.js - but testing the constructors here, not object instances.
|
||||
* Therefore we expect the [[Class]] property to equal 'Function' in each case.
|
||||
*
|
||||
* The getClass() function we use is in a utility file, e.g. "shell.js"
|
||||
*/
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
var i = 0;
|
||||
var UBound = 0;
|
||||
var bug = '(none)';
|
||||
var summary = 'Testing the internal [[Class]] property of native constructors';
|
||||
var statprefix = 'Current constructor is: ';
|
||||
var status = ''; var statusList = [ ];
|
||||
var actual = ''; var actualvalue = [ ];
|
||||
var expect= ''; var expectedvalue = [ ];
|
||||
|
||||
/*
|
||||
* We set the expect variable each time only for readability.
|
||||
* We expect 'Function' every time; see discussion above -
|
||||
*/
|
||||
status = 'Object';
|
||||
actual = getClass(Object);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'Function';
|
||||
actual = getClass(Function);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'Array';
|
||||
actual = getClass(Array);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'String';
|
||||
actual = getClass(String);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'Boolean';
|
||||
actual = getClass(Boolean);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'Number';
|
||||
actual = getClass(Number);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'Date';
|
||||
actual = getClass(Date);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'RegExp';
|
||||
actual = getClass(RegExp);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'Error';
|
||||
actual = getClass(Error);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
test();
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
function addThis()
|
||||
{
|
||||
statusList[UBound] = status;
|
||||
actualvalue[UBound] = actual;
|
||||
expectedvalue[UBound] = expect;
|
||||
UBound++;
|
||||
}
|
||||
|
||||
|
||||
function test()
|
||||
{
|
||||
enterFunc ('test');
|
||||
printBugNumber (bug);
|
||||
printStatus (summary);
|
||||
|
||||
for (i = 0; i < UBound; i++)
|
||||
{
|
||||
reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
|
||||
}
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
||||
|
||||
function getStatus(i)
|
||||
{
|
||||
return statprefix + statusList[i];
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* 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 expressed
|
||||
* 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): pschwartau@netscape.com
|
||||
* Date: 14 Mar 2001
|
||||
*
|
||||
* SUMMARY: Testing the [[Class]] property of native error types.
|
||||
* See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property.
|
||||
*
|
||||
* Same as class-001.js - but testing only the native error types here.
|
||||
* See ECMA-262 Edition 3, Section 15.11.6 for a list of these types.
|
||||
*
|
||||
* ECMA expects the [[Class]] property to equal 'Error' in each case.
|
||||
* See ECMA-262 Edition 3, Sections 15.11.1.1 and 15.11.7.2 for this.
|
||||
* See http://bugzilla.mozilla.org/show_bug.cgi?id=56868
|
||||
*
|
||||
* The getClass() function we use is in a utility file, e.g. "shell.js"
|
||||
*/
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
var i = 0;
|
||||
var UBound = 0;
|
||||
var bug = 56868;
|
||||
var summary = 'Testing the internal [[Class]] property of native error types';
|
||||
var statprefix = 'Current object is: ';
|
||||
var status = ''; var statusList = [ ];
|
||||
var actual = ''; var actualvalue = [ ];
|
||||
var expect= ''; var expectedvalue = [ ];
|
||||
|
||||
/*
|
||||
* We set the expect variable each time only for readability.
|
||||
* We expect 'Error' every time; see discussion above -
|
||||
*/
|
||||
status = 'new Error()';
|
||||
actual = getClass(new Error());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
status = 'new EvalError()';
|
||||
actual = getClass(new EvalError());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
status = 'new RangeError()';
|
||||
actual = getClass(new RangeError());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
status = 'new ReferenceError()';
|
||||
actual = getClass(new ReferenceError());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
status = 'new SyntaxError()';
|
||||
actual = getClass(new SyntaxError());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
status = 'new TypeError()';
|
||||
actual = getClass(new TypeError());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
status = 'new URIError()';
|
||||
actual = getClass(new URIError());
|
||||
expect = 'Error';
|
||||
addThis();
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
test();
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
function addThis()
|
||||
{
|
||||
statusList[UBound] = status;
|
||||
actualvalue[UBound] = actual;
|
||||
expectedvalue[UBound] = expect;
|
||||
UBound++;
|
||||
}
|
||||
|
||||
|
||||
function test()
|
||||
{
|
||||
enterFunc ('test');
|
||||
printBugNumber (bug);
|
||||
printStatus (summary);
|
||||
|
||||
for (i = 0; i < UBound; i++)
|
||||
{
|
||||
reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
|
||||
}
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
||||
|
||||
function getStatus(i)
|
||||
{
|
||||
return statprefix + statusList[i];
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* 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 expressed
|
||||
* 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): pschwartau@netscape.com
|
||||
* Date: 14 Mar 2001
|
||||
*
|
||||
* SUMMARY: Testing [[Class]] property of native error constructors.
|
||||
* See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property.
|
||||
*
|
||||
* See ECMA-262 Edition 3, Section 15.11.6 for the native error types.
|
||||
* See http://bugzilla.mozilla.org/show_bug.cgi?id=56868
|
||||
*
|
||||
* Same as class-003.js - but testing the constructors here, not object instances.
|
||||
* Therefore we expect the [[Class]] property to equal 'Function' in each case.
|
||||
*
|
||||
* The getClass() function we use is in a utility file, e.g. "shell.js"
|
||||
*/
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
var i = 0;
|
||||
var UBound = 0;
|
||||
var bug = 56868;
|
||||
var summary = 'Testing the internal [[Class]] property of native error constructors';
|
||||
var statprefix = 'Current constructor is: ';
|
||||
var status = ''; var statusList = [ ];
|
||||
var actual = ''; var actualvalue = [ ];
|
||||
var expect= ''; var expectedvalue = [ ];
|
||||
|
||||
/*
|
||||
* We set the expect variable each time only for readability.
|
||||
* We expect 'Function' every time; see discussion above -
|
||||
*/
|
||||
status = 'Error';
|
||||
actual = getClass(Error);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'EvalError';
|
||||
actual = getClass(EvalError);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'RangeError';
|
||||
actual = getClass(RangeError);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'ReferenceError';
|
||||
actual = getClass(ReferenceError);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'SyntaxError';
|
||||
actual = getClass(SyntaxError);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'TypeError';
|
||||
actual = getClass(TypeError);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
status = 'URIError';
|
||||
actual = getClass(URIError);
|
||||
expect = 'Function';
|
||||
addThis();
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
test();
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
function addThis()
|
||||
{
|
||||
statusList[UBound] = status;
|
||||
actualvalue[UBound] = actual;
|
||||
expectedvalue[UBound] = expect;
|
||||
UBound++;
|
||||
}
|
||||
|
||||
|
||||
function test()
|
||||
{
|
||||
enterFunc ('test');
|
||||
printBugNumber (bug);
|
||||
printStatus (summary);
|
||||
|
||||
for (i = 0; i < UBound; i++)
|
||||
{
|
||||
reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
|
||||
}
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
||||
|
||||
function getStatus(i)
|
||||
{
|
||||
return statprefix + statusList[i];
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* 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 expressed
|
||||
* 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): pschwartau@netscape.com
|
||||
* Date: 14 Mar 2001
|
||||
*
|
||||
* SUMMARY: Testing the internal [[Class]] property of user-defined types.
|
||||
* See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property.
|
||||
*
|
||||
* Same as class-001.js - but testing user-defined types here, not native types.
|
||||
* Therefore we expect the [[Class]] property to equal 'Object' in each case -
|
||||
*
|
||||
* The getClass() function we use is in a utility file, e.g. "shell.js"
|
||||
*/
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
var i = 0;
|
||||
var UBound = 0;
|
||||
var bug = '(none)';
|
||||
var summary = 'Testing the internal [[Class]] property of user-defined types';
|
||||
var statprefix = 'Current user-defined type is: ';
|
||||
var status = ''; var statusList = [ ];
|
||||
var actual = ''; var actualvalue = [ ];
|
||||
var expect= ''; var expectedvalue = [ ];
|
||||
|
||||
|
||||
Calf.prototype= new Cow();
|
||||
|
||||
/*
|
||||
* We set the expect variable each time only for readability.
|
||||
* We expect 'Object' every time; see discussion above -
|
||||
*/
|
||||
status = 'new Cow()';
|
||||
actual = getClass(new Cow());
|
||||
expect = 'Object';
|
||||
addThis();
|
||||
|
||||
status = 'new Calf()';
|
||||
actual = getClass(new Calf());
|
||||
expect = 'Object';
|
||||
addThis();
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
test();
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function addThis()
|
||||
{
|
||||
statusList[UBound] = status;
|
||||
actualvalue[UBound] = actual;
|
||||
expectedvalue[UBound] = expect;
|
||||
UBound++;
|
||||
}
|
||||
|
||||
|
||||
function test()
|
||||
{
|
||||
enterFunc ('test');
|
||||
printBugNumber (bug);
|
||||
printStatus (summary);
|
||||
|
||||
for (i = 0; i < UBound; i++)
|
||||
{
|
||||
reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
|
||||
}
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
||||
|
||||
function getStatus(i)
|
||||
{
|
||||
return statprefix + statusList[i];
|
||||
}
|
||||
|
||||
|
||||
function Cow(name)
|
||||
{
|
||||
this.name=name;
|
||||
}
|
||||
|
||||
|
||||
function Calf(name)
|
||||
{
|
||||
this.name=name;
|
||||
}
|
Загрузка…
Ссылка в новой задаче