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 30 function func(x, y, z) { 31 print(x, y, z); 32 } 33 34 function g() { 35 func.apply(this, arguments); 36 } 37 function h() { 38 func.apply(this, arguments, 23); 39 } 40 function i() { 41 func.apply(this, arguments, 23, 4711); 42 } 43 function j() { 44 func.apply(this, arguments, 23, 4711, "apa", "dingo", "gorilla"); 45 } 46 function k() { 47 func.apply(this, arguments, 23); 48 } 49 function l() { 50 func.apply(this, [23, "apa", "gorilla", "dingo"], 17); 51 } 52 function m() { 53 func.apply(this, [23, "apa", "gorilla", "dingo"]); 54 } 55 function n() { 56 func.apply(this, "significant"); 57 } 58 59 g(1,2); 60 g(1,2,3); 61 g(1,2,3,4); 62 63 h(1,2); 64 h(1,2,3); 65 h(1,2,3,4); 66 67 i(1,2); 68 i(1,2,3); 69 i(1,2,3,4); 70 71 j(1,2); 72 j(1,2,3); 73 j(1,2,3,4); 74 75 k(1,2); 76 k(1,2,3); 77 k(1,2,3,4); 78 79 l(1,2); 80 l(1,2,3); 81 l(1,2,3,4); 82 83 m(1,2); 84 m(1,2,3); 85 m(1,2,3,4); 86 87 try { 88 n(1,2); 89 } catch (e) { 90 print(e); 91 } 92 try { 93 n(1,2,3); 94 } catch (e) { 95 print(e); 96 } 97 98 try { 99 n(1,2,3,4); 100 } catch (e) { 101 print(e); 102 }