sundar@1520: /* sundar@1520: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. sundar@1520: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@1520: * sundar@1520: * This code is free software; you can redistribute it and/or modify it sundar@1520: * under the terms of the GNU General Public License version 2 only, as sundar@1520: * published by the Free Software Foundation. sundar@1520: * sundar@1520: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@1520: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@1520: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@1520: * version 2 for more details (a copy is included in the LICENSE file that sundar@1520: * accompanied this code). sundar@1520: * sundar@1520: * You should have received a copy of the GNU General Public License version sundar@1520: * 2 along with this work; if not, write to the Free Software Foundation, sundar@1520: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@1520: * sundar@1520: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@1520: * or visit www.oracle.com if you need additional information or have any sundar@1520: * questions. sundar@1520: */ sundar@1520: sundar@1520: /** sundar@1520: * JDK-8134731: `Function.prototype.apply` interacts incorrectly with `arguments` sundar@1520: * sundar@1520: * @test sundar@1520: * @run sundar@1520: */ sundar@1520: sundar@1520: function func() { sundar@1520: return (function(f){ sundar@1520: return function(a1, a2, a3, a4){ sundar@1520: return (f.apply(this, arguments)); sundar@1520: } sundar@1520: })(function(){ sundar@1520: return arguments.length; sundar@1520: }) sundar@1520: } sundar@1520: sundar@1520: Assert.assertTrue(func()() == 0); sundar@1520: Assert.assertTrue(func()(33) == 1); sundar@1520: Assert.assertTrue(func()(33, true) == 2); sundar@1520: Assert.assertTrue(func()(33, true, "hello") == 3); sundar@1520: Assert.assertTrue(func()(33, true, "hello", "world") == 4); sundar@1520: Assert.assertTrue(func()(33, true, "hello", "world", 42) == 5);