with.js revision 6:5a1b0714df0e
1153816Sdougb/* 2193149Sdougb * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3153816Sdougb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4153816Sdougb * 5153816Sdougb * This code is free software; you can redistribute it and/or modify it 6153816Sdougb * under the terms of the GNU General Public License version 2 only, as 7153816Sdougb * published by the Free Software Foundation. 8153816Sdougb * 9153816Sdougb * This code is distributed in the hope that it will be useful, but WITHOUT 10153816Sdougb * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11153816Sdougb * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12153816Sdougb * version 2 for more details (a copy is included in the LICENSE file that 13153816Sdougb * accompanied this code). 14153816Sdougb * 15153816Sdougb * You should have received a copy of the GNU General Public License version 16153816Sdougb * 2 along with this work; if not, write to the Free Software Foundation, 17193149Sdougb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18153816Sdougb * 19153816Sdougb * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20153816Sdougb * or visit www.oracle.com if you need additional information or have any 21153816Sdougb * questions. 22170222Sdougb */ 23153816Sdougb 24153816Sdougb/** 25153816Sdougb * With test. 26153816Sdougb * 27153816Sdougb * @test 28153816Sdougb * @run 29153816Sdougb */ 30153816Sdougb 31153816Sdougbvar x = {a: 10, b: 20, c: 30}; 32153816Sdougb 33153816Sdougbvar b = "here"; 34153816Sdougb 35153816Sdougbprint(b); 36153816Sdougbprint(x.b); 37153816Sdougb 38153816Sdougbwith (x) { 39153816Sdougb print(b); 40153816Sdougb print(x.b); 41153816Sdougb 42153816Sdougb b = false; 43153816Sdougb 44153816Sdougb print(b); 45153816Sdougb print(x.b); 46153816Sdougb 47153816Sdougb y = 200; 48153816Sdougb} 49153816Sdougb 50153816Sdougbprint(b); 51153816Sdougbprint(x.b); 52193149Sdougb 53193149Sdougbfor (i in x) print(i, x[i]); 54153816Sdougb 55153816Sdougbvar obj = { 56193149Sdougb __noSuchProperty__: function(name) { 57193149Sdougb return name.toUpperCase(); 58193149Sdougb } 59193149Sdougb}; 60193149Sdougb 61193149Sdougbwith(obj) { 62153816Sdougb print(foo); 63193149Sdougb print(bar); 64193149Sdougb} 65153816Sdougb