nosuchproperty.js revision 2:da1e581c933b
1163953Srrs/* 2185694Srrs * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 3235828Stuexen * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4235828Stuexen * 5163953Srrs * This code is free software; you can redistribute it and/or modify it 6163953Srrs * under the terms of the GNU General Public License version 2 only, as 7163953Srrs * published by the Free Software Foundation. 8163953Srrs * 9163953Srrs * This code is distributed in the hope that it will be useful, but WITHOUT 10228653Stuexen * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11163953Srrs * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12163953Srrs * version 2 for more details (a copy is included in the LICENSE file that 13163953Srrs * accompanied this code). 14228653Stuexen * 15163953Srrs * You should have received a copy of the GNU General Public License version 16163953Srrs * 2 along with this work; if not, write to the Free Software Foundation, 17163953Srrs * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18163953Srrs * 19163953Srrs * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20163953Srrs * or visit www.oracle.com if you need additional information or have any 21163953Srrs * questions. 22163953Srrs */ 23163953Srrs 24163953Srrs/** 25163953Srrs * Check __noSuchProperty__ 26163953Srrs * 27163953Srrs * @test 28163953Srrs * @run 29163953Srrs */ 30163953Srrs 31163953Srrsfunction func(o) { 32163953Srrs return o.foo; 33163953Srrs} 34163953Srrs 35163953Srrsvar obj = { 36163953Srrs __noSuchProperty__: function(name) { 37163953Srrs print("obj.__noSuchProperty__ for " + name); 38163953Srrs } 39235828Stuexen}; 40163953Srrs 41163953Srrsfunc(obj); 42179783Srrs 43179783Srrsobj.__noSuchProperty__ = function(name) { 44179783Srrs print("new obj.__noSuchProperty__ for " + name); 45163953Srrs} 46267721Stuexen 47163953Srrsfunc(obj); 48163953Srrs 49163953Srrs// try inherited __noSuchProperty__ now. 50163953Srrsvar proto = { 51163953Srrs __noSuchProperty__ : function(name) { 52267721Stuexen print("proto.__noSuchProperty__ for " + name); 53163953Srrs } 54179783Srrs}; 55163953Srrs 56163953Srrsvar obj2 = Object.create(proto); 57163953Srrsfunc(obj2); 58163953Srrs 59179783Srrsproto.__noSuchProperty__ = function(name) { 60179783Srrs print("new proto.__noSuchProperty__ for " + name); 61179783Srrs} 62179783Srrs 63179783Srrsfunc(obj2); 64179783Srrs