test/script/nosecurity/JDK-8149334.js

Tue, 09 Feb 2016 10:00:02 +0100

author
mhaupt
date
Tue, 09 Feb 2016 10:00:02 +0100
changeset 1739
29603fdf59a8
permissions
-rw-r--r--

8149334: JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
Reviewed-by: jlaskey, sundar

mhaupt@1739 1 /*
mhaupt@1739 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
mhaupt@1739 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mhaupt@1739 4 *
mhaupt@1739 5 * This code is free software; you can redistribute it and/or modify it
mhaupt@1739 6 * under the terms of the GNU General Public License version 2 only, as
mhaupt@1739 7 * published by the Free Software Foundation.
mhaupt@1739 8 *
mhaupt@1739 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mhaupt@1739 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mhaupt@1739 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mhaupt@1739 12 * version 2 for more details (a copy is included in the LICENSE file that
mhaupt@1739 13 * accompanied this code).
mhaupt@1739 14 *
mhaupt@1739 15 * You should have received a copy of the GNU General Public License version
mhaupt@1739 16 * 2 along with this work; if not, write to the Free Software Foundation,
mhaupt@1739 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mhaupt@1739 18 *
mhaupt@1739 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mhaupt@1739 20 * or visit www.oracle.com if you need additional information or have any
mhaupt@1739 21 * questions.
mhaupt@1739 22 */
mhaupt@1739 23
mhaupt@1739 24 /**
mhaupt@1739 25 * JDK-8149334: JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
mhaupt@1739 26 *
mhaupt@1739 27 * @test
mhaupt@1739 28 * @run
mhaupt@1739 29 */
mhaupt@1739 30
mhaupt@1739 31 var a = JSON.parse(JSON.stringify([]))
mhaupt@1739 32 print(a.length)
mhaupt@1739 33 a.push(10)
mhaupt@1739 34 print(a.length)
mhaupt@1739 35 print(a)
mhaupt@1739 36
mhaupt@1739 37 var b = JSON.parse(JSON.stringify([]))
mhaupt@1739 38 print(b.length)
mhaupt@1739 39 b.push('ieps')
mhaupt@1739 40 print(b.length)
mhaupt@1739 41 print(b)

mercurial