1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/String/15.5.4.5-1.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.5.4.5.1.js 1.12 + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) 1.13 + Description: Returns a number (a nonnegative integer less than 2^16) 1.14 + representing the Unicode encoding of the character at 1.15 + position pos in this string. If there is no character 1.16 + at that position, the number is NaN. 1.17 + 1.18 + When the charCodeAt method is called with one argument 1.19 + pos, the following steps are taken: 1.20 + 1. Call ToString, giving it the theis value as its 1.21 + argument 1.22 + 2. Call ToInteger(pos) 1.23 + 3. Compute the number of characters in result(1). 1.24 + 4. If Result(2) is less than 0 or is not less than 1.25 + Result(3), return NaN. 1.26 + 5. Return a value of Number type, of positive sign, whose 1.27 + magnitude is the Unicode encoding of one character 1.28 + from result 1, namely the characer at position Result 1.29 + (2), where the first character in Result(1) is 1.30 + considered to be at position 0. 1.31 + 1.32 + Note that the charCodeAt function is intentionally 1.33 + generic; it does not require that its this value be a 1.34 + String object. Therefore it can be transferred to other 1.35 + kinds of objects for use as a method. 1.36 + 1.37 + Author: christine@netscape.com 1.38 + Date: 2 october 1997 1.39 +*/ 1.40 +var SECTION = "15.5.4.5-1"; 1.41 +var VERSION = "ECMA_1"; 1.42 +startTest(); 1.43 +var TITLE = "String.prototype.charCodeAt"; 1.44 + 1.45 +writeHeaderToLog( SECTION + " "+ TITLE); 1.46 + 1.47 +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); 1.48 + 1.49 +for ( j = 0, i = 0x0020; i < 0x007e; i++, j++ ) { 1.50 + new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", i, TEST_STRING.charCodeAt( j ) ); 1.51 +} 1.52 + 1.53 +new TestCase( SECTION, 'TEST_STRING.charCodeAt('+i+')', NaN, TEST_STRING.charCodeAt( i ) ); 1.54 + 1.55 + 1.56 +test();