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