• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.3.5.1.js
24    ECMA Section:       Function.length
25    Description:
26
27    The value of the length property is usually an integer that indicates the
28    "typical" number of arguments expected by the function.  However, the
29    language permits the function to be invoked with some other number of
30    arguments. The behavior of a function when invoked on a number of arguments
31    other than the number specified by its length property depends on the function.
32
33    This checks the pre-ecma behavior Function.length.
34
35    http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204
36
37
38    Author:             christine@netscape.com
39    Date:               12 november 1997
40*/
41
42    var SECTION = "function/length.js";
43    var VERSION = "ECMA_1";
44    startTest();
45    var TITLE   = "Function.length";
46    var BUGNUMBER="104204";
47
48    writeHeaderToLog( SECTION + " "+ TITLE);
49
50    var testcases = new Array();
51
52    var f = new Function( "a","b", "c", "return f.length");
53
54    if ( version() <= 120 ) {
55
56    testcases[tc++] = new TestCase( SECTION,
57        'var f = new Function( "a","b", "c", "return f.length"); f()',
58        0,
59        f() );
60
61    testcases[tc++] = new TestCase( SECTION,
62        'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)',
63        5,
64        f(1,2,3,4,5) );
65    } else {
66
67    testcases[tc++] = new TestCase( SECTION,
68        'var f = new Function( "a","b", "c", "return f.length"); f()',
69        3,
70        f() );
71
72    testcases[tc++] = new TestCase( SECTION,
73        'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)',
74        3,
75        f(1,2,3,4,5) );
76
77
78    }
79    test();
80
81function test() {
82    for ( tc=0; tc < testcases.length; tc++ ) {
83        testcases[tc].passed = writeTestCaseResult(
84                            testcases[tc].expect,
85                            testcases[tc].actual,
86                            testcases[tc].description +" = "+
87                            testcases[tc].actual );
88
89        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
90    }
91    stopTest();
92    return ( testcases );
93}
94