NASHORN-284.js revision 2:da1e581c933b
11590Srgrimes/*
21590Srgrimes * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
31590Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41590Srgrimes *
51590Srgrimes * This code is free software; you can redistribute it and/or modify it
61590Srgrimes * under the terms of the GNU General Public License version 2 only, as
71590Srgrimes * published by the Free Software Foundation.
81590Srgrimes *
91590Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
101590Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111590Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
121590Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
131590Srgrimes * accompanied this code).
141590Srgrimes *
151590Srgrimes * You should have received a copy of the GNU General Public License version
161590Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
171590Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
181590Srgrimes *
191590Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
201590Srgrimes * or visit www.oracle.com if you need additional information or have any
211590Srgrimes * questions.
221590Srgrimes */
231590Srgrimes
241590Srgrimes/**
251590Srgrimes * NASHORN-284 :  Guard setup in ScriptObject.findGetMethod is wrong for inherited properties
261590Srgrimes *
271590Srgrimes * @test
281590Srgrimes * @run
291590Srgrimes */
30105243Scharnier
311590Srgrimesvar obj1 = { x : 44 };
3227327Scharnier
33105243Scharniervar obj2 = Object.create(obj1);
3427313Scharnier// shadow obj1.x here
35105243Scharnierobj2.x = 'hello';
3699112Sobrien
3799112Sobrienvar obj3 = Object.create(obj2);
381590Srgrimes
3927313Scharnierfunction func(obj) {
401590Srgrimes   print("x = " + obj.x);
411590Srgrimes}
421590Srgrimes
431590Srgrimes// should print obj2.x from obj3
441590Srgrimesfunc(obj3);
451590Srgrimes// the following should expose obj1.x on obj3
461590Srgrimesdelete obj2.x;
4797631Swollman// now, it should print obj1.x
481590Srgrimesfunc(obj3);
49246783Scharnier