test/nashorn/script/basic/JDK-8038945.js
changeset 47216 71c04702a3d5
parent 24778 2ff5d7041566
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     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}
       
    35 function f1(x) {
       
    36     return x === undefined;
       
    37 }
       
    38 
       
    39 //f2 internals={} externals=null
       
    40 function f2(x, undefined) {
       
    41     return x === undefined;
       
    42 }
       
    43 
       
    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 }
       
    52 
       
    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 }
       
    62 
       
    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 }
       
    72 
       
    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");
       
    78 
       
    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");
       
    85 
       
    86 //g1 internals={} externals={undefined=0}
       
    87 function g1(x) {
       
    88     return x !== undefined;
       
    89 }
       
    90 
       
    91 //g2 internals={} externals=null
       
    92 function g2(x, undefined) {
       
    93     return x !== undefined;
       
    94 }
       
    95 
       
    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 }
       
   104 
       
   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 }
       
   114 
       
   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 }
       
   124 
       
   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");
       
   130 
       
   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");
       
   137 
       
   138 //h1 internals={} externals={undefined=0}
       
   139 function h1(x) {
       
   140     return undefined === x;
       
   141 }
       
   142 
       
   143 //h2 internals={} externals=null
       
   144 function h2(x, undefined) {
       
   145     return undefined === x;
       
   146 }
       
   147 
       
   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 }
       
   156 
       
   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 }
       
   166 
       
   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 }
       
   176 
       
   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");
       
   182 
       
   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");
       
   189 
       
   190 //i1 internals={} externals={undefined=0}
       
   191 function i1(x) {
       
   192     return undefined !== x;
       
   193 }
       
   194 
       
   195 //i2 internals={} externals=null
       
   196 function i2(x, undefined) {
       
   197     return undefined !== x;
       
   198 }
       
   199 
       
   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 }
       
   208 
       
   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 }
       
   218 
       
   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 }
       
   228 
       
   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");
       
   234 
       
   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");