NASHORN-99.js revision 877:cf4d2252d444
1139825Simp/*
222521Sdyson * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
31541Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41541Srgrimes *
51541Srgrimes * This code is free software; you can redistribute it and/or modify it
61541Srgrimes * under the terms of the GNU General Public License version 2 only, as
71541Srgrimes * published by the Free Software Foundation.
81541Srgrimes *
91541Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
101541Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111541Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
121541Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
131541Srgrimes * accompanied this code).
141541Srgrimes *
151541Srgrimes * You should have received a copy of the GNU General Public License version
161541Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
171541Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
181541Srgrimes *
191541Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
201541Srgrimes * or visit www.oracle.com if you need additional information or have any
211541Srgrimes * questions.
221541Srgrimes */
231541Srgrimes
241541Srgrimes
251541Srgrimes/**
261541Srgrimes * NASHORN-99 :  Passing less number of arguments to a native varargs function results in IllegalArgumentException.
271541Srgrimes *
281541Srgrimes * @test
291541Srgrimes * @run
301541Srgrimes */
311541Srgrimes
321541Srgrimesfunction func() {
331541Srgrimes}
3422521Sdyson
351541Srgrimestry {
361541Srgrimes    func.call();
37116192Sobrien} catch (e) {
38116192Sobrien    fail("func.call() failed", e);
39116192Sobrien}
4013260Swollman
4131749Seivindvar obj = Object.create(Function.prototype);
4274822Srwatson
43136969Sphkif (typeof obj.call !== "function") {
4413260Swollman    fail('#1: call method not found!');
451541Srgrimes}
461541Srgrimes
47101073Srwatsontry {
481541Srgrimes    obj.call();
491541Srgrimes    fail('#2: No [[Call]] property, a TypeError expected');
5018020Sbde} catch (e) {
51236044Skib    if (!(e instanceof TypeError)) {
521541Srgrimes        fail('#3: TypeError expected but got ' + e);
5360041Sphk    }
541541Srgrimes}
551541Srgrimes