1/* 2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/** 25 * this apply with extra arguments 26 * 27 * @subtest 28 */ 29 30function func(x, y, z) { 31 print(x, y, z); 32} 33 34function g() { 35 func.apply(this, arguments); 36} 37function h() { 38 func.apply(this, arguments, 23); 39} 40function i() { 41 func.apply(this, arguments, 23, 4711); 42} 43function j() { 44 func.apply(this, arguments, 23, 4711, "apa", "dingo", "gorilla"); 45} 46function k() { 47 func.apply(this, arguments, 23); 48} 49function l() { 50 func.apply(this, [23, "apa", "gorilla", "dingo"], 17); 51} 52function m() { 53 func.apply(this, [23, "apa", "gorilla", "dingo"]); 54} 55function n() { 56 func.apply(this, "significant"); 57} 58 59g(1,2); 60g(1,2,3); 61g(1,2,3,4); 62 63h(1,2); 64h(1,2,3); 65h(1,2,3,4); 66 67i(1,2); 68i(1,2,3); 69i(1,2,3,4); 70 71j(1,2); 72j(1,2,3); 73j(1,2,3,4); 74 75k(1,2); 76k(1,2,3); 77k(1,2,3,4); 78 79l(1,2); 80l(1,2,3); 81l(1,2,3,4); 82 83m(1,2); 84m(1,2,3); 85m(1,2,3,4); 86 87try { 88 n(1,2); 89} catch (e) { 90 print(e); 91} 92try { 93 n(1,2,3); 94} catch (e) { 95 print(e); 96} 97 98try { 99 n(1,2,3,4); 100} catch (e) { 101 print(e); 102} 103