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