test/script/basic/JDK-8062141.js

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

author
hannesw
date
Wed, 03 Jun 2015 18:08:57 +0200
changeset 1396
d5a9705a27b1
parent 1228
3f7e205c2c44
permissions
-rw-r--r--

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

     1 /*
     2  * Copyright (c) 2015, 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  */
    24 /**
    25  * JDK-8062141: Various performance issues parsing JSON
    26  *
    27  * @test
    28  * @run
    29  */
    31 function testJson(json) {
    32     try {
    33         print(JSON.stringify(JSON.parse(json)));
    34     } catch (error) {
    35         print(error);
    36     }
    37 }
    39 testJson('"\\u003f"');
    40 testJson('"\\u0"');
    41 testJson('"\\u0"');
    42 testJson('"\\u00"');
    43 testJson('"\\u003"');
    44 testJson('"\\u003x"');
    45 testJson('"\\"');
    46 testJson('"');
    47 testJson('+1');
    48 testJson('-1');
    49 testJson('1.');
    50 testJson('.1');
    51 testJson('01');
    52 testJson('1e');
    53 testJson('1e0');
    54 testJson('1a');
    55 testJson('1e+');
    56 testJson('1e-');
    57 testJson('0.0e+0');
    58 testJson('0.0e-0');
    59 testJson('[]');
    60 testJson('[ 1 ]');
    61 testJson('[1,]');
    62 testJson('[ 1 , 2 ]');
    63 testJson('[1, 2');
    64 testJson('{}');
    65 testJson('{ "a" : "b" }');
    66 testJson('{ "a" : "b" ');
    67 testJson('{ "a" : }');
    68 testJson('true');
    69 testJson('tru');
    70 testJson('true1');
    71 testJson('false');
    72 testJson('fals');
    73 testJson('falser');
    74 testJson('null');
    75 testJson('nul');
    76 testJson('null0');
    77 testJson('{} 0');
    78 testJson('{} a');
    79 testJson('[] 0');
    80 testJson('[] a');
    81 testJson('1 0');
    82 testJson('1 a');
    83 testJson('["a":true]');
    84 testJson('{"a",truer}');
    85 testJson('{"a":truer}');
    86 testJson('[1, 2, 3]');
    87 testJson('[9223372036854774000, 9223372036854775000, 9223372036854776000]');
    88 testJson('[1.1, 1.2, 1.3]');
    89 testJson('[1, 1.2, 9223372036854776000, null, true]');
    90 testJson('{ "a" : "string" , "b": 1 , "c" : 1.2 , "d" : 9223372036854776000 , "e" : null , "f" : true }');

mercurial