js/src/tests/ecma/Array/15.4.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.1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,98 @@
     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.1.js
    1.12 +   ECMA Section:       15.4.1 The Array Constructor Called as a Function
    1.13 +
    1.14 +   Description:        When Array is called as a function rather than as a
    1.15 +   constructor, it creates and initializes a new array
    1.16 +   object.  Thus, the function call Array(...) is
    1.17 +   equivalent to the object creationi new Array(...) with
    1.18 +   the same arguments.
    1.19 +
    1.20 +   Author:             christine@netscape.com
    1.21 +   Date:               7 october 1997
    1.22 +*/
    1.23 +
    1.24 +var SECTION = "15.4.1";
    1.25 +var VERSION = "ECMA_1";
    1.26 +startTest();
    1.27 +var TITLE   = "The Array Constructor Called as a Function";
    1.28 +
    1.29 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.30 +
    1.31 +new TestCase(   SECTION,
    1.32 +		"Array() +''",
    1.33 +		"",
    1.34 +		Array() +"" );
    1.35 +
    1.36 +new TestCase(   SECTION,
    1.37 +		"typeof Array()",
    1.38 +		"object",
    1.39 +		typeof Array() );
    1.40 +
    1.41 +new TestCase(   SECTION,
    1.42 +		"var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
    1.43 +		"[object Array]",
    1.44 +		eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
    1.45 +
    1.46 +new TestCase(   SECTION,
    1.47 +		"var arr = Array(); arr.toString == Array.prototype.toString",
    1.48 +		true,
    1.49 +		eval("var arr = Array(); arr.toString == Array.prototype.toString") );
    1.50 +
    1.51 +new TestCase(   SECTION,
    1.52 +		"Array().length",
    1.53 +		0,
    1.54 +		Array().length );
    1.55 +
    1.56 +new TestCase(   SECTION,
    1.57 +		"Array(1,2,3) +''",
    1.58 +		"1,2,3",
    1.59 +		Array(1,2,3) +"" );
    1.60 +
    1.61 +new TestCase(   SECTION,
    1.62 +		"typeof Array(1,2,3)",
    1.63 +		"object",
    1.64 +		typeof Array(1,2,3) );
    1.65 +
    1.66 +new TestCase(   SECTION,
    1.67 +		"var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
    1.68 +		"[object Array]",
    1.69 +		eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
    1.70 +
    1.71 +new TestCase(   SECTION,
    1.72 +		"var arr = Array(1,2,3); arr.toString == Array.prototype.toString",
    1.73 +		true,
    1.74 +		eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") );
    1.75 +
    1.76 +new TestCase(   SECTION,
    1.77 +		"Array(1,2,3).length",
    1.78 +		3,
    1.79 +		Array(1,2,3).length );
    1.80 +
    1.81 +new TestCase(   SECTION,
    1.82 +		"typeof Array(12345)",
    1.83 +		"object",
    1.84 +		typeof Array(12345) );
    1.85 +
    1.86 +new TestCase(   SECTION,
    1.87 +		"var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()",
    1.88 +		"[object Array]",
    1.89 +		eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") );
    1.90 +
    1.91 +new TestCase(   SECTION,
    1.92 +		"var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString",
    1.93 +		true,
    1.94 +		eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") );
    1.95 +
    1.96 +new TestCase(   SECTION,
    1.97 +		"Array(12345).length",
    1.98 +		12345,
    1.99 +		Array(12345).length );
   1.100 +
   1.101 +test();

mercurial