Debian Codegraph @

rhino/testsrc/tests/ecma/String/15.5.4.4-1.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = '15.5.4.4-1.js';
7
8 /**
9 File Name: 15.5.4.4-1.js
10 ECMA Section: 15.5.4.4 String.prototype.charAt(pos)
11 Description: Returns a string containing the character at position
12 pos in the string. If there is no character at that
13 string, the result is the empty string. The result is
14 a string value, not a String object.
15
16 When the charAt method is called with one argument,
17 pos, the following steps are taken:
18 1. Call ToString, with this value as its argument
19 2. Call ToInteger pos
20
21 In this test, this is a String, pos is an integer, and
22 all pos are in range.
23
24 Author: [email protected]
25 Date: 2 october 1997
26 */
27 var SECTION = "15.5.4.4-1";
28 var VERSION = "ECMA_1";
29 startTest();
30 var TITLE = "String.prototype.charAt";
31
32 writeHeaderToLog( SECTION + " "+ TITLE);
33
34 var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" );
35
36 var item = 0;
37 var i;
38
39 for ( i = 0x0020; i < 0x007e; i++, item++) {
40 new TestCase( SECTION,
41 "TEST_STRING.charAt("+item+")",
42 String.fromCharCode( i ),
43 TEST_STRING.charAt( item ) );
44 }
45
46 for ( i = 0x0020; i < 0x007e; i++, item++) {
47 new TestCase( SECTION,
48 "TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")",
49 true,
50 TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 )
51 );
52 }
53
54 new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length );
55
56 print( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" );
57
58 test();
59