Home | History | Annotate | Download | only in Array
      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.4-1.js
     24     ECMA Section:       15.4 Array Objects
     25 
     26     Description:        Every Array object has a length property whose value
     27                         is always an integer with positive sign and less than
     28                         Math.pow(2,32).
     29 
     30     Author:             christine (at) netscape.com
     31     Date:               28 october 1997
     32 
     33 */
     34     var SECTION = "15.4-1";
     35     var VERSION = "ECMA_1";
     36     startTest();
     37     var TITLE   = "Array Objects";
     38 
     39     writeHeaderToLog( SECTION + " "+ TITLE);
     40 
     41     var testcases = getTestCases();
     42     test();
     43 
     44 function getTestCases() {
     45     var array = new Array();
     46     var item = 0;
     47 
     48     array[item++] = new TestCase(   SECTION,
     49                                     "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]",
     50                                     "hi",
     51                                     eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]")
     52                                 );
     53     array[item++] = new TestCase(   SECTION,
     54                                     "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length",
     55                                     (Math.pow(2,32)-1),
     56                                     eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length")
     57                                 );
     58     array[item++] = new TestCase(   SECTION,
     59                                     "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]",
     60                                     "hi",
     61                                     eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]")
     62                                 );
     63     array[item++] = new TestCase(   SECTION,
     64                                     "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length",
     65                                     (Math.pow(2,32)-2),
     66                                     eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length")
     67                                 );
     68 
     69     array[item++] = new TestCase(   SECTION,
     70                                     "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]",
     71                                     "hi",
     72                                     eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]")
     73                                 );
     74     array[item++] = new TestCase(   SECTION,
     75                                     "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length",
     76                                     (Math.pow(2,31)-1),
     77                                     eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length")
     78                                 );
     79 
     80     array[item++] = new TestCase(   SECTION,
     81                                     "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]",
     82                                     "hi",
     83                                     eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]")
     84                                 );
     85     array[item++] = new TestCase(   SECTION,
     86                                     "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length",
     87                                     (Math.pow(2,31)),
     88                                     eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length")
     89                                 );
     90 
     91 
     92     array[item++] = new TestCase(   SECTION,
     93                                     "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]",
     94                                     "hi",
     95                                     eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]")
     96                                 );
     97     array[item++] = new TestCase(   SECTION,
     98                                     "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length",
     99                                     (Math.pow(2,31)+1),
    100                                     eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length")
    101                                 );
    102 
    103     array[item++] = new TestCase(   SECTION,
    104                                     "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]",
    105                                     "hi",
    106                                     eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]")
    107                                 );
    108     array[item++] = new TestCase(   SECTION,
    109                                     "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length",
    110                                     (Math.pow(2,30)-1),
    111                                     eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length")
    112                                 );
    113     return ( array );
    114 }
    115 function test() {
    116     for ( tc=0; tc < testcases.length; tc++ ) {
    117         testcases[tc].passed = writeTestCaseResult(
    118                             testcases[tc].expect,
    119                             testcases[tc].actual,
    120                             testcases[tc].description +" = "+ testcases[tc].actual );
    121 
    122         testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
    123     }
    124     stopTest();
    125     return ( testcases );
    126 }
    127