NASHORN-691.js revision 2:da1e581c933b
1306196Sjkim/*
296593Smarkm * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
396593Smarkm * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4142429Snectar *
596593Smarkm * This code is free software; you can redistribute it and/or modify it
696593Smarkm * under the terms of the GNU General Public License version 2 only, as
796593Smarkm * published by the Free Software Foundation.
896593Smarkm *
996593Smarkm * This code is distributed in the hope that it will be useful, but WITHOUT
1096593Smarkm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1196593Smarkm * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1296593Smarkm * version 2 for more details (a copy is included in the LICENSE file that
1396593Smarkm * accompanied this code).
1496593Smarkm *
1596593Smarkm * You should have received a copy of the GNU General Public License version
1696593Smarkm * 2 along with this work; if not, write to the Free Software Foundation,
1796593Smarkm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1896593Smarkm *
1996593Smarkm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20215698Ssimon * or visit www.oracle.com if you need additional information or have any
21215698Ssimon * questions.
22215698Ssimon */
23215698Ssimon
24215698Ssimon/**
2596593Smarkm * NASHORN-691 :  Get rid of function id guard
2696593Smarkm *
2796593Smarkm * @test
2896593Smarkm * @run
2996593Smarkm */
3096593Smarkm
3196593Smarkmfunction func(x) {
3296593Smarkm    return function(name) {
3396593Smarkm        return x;
3496593Smarkm    }
3596593Smarkm};
3696593Smarkm
3796593Smarkmvar delegate = {
3896593Smarkm   __get__: func(33)
3996593Smarkm};
4096593Smarkm
41276864Sjkimvar x = new JSAdapter(delegate);
42276864Sjkim
4396593Smarkmfunction f(o) {
4496593Smarkm   print('o.foo = ' + o.foo);
45215698Ssimon}
46215698Ssimon
47215698Ssimonf(x);
48215698Ssimon
49142429Snectar// now change __get__
50215698Ssimondelegate.__get__ = func(44);
51142429Snectarf(x);
52142429Snectar
53276864Sjkimvar obj = {};
54276864Sjkimobj.__noSuchProperty__ = func(3);
55276864Sjkimf(obj);
5696593Smarkmobj.__noSuchProperty__ = func("hello");
57276864Sjkimf(obj);
58276864Sjkim