js/src/tests/ecma/Array/15.4.2.1-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Array/15.4.2.1-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     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.4.2.1-1.js
    1.12 +   ECMA Section:       15.4.2.1 new Array( item0, item1, ... )
    1.13 +   Description:        This description only applies of the constructor is
    1.14 +   given two or more arguments.
    1.15 +
    1.16 +   The [[Prototype]] property of the newly constructed
    1.17 +   object is set to the original Array prototype object,
    1.18 +   the one that is the initial value of Array.prototype
    1.19 +   (15.4.3.1).
    1.20 +
    1.21 +   The [[Class]] property of the newly constructed object
    1.22 +   is set to "Array".
    1.23 +
    1.24 +   The length property of the newly constructed object is
    1.25 +   set to the number of arguments.
    1.26 +
    1.27 +   The 0 property of the newly constructed object is set
    1.28 +   to item0... in general, for as many arguments as there
    1.29 +   are, the k property of the newly constructed object is
    1.30 +   set to argument k, where the first argument is
    1.31 +   considered to be argument number 0.
    1.32 +
    1.33 +   This file tests the typeof the newly constructed object.
    1.34 +
    1.35 +   Author:             christine@netscape.com
    1.36 +   Date:               7 october 1997
    1.37 +*/
    1.38 +
    1.39 +var SECTION = "15.4.2.1-1";
    1.40 +var VERSION = "ECMA_1";
    1.41 +startTest();
    1.42 +var TITLE   = "The Array Constructor:  new Array( item0, item1, ...)";
    1.43 +
    1.44 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.45 +
    1.46 +new TestCase( SECTION,
    1.47 +	      "typeof new Array(1,2)",       
    1.48 +	      "object",          
    1.49 +	      typeof new Array(1,2) );
    1.50 +
    1.51 +new TestCase( SECTION,
    1.52 +	      "(new Array(1,2)).toString",   
    1.53 +	      Array.prototype.toString,   
    1.54 +	      (new Array(1,2)).toString );
    1.55 +
    1.56 +new TestCase( SECTION,
    1.57 +	      "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
    1.58 +	      "[object Array]",
    1.59 +	      eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
    1.60 +
    1.61 +new TestCase( SECTION,
    1.62 +	      "(new Array(1,2)).length",     
    1.63 +	      2,                 
    1.64 +	      (new Array(1,2)).length );
    1.65 +
    1.66 +new TestCase( SECTION,
    1.67 +	      "var arr = (new Array(1,2)); arr[0]", 
    1.68 +	      1,          
    1.69 +	      eval("var arr = (new Array(1,2)); arr[0]") );
    1.70 +
    1.71 +new TestCase( SECTION,
    1.72 +	      "var arr = (new Array(1,2)); arr[1]", 
    1.73 +	      2,          
    1.74 +	      eval("var arr = (new Array(1,2)); arr[1]") );
    1.75 +
    1.76 +new TestCase( SECTION,
    1.77 +	      "var arr = (new Array(1,2)); String(arr)", 
    1.78 +	      "1,2", 
    1.79 +	      eval("var arr = (new Array(1,2)); String(arr)") );
    1.80 +
    1.81 +test();

mercurial