1 /*
   2  * Copyright (c) 2010, 2013, 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-8019814: Add regression test for passing cases
  26  *
  27  * @test
  28  * @run
  29  */
  30 
  31 // java.lang.VerifyError: Bad type on operand stack
  32 Function("switch([]) { case 7: }");
  33 
  34 // java.lang.AssertionError: expecting integer type or object for jump, but found double
  35 Function("with(\nnull == (this % {}))( /x/g );");
  36 
  37 // java.lang.AssertionError: expecting equivalent types on stack but got double and int
  38 try {
  39     eval('Function("/*infloop*/while(((function ()4.)([z1,,], [,,]) - true++))switch(1e+81.x) { default: break; \u0009 }")');
  40 } catch (e) {
  41     print(e.toString().replace(/\\/g, '/'));
  42 }
  43 
  44 // java.lang.VerifyError: get long/double overflows locals
  45 Function("var x = x -= '' ");
  46 
  47 // java.lang.AssertionError: object is not compatible with boolean
  48 Function("return (null != [,,] <= this);");
  49 
  50 // java.lang.AssertionError: Only return value on stack allowed at return point
  51 // - depth=2 stack = jdk.nashorn.internal.codegen.Label$Stack@4bd0d62f
  52 Function("x = 0.1, x\ntrue\n~this");
  53 
  54 // java.lang.AssertionError: node NaN ~ window class jdk.nashorn.internal.ir.BinaryNode
  55 // has no symbol! [object] function _L1()
  56 Function("throw NaN\n~window;");
  57 
  58 // java.lang.AssertionError: array element type doesn't match array type
  59 Function("if(([(this >>> 4.)].map(gc))) x;");
  60 
  61 try {
  62     eval('Function("if(--) y;")');
  63 } catch (e) {
  64     print(e.toString().replace(/\\/g, '/'));
  65 }
  66 
  67 // java.lang.AssertionError: stacks jdk.nashorn.internal.codegen.Label$Stack@4918f90f
  68 // is not equivalent with jdk.nashorn.internal.codegen.Label$Stack@5f9b21a1 at join point
  69 Function("if((null ^ [1]) !== (this.yoyo(false))) {var NaN, x;x\n~[,,z1] }");
  70 
  71 // java.lang.AssertionError
  72 //    at jdk.nashorn.internal.codegen.Attr.enterFunctionBody(Attr.java:276)
  73 Function("return (void ({ set each (x2)y }));");