sundar@403: /* sundar@403: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. sundar@403: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@403: * sundar@403: * This code is free software; you can redistribute it and/or modify it sundar@403: * under the terms of the GNU General Public License version 2 only, as sundar@403: * published by the Free Software Foundation. sundar@403: * sundar@403: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@403: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@403: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@403: * version 2 for more details (a copy is included in the LICENSE file that sundar@403: * accompanied this code). sundar@403: * sundar@403: * You should have received a copy of the GNU General Public License version sundar@403: * 2 along with this work; if not, write to the Free Software Foundation, sundar@403: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@403: * sundar@403: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@403: * or visit www.oracle.com if you need additional information or have any sundar@403: * questions. sundar@403: */ sundar@403: sundar@403: /** sundar@403: * JDK-8019791: ~ is a unary operator sundar@403: * sundar@403: * @test sundar@403: * @run sundar@403: */ sundar@403: sundar@403: // Used to crash instead of SyntaxError sundar@403: try { sundar@403: eval('"" ~ ""'); sundar@403: print("FAILED: SyntaxError expected for: \"\" ~ \"\""); sundar@403: } catch (e) { sundar@606: printError(e); sundar@403: } sundar@403: sundar@403: // Used to crash instead of SyntaxError sundar@403: try { sundar@403: eval("function() { if (1~0) return 0; return 1 }"); sundar@403: print("FAILED: SyntaxError expected for: if (1~0) "); sundar@403: } catch (e) { sundar@606: printError(e); sundar@403: } sundar@403: sundar@403: // The following are valid, but used to crash sundar@403: Function("0 \n ~ 2 \n ~ 1")(); sundar@403: sundar@403: Function("~ ~ 0 \n ~ ~ 1")();