test/script/basic/JDK-8019508.js

Wed, 03 Jun 2015 18:08:57 +0200

author
hannesw
date
Wed, 03 Jun 2015 18:08:57 +0200
changeset 1396
d5a9705a27b1
parent 962
ac62e33a99b0
child 1205
4112748288bb
permissions
-rw-r--r--

8066237: Fuzzing bug: Parser error on optimistic recompilation
Reviewed-by: lagergren, attila

sundar@391 1 /*
sundar@391 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
sundar@391 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
attila@962 4 *
sundar@391 5 * This code is free software; you can redistribute it and/or modify it
sundar@391 6 * under the terms of the GNU General Public License version 2 only, as
sundar@391 7 * published by the Free Software Foundation.
attila@962 8 *
sundar@391 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sundar@391 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sundar@391 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sundar@391 12 * version 2 for more details (a copy is included in the LICENSE file that
sundar@391 13 * accompanied this code).
attila@962 14 *
sundar@391 15 * You should have received a copy of the GNU General Public License version
sundar@391 16 * 2 along with this work; if not, write to the Free Software Foundation,
sundar@391 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
attila@962 18 *
sundar@391 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sundar@391 20 * or visit www.oracle.com if you need additional information or have any
sundar@391 21 * questions.
sundar@391 22 */
sundar@391 23
sundar@391 24 /**
sundar@391 25 * JDK-8019508: Comma handling in object literal parsing is wrong
sundar@391 26 *
sundar@391 27 * @test
sundar@391 28 * @run
sundar@391 29 */
sundar@391 30
sundar@391 31 function checkObjLiteral(str) {
sundar@391 32 try {
sundar@391 33 eval(str);
sundar@391 34 fail("SyntaxError expected for: " + str);
sundar@391 35 } catch (e) {
sundar@391 36 if (! (e instanceof SyntaxError)) {
sundar@391 37 fail("expected SyntaxError, got " + e);
sundar@391 38 }
sundar@606 39 printError(e);
sundar@391 40 }
sundar@391 41 }
sundar@391 42
sundar@391 43 // only comma
sundar@391 44 checkObjLiteral("({,})");
sundar@391 45
sundar@391 46 // starting with comma
sundar@391 47 checkObjLiteral("({, a:2 })");
sundar@391 48
sundar@391 49 // consecutive commas
sundar@391 50 checkObjLiteral("({a:3,,})");
sundar@391 51
sundar@391 52 // missing comma
sundar@391 53 checkObjLiteral("({a:3 b:2}");
sundar@391 54
sundar@391 55 // single trailing comma is okay!
sundar@391 56 var obj = { a: 3, };

mercurial