var SECTION = "15.3.1.1-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "The Function Constructor Called as a Function";
writeHeaderToLog( SECTION + " "+ TITLE);
var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" );
var testcases = getTestCases();
test();
function getTestCases() {
var array = new Array();
var item = 0;
var myfunc = Function();
myfunc.toString = Object.prototype.toString;
myfunc.toString = Object.prototype.toString;
array[item++] = new TestCase( SECTION,
"myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()",
"[object Function]",
myfunc.toString() );
array[item++] = new TestCase( SECTION, "myfunc.length", 0, myfunc.length );
array[item++] = new TestCase( SECTION, "myfunc.prototype.toString()", "[object Object]", myfunc.prototype.toString() );
array[item++] = new TestCase( SECTION, "myfunc.prototype.constructor", myfunc, myfunc.prototype.constructor );
array[item++] = new TestCase( SECTION, "myfunc.arguments", null, myfunc.arguments );
array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") );
array[item++] = new TestCase( SECTION, "OBJ.toString()", "true", OBJ.toString() );
array[item++] = new TestCase( SECTION, "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") );
array[item++] = new TestCase( SECTION, "MyObject.toString = Object.prototype.toString; MyObject.toString()", "[object Function]", eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") );
array[item++] = new TestCase( SECTION, "MyObject.__proto__ == Function.prototype", true, MyObject.__proto__ == Function.prototype );
array[item++] = new TestCase( SECTION, "MyObject.length", 1, MyObject.length );
array[item++] = new TestCase( SECTION, "MyObject.prototype.constructor", MyObject, MyObject.prototype.constructor );
array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments );
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 );
}