var SECTION = "15.5.4.4-3";
var VERSION = "ECMA_1";
startTest();
var TITLE = "String.prototype.charAt";
writeHeaderToLog( SECTION + " "+ TITLE);
var testcases = getTestCases();
test();
function MyObject (v) {
this.value = v;
this.toString = new Function( "return this.value +'';" );
this.valueOf = new Function( "return this.value" );
this.charAt = String.prototype.charAt;
}
function getTestCases() {
var array = new Array();
var item = 0;
var foo = new MyObject('hello');
array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "h", foo.charAt(0) );
array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "e", foo.charAt(1) );
array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(2) );
array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(3) );
array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "o", foo.charAt(4) );
array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(-1) );
array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(5) );
var boo = new MyObject(true);
array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "t", boo.charAt(0) );
array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "r", boo.charAt(1) );
array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "u", boo.charAt(2) );
array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "e", boo.charAt(3) );
var noo = new MyObject( Math.PI );
array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "3", noo.charAt(0) );
array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", ".", noo.charAt(1) );
array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(2) );
array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "4", noo.charAt(3) );
array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(4) );
array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "5", noo.charAt(5) );
array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "9", noo.charAt(6) );
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 );
}