test/script/basic/JDK-8066407.js

Mon, 27 Apr 2015 12:27:33 +0200

author
hannesw
date
Mon, 27 Apr 2015 12:27:33 +0200
changeset 1336
5ed57fe26f13
permissions
-rw-r--r--

8066407: Function with same body not reparsed after SyntaxError
Reviewed-by: attila, lagergren

hannesw@1336 1 /*
hannesw@1336 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hannesw@1336 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1336 4 *
hannesw@1336 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1336 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1336 7 * published by the Free Software Foundation.
hannesw@1336 8 *
hannesw@1336 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1336 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1336 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1336 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1336 13 * accompanied this code).
hannesw@1336 14 *
hannesw@1336 15 * You should have received a copy of the GNU General Public License version
hannesw@1336 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1336 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1336 18 *
hannesw@1336 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1336 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1336 21 * questions.
hannesw@1336 22 */
hannesw@1336 23
hannesw@1336 24 /**
hannesw@1336 25 * JDK-8066407: Function with same body not reparsed after SyntaxError
hannesw@1336 26 *
hannesw@1336 27 * @test
hannesw@1336 28 * @run
hannesw@1336 29 */
hannesw@1336 30
hannesw@1336 31 function testFunction(body) {
hannesw@1336 32 try {
hannesw@1336 33 Function(body);
hannesw@1336 34 Assert.fail("Should have thrown");
hannesw@1336 35 } catch (e) {
hannesw@1336 36 Assert.assertEquals(e.name, "SyntaxError");
hannesw@1336 37 count++;
hannesw@1336 38 }
hannesw@1336 39
hannesw@1336 40 }
hannesw@1336 41
hannesw@1336 42 var count = 0;
hannesw@1336 43
hannesw@1336 44 testFunction("/a/r");
hannesw@1336 45 testFunction("/a/r");
hannesw@1336 46 testFunction("/a/r");
hannesw@1336 47
hannesw@1336 48 Assert.assertTrue(count === 3);

mercurial