NASHORN-23.js revision 6:5a1b0714df0e
11556Srgrimes/*
21556Srgrimes * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
31556Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41556Srgrimes *
51556Srgrimes * This code is free software; you can redistribute it and/or modify it
61556Srgrimes * under the terms of the GNU General Public License version 2 only, as
71556Srgrimes * published by the Free Software Foundation.
81556Srgrimes *
91556Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
101556Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111556Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
121556Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
131556Srgrimes * accompanied this code).
141556Srgrimes *
151556Srgrimes * You should have received a copy of the GNU General Public License version
161556Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
171556Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
181556Srgrimes *
191556Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
201556Srgrimes * or visit www.oracle.com if you need additional information or have any
211556Srgrimes * questions.
221556Srgrimes */
231556Srgrimes
241556Srgrimes/**
251556Srgrimes * NASHORN-23:  calling function valued global variable before it is initialized should fail.
261556Srgrimes *
271556Srgrimes * @test
281556Srgrimes * @run
291556Srgrimes */
301556Srgrimes
311556Srgrimes
321556Srgrimestry {
331556Srgrimes    func();
341556Srgrimes    print("huh!! we can call undefined variable as function!");
3536049Scharnier} catch (e) {
3636049Scharnier    if (! (e instanceof TypeError)) {
3736049Scharnier        print("TypeError expected");
381556Srgrimes    }
3999110Sobrien}
4099110Sobrien
411556Srgrimes// define now..
421556Srgrimesvar func = function() {
431556Srgrimes  print("hello");
441556Srgrimes}
451556Srgrimes
461556Srgrimesfunc(); // should be able to invoke now..
471556Srgrimes