nashorn/test/script/basic/JDK-8062141.js
author hannesw
Fri, 03 Feb 2017 13:28:00 +0100
changeset 43555 1bb10bccf057
parent 28786 679fd2d26470
permissions -rw-r--r--
8173888: Test for JDK-8169481 causes stack overflows in parser tests Reviewed-by: jlaskey, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28786
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     1
/*
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     4
 * 
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     8
 * 
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    13
 * accompanied this code).
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    14
 * 
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    18
 * 
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    21
 * questions.
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    22
 */
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    23
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    24
/**
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    25
 * JDK-8062141: Various performance issues parsing JSON
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    26
 *
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    27
 * @test
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    28
 * @run
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    29
 */
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    30
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    31
function testJson(json) {
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    32
    try {
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    33
        print(JSON.stringify(JSON.parse(json)));
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    34
    } catch (error) {
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    35
        print(error);
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    36
    }
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    37
}
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    38
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    39
testJson('"\\u003f"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    40
testJson('"\\u0"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    41
testJson('"\\u0"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    42
testJson('"\\u00"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    43
testJson('"\\u003"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    44
testJson('"\\u003x"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    45
testJson('"\\"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    46
testJson('"');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    47
testJson('+1');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    48
testJson('-1');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    49
testJson('1.');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    50
testJson('.1');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    51
testJson('01');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    52
testJson('1e');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    53
testJson('1e0');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    54
testJson('1a');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    55
testJson('1e+');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    56
testJson('1e-');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    57
testJson('0.0e+0');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    58
testJson('0.0e-0');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    59
testJson('[]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    60
testJson('[ 1 ]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    61
testJson('[1,]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    62
testJson('[ 1 , 2 ]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    63
testJson('[1, 2');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    64
testJson('{}');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    65
testJson('{ "a" : "b" }');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    66
testJson('{ "a" : "b" ');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    67
testJson('{ "a" : }');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    68
testJson('true');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    69
testJson('tru');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    70
testJson('true1');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    71
testJson('false');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    72
testJson('fals');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    73
testJson('falser');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    74
testJson('null');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    75
testJson('nul');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    76
testJson('null0');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    77
testJson('{} 0');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    78
testJson('{} a');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    79
testJson('[] 0');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    80
testJson('[] a');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    81
testJson('1 0');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    82
testJson('1 a');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    83
testJson('["a":true]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    84
testJson('{"a",truer}');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    85
testJson('{"a":truer}');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    86
testJson('[1, 2, 3]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    87
testJson('[9223372036854774000, 9223372036854775000, 9223372036854776000]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    88
testJson('[1.1, 1.2, 1.3]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    89
testJson('[1, 1.2, 9223372036854776000, null, true]');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    90
testJson('{ "a" : "string" , "b": 1 , "c" : 1.2 , "d" : 9223372036854776000 , "e" : null , "f" : true }');
679fd2d26470 8062141: Various performance issues parsing JSON
hannesw
parents:
diff changeset
    91