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