NASHORN-95.js revision 6:5a1b0714df0e
1254721Semaste/*
2254721Semaste * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3254721Semaste * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4254721Semaste *
5254721Semaste * This code is free software; you can redistribute it and/or modify it
6254721Semaste * under the terms of the GNU General Public License version 2 only, as
7254721Semaste * published by the Free Software Foundation.
8254721Semaste *
9254721Semaste * This code is distributed in the hope that it will be useful, but WITHOUT
10254721Semaste * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11254721Semaste * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12254721Semaste * version 2 for more details (a copy is included in the LICENSE file that
13254721Semaste * accompanied this code).
14254721Semaste *
15254721Semaste * You should have received a copy of the GNU General Public License version
16254721Semaste * 2 along with this work; if not, write to the Free Software Foundation,
17254721Semaste * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18254721Semaste *
19254721Semaste * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20254721Semaste * or visit www.oracle.com if you need additional information or have any
21254721Semaste * questions.
22254721Semaste */
23254721Semaste
24254721Semaste/**
25254721Semaste * NASHORN-95 :  function length is always -1 when it uses "arguments" regardless of actual formals specified.
26254721Semaste *
27254721Semaste *
28254721Semaste * @test
29254721Semaste * @run
30254721Semaste */
31254721Semaste
32254721Semastefunction func1() {
33254721Semaste    print(arguments);
34254721Semaste}
35254721Semaste
36254721Semastefunction func2(x, y) {
37254721Semaste    print(arguments);
38254721Semaste}
39254721Semaste
40254721Semastefunction func3(x, y, z) {
41254721Semaste    print(arguments);
42254721Semaste}
43254721Semaste
44254721Semaste// more than arglimit number of arguments - so uses varargs in impl..
45254721Semastefunction func4(a, b, c, d, e, f, g, h, i, j) {}
46254721Semaste
47254721Semasteprint("func1.length = " + func1.length);
48254721Semasteprint("func2.length = " + func2.length);
49254721Semasteprint("func3.length = " + func3.length);
50254721Semasteprint("func4.length = " + func4.length);
51254721Semaste