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