michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 15.5.4.4-1.js michael@0: ECMA Section: 15.5.4.4 String.prototype.charAt(pos) michael@0: Description: Returns a string containing the character at position michael@0: pos in the string. If there is no character at that michael@0: string, the result is the empty string. The result is michael@0: a string value, not a String object. michael@0: michael@0: When the charAt method is called with one argument, michael@0: pos, the following steps are taken: michael@0: 1. Call ToString, with this value as its argument michael@0: 2. Call ToInteger pos michael@0: michael@0: In this test, this is a String, pos is an integer, and michael@0: all pos are in range. michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 2 october 1997 michael@0: */ michael@0: var SECTION = "15.5.4.4-1"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "String.prototype.charAt"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); michael@0: michael@0: var item = 0; michael@0: var i; michael@0: michael@0: for ( i = 0x0020; i < 0x007e; i++, item++) { michael@0: new TestCase( SECTION, michael@0: "TEST_STRING.charAt("+item+")", michael@0: String.fromCharCode( i ), michael@0: TEST_STRING.charAt( item ) ); michael@0: } michael@0: michael@0: for ( i = 0x0020; i < 0x007e; i++, item++) { michael@0: new TestCase( SECTION, michael@0: "TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")", michael@0: true, michael@0: TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 ) michael@0: ); michael@0: } michael@0: michael@0: new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length ); michael@0: michael@0: print( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); michael@0: michael@0: test(); michael@0: