JDK-8038945.js revision 877:cf4d2252d444
1/* 2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/** 25 * JDK-8038945.js : test various undefined strict intrinsics and that they 26 * aren't erroneously applied when undefined is in any scope but global 27 * 28 * @test 29 * @run 30 */ 31 32//:program internals={print=0, f1=0, f2=0, f3=0, f4=0, undefined=0, f5=0} externals=null 33 34//f1 internals={} externals={undefined=0} 35function f1(x) { 36 return x === undefined; 37} 38 39//f2 internals={} externals=null 40function f2(x, undefined) { 41 return x === undefined; 42} 43 44//f3 internals={x=0} externals=null 45function f3(x) { 46 //f3$f3_2 internals={} externals={x=0} 47 function f3_2(undefined) { 48 return x === undefined; 49 } 50 return f3_2(17); 51} 52 53//f4 internals={x=0} externals=null 54function f4(x) { 55 //f4$f4_2 internals={} externals={x=0} 56 function f4_2() { 57 var undefined = 17; 58 return x === undefined; 59 } 60 return f4_2(); 61} 62 63//f5 internals={x=0, undefined=0} externals=null 64function f5(x) { 65 var undefined = 17; 66 //f5$f5_2 internals={} externals={x=0, undefined=0} 67 function f5_2() { 68 return x === undefined; 69 } 70 return f5_2(); 71} 72 73print(" 1: " + f1(17) + " === false"); 74print(" 2: " + f2(17) + " === false"); 75print(" 3: " + f3(17) + " === true"); 76print(" 4: " + f4(17) + " === true"); 77print(" 5: " + f5(17) + " === true"); 78 79//recompile 80print(" 6: " + f1("17") + " === false"); 81print(" 7: " + f2("17") + " === false"); 82print(" 8: " + f3("17") + " === false"); 83print(" 9: " + f4("17") + " === false"); 84print("10: " + f5("17") + " === false"); 85 86//g1 internals={} externals={undefined=0} 87function g1(x) { 88 return x !== undefined; 89} 90 91//g2 internals={} externals=null 92function g2(x, undefined) { 93 return x !== undefined; 94} 95 96//g3 internals={x=0} externals=null 97function g3(x) { 98 //g3$g3_2 internals={} externals={x=0} 99 function g3_2(undefined) { 100 return x !== undefined; 101 } 102 return g3_2(17); 103} 104 105//g4 internals={x=0} externals=null 106function g4(x) { 107 //f4$f4_2 internals={} externals={x=0} 108 function g4_2() { 109 var undefined = 17; 110 return x !== undefined; 111 } 112 return g4_2(); 113} 114 115//g5 internals={x=0, undefined=0} externals=null 116function g5(x) { 117 var undefined = 17; 118 //g5$g5_2 internals={} externals={x=0, undefined=0} 119 function g5_2() { 120 return x !== undefined; 121 } 122 return g5_2(); 123} 124 125print("11: " + g1(17) + " === true"); 126print("12: " + g2(17) + " === true"); 127print("13: " + g3(17) + " === false"); 128print("14: " + g4(17) + " === false"); 129print("15: " + g5(17) + " === false"); 130 131//recompile 132print("16: " + g1("17") + " === true"); 133print("17: " + g2("17") + " === true"); 134print("18: " + g3("17") + " === true"); 135print("19: " + g4("17") + " === true"); 136print("20: " + g5("17") + " === true"); 137 138//h1 internals={} externals={undefined=0} 139function h1(x) { 140 return undefined === x; 141} 142 143//h2 internals={} externals=null 144function h2(x, undefined) { 145 return undefined === x; 146} 147 148//h3 internals={x=0} externals=null 149function h3(x) { 150 //h3$f3_2 internals={} externals={x=0} 151 function h3_2(undefined) { 152 return undefined === x; 153 } 154 return h3_2(17); 155} 156 157//h4 internals={x=0} externals=null 158function h4(x) { 159 //h4$h4_2 internals={} externals={x=0} 160 function h4_2() { 161 var undefined = 17; 162 return undefined === x; 163 } 164 return h4_2(); 165} 166 167//h5 internals={x=0, undefined=0} externals=null 168function h5(x) { 169 var undefined = 17; 170 //h5$h5_2 internals={} externals={x=0, undefined=0} 171 function h5_2() { 172 return undefined === x; 173 } 174 return h5_2(); 175} 176 177print("21: " + h1(17) + " === false"); 178print("22: " + h2(17) + " === false"); 179print("23: " + h3(17) + " === true"); 180print("24: " + h4(17) + " === true"); 181print("25: " + h5(17) + " === true"); 182 183//recompile 184print("26: " + h1("17") + " === false"); 185print("27: " + h2("17") + " === false"); 186print("28: " + h3("17") + " === false"); 187print("29: " + h4("17") + " === false"); 188print("30: " + h5("17") + " === false"); 189 190//i1 internals={} externals={undefined=0} 191function i1(x) { 192 return undefined !== x; 193} 194 195//i2 internals={} externals=null 196function i2(x, undefined) { 197 return undefined !== x; 198} 199 200//i3 internals={x=0} externals=null 201function i3(x) { 202 //i3$f3_2 internals={} externals={x=0} 203 function i3_2(undefined) { 204 return undefined !== x; 205 } 206 return i3_2(17); 207} 208 209//i4 internals={x=0} externals=null 210function i4(x) { 211 //i4$i4_2 internals={} externals={x=0} 212 function i4_2() { 213 var undefined = 17; 214 return undefined !== x; 215 } 216 return i4_2(); 217} 218 219//h5 internals={x=0, undefined=0} externals=null 220function i5(x) { 221 var undefined = 17; 222 //i5$i5_2 internals={} externals={x=0, undefined=0} 223 function i5_2() { 224 return undefined !== x; 225 } 226 return i5_2(); 227} 228 229print("31: " + i1(17) + " === true"); 230print("32: " + i2(17) + " === true"); 231print("33: " + i3(17) + " === false"); 232print("34: " + i4(17) + " === false"); 233print("35: " + i5(17) + " === false"); 234 235//recompile 236print("36: " + i1("17") + " === true"); 237print("37: " + i2("17") + " === true"); 238print("38: " + i3("17") + " === true"); 239print("39: " + i4("17") + " === true"); 240print("40: " + i5("17") + " === true"); 241