Home | History | Annotate | Download | only in String
      1 /* The contents of this file are subject to the Netscape Public
      2  * License Version 1.1 (the "License"); you may not use this file
      3  * except in compliance with the License. You may obtain a copy of
      4  * the License at http://www.mozilla.org/NPL/
      5  *
      6  * Software distributed under the License is distributed on an "AS
      7  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
      8  * implied. See the License for the specific language governing
      9  * rights and limitations under the License.
     10  *
     11  * The Original Code is Mozilla Communicator client code, released March
     12  * 31, 1998.
     13  *
     14  * The Initial Developer of the Original Code is Netscape Communications
     15  * Corporation. Portions created by Netscape are
     16  * Copyright (C) 1998 Netscape Communications Corporation. All
     17  * Rights Reserved.
     18  *
     19  * Contributor(s):
     20  *
     21  */
     22 /**
     23     File Name:          15.5.3.2-2.js
     24     ECMA Section:       15.5.3.2  String.fromCharCode( char0, char1, ... )
     25     Description:        Return a string value containing as many characters
     26                         as the number of arguments.  Each argument specifies
     27                         one character of the resulting string, with the first
     28                         argument specifying the first character, and so on,
     29                         from left to right.  An argument is converted to a
     30                         character by applying the operation ToUint16 and
     31                         regarding the resulting 16bit integeras the Unicode
     32                         encoding of a character.  If no arguments are supplied,
     33                         the result is the empty string.
     34 
     35                         This tests String.fromCharCode with multiple arguments.
     36 
     37     Author:             christine (at) netscape.com
     38     Date:               2 october 1997
     39 */
     40 
     41     var SECTION = "15.5.3.2-2";
     42     var VERSION = "ECMA_1";
     43     startTest();
     44     var TITLE   = "String.fromCharCode()";
     45 
     46     writeHeaderToLog( SECTION + " "+ TITLE);
     47 
     48     var testcases = getTestCases();
     49     test();
     50 
     51 
     52 function getTestCases() {
     53     var array = new Array();
     54     var item = 0;
     55 
     56     array[item++] = new TestCase( SECTION,
     57                                   "var MYSTRING = String.fromCharCode(eval(\"var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;\")); MYSTRING",
     58                                   " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
     59                                   eval( "var MYSTRING = String.fromCharCode(" + eval("var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;") +"); MYSTRING" ));
     60 
     61     array[item++] = new TestCase( SECTION,
     62                                     "MYSTRING.length",
     63                                     0x007f - 0x0020,
     64                                     MYSTRING.length );
     65      return array;
     66 }
     67 
     68 function test() {
     69     for ( tc=0; tc < testcases.length; tc++ ) {
     70         testcases[tc].passed = writeTestCaseResult(
     71                             testcases[tc].expect,
     72                             testcases[tc].actual,
     73                             testcases[tc].description +" = "+
     74                             testcases[tc].actual );
     75 
     76         testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
     77     }
     78     stopTest();
     79     return ( testcases );
     80 }
     81