test/script/basic/JDK-8038945.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 963
e2497b11a021
permissions
-rw-r--r--

Merge

     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  */
    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  */
    32 //:program internals={print=0, f1=0, f2=0, f3=0, f4=0, undefined=0, f5=0} externals=null
    34 //f1 internals={} externals={undefined=0}
    35 function f1(x) {
    36     return x === undefined;
    37 }
    39 //f2 internals={} externals=null
    40 function f2(x, undefined) {
    41     return x === undefined;
    42 }
    44 //f3 internals={x=0} externals=null
    45 function 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 }
    53 //f4 internals={x=0} externals=null
    54 function 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 }
    63 //f5 internals={x=0, undefined=0} externals=null
    64 function 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 }
    73 print(" 1: " + f1(17) + " === false");
    74 print(" 2: " + f2(17) + " === false");
    75 print(" 3: " + f3(17) + " === true");
    76 print(" 4: " + f4(17) + " === true");
    77 print(" 5: " + f5(17) + " === true");
    79 //recompile
    80 print(" 6: " + f1("17") + " === false");
    81 print(" 7: " + f2("17") + " === false");
    82 print(" 8: " + f3("17") + " === false");
    83 print(" 9: " + f4("17") + " === false");
    84 print("10: " + f5("17") + " === false");
    86 //g1 internals={} externals={undefined=0}
    87 function g1(x) {
    88     return x !== undefined;
    89 }
    91 //g2 internals={} externals=null
    92 function g2(x, undefined) {
    93     return x !== undefined;
    94 }
    96 //g3 internals={x=0} externals=null
    97 function 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 }
   105 //g4 internals={x=0} externals=null
   106 function 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 }
   115 //g5 internals={x=0, undefined=0} externals=null
   116 function 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 }
   125 print("11: " + g1(17) + " === true");
   126 print("12: " + g2(17) + " === true");
   127 print("13: " + g3(17) + " === false");
   128 print("14: " + g4(17) + " === false");
   129 print("15: " + g5(17) + " === false");
   131 //recompile
   132 print("16: " + g1("17") + " === true");
   133 print("17: " + g2("17") + " === true");
   134 print("18: " + g3("17") + " === true");
   135 print("19: " + g4("17") + " === true");
   136 print("20: " + g5("17") + " === true");
   138 //h1 internals={} externals={undefined=0}
   139 function h1(x) {
   140     return undefined === x;
   141 }
   143 //h2 internals={} externals=null
   144 function h2(x, undefined) {
   145     return undefined === x;
   146 }
   148 //h3 internals={x=0} externals=null
   149 function 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 }
   157 //h4 internals={x=0} externals=null
   158 function 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 }
   167 //h5 internals={x=0, undefined=0} externals=null
   168 function 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 }
   177 print("21: " + h1(17) + " === false");
   178 print("22: " + h2(17) + " === false");
   179 print("23: " + h3(17) + " === true");
   180 print("24: " + h4(17) + " === true");
   181 print("25: " + h5(17) + " === true");
   183 //recompile
   184 print("26: " + h1("17") + " === false");
   185 print("27: " + h2("17") + " === false");
   186 print("28: " + h3("17") + " === false");
   187 print("29: " + h4("17") + " === false");
   188 print("30: " + h5("17") + " === false");
   190 //i1 internals={} externals={undefined=0}
   191 function i1(x) {
   192     return undefined !== x;
   193 }
   195 //i2 internals={} externals=null
   196 function i2(x, undefined) {
   197     return undefined !== x;
   198 }
   200 //i3 internals={x=0} externals=null
   201 function 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 }
   209 //i4 internals={x=0} externals=null
   210 function 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 }
   219 //h5 internals={x=0, undefined=0} externals=null
   220 function 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 }
   229 print("31: " + i1(17) + " === true");
   230 print("32: " + i2(17) + " === true");
   231 print("33: " + i3(17) + " === false");
   232 print("34: " + i4(17) + " === false");
   233 print("35: " + i5(17) + " === false");
   235 //recompile
   236 print("36: " + i1("17") + " === true");
   237 print("37: " + i2("17") + " === true");
   238 print("38: " + i3("17") + " === true");
   239 print("39: " + i4("17") + " === true");
   240 print("40: " + i5("17") + " === true");

mercurial