hannesw@2017: /* hannesw@2017: * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. hannesw@2017: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@2017: * hannesw@2017: * This code is free software; you can redistribute it and/or modify it hannesw@2017: * under the terms of the GNU General Public License version 2 only, as hannesw@2017: * published by the Free Software Foundation. hannesw@2017: * hannesw@2017: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@2017: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@2017: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@2017: * version 2 for more details (a copy is included in the LICENSE file that hannesw@2017: * accompanied this code). hannesw@2017: * hannesw@2017: * You should have received a copy of the GNU General Public License version hannesw@2017: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@2017: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@2017: * hannesw@2017: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@2017: * or visit www.oracle.com if you need additional information or have any hannesw@2017: * questions. hannesw@2017: */ hannesw@2017: hannesw@2017: /** hannesw@2017: * JDK-8171219: Missing checks in sparse array shift() implementation hannesw@2017: * hannesw@2017: * @test hannesw@2017: * @run hannesw@2017: */ hannesw@2017: hannesw@2017: var a = []; hannesw@2017: a[1048577] = 1; hannesw@2017: a.shift(); hannesw@2017: a[1] = 2; hannesw@2017: a.shift(); hannesw@2017: var ka = Object.keys(a); hannesw@2017: Assert.assertTrue(ka.length === 2); hannesw@2017: Assert.assertTrue(ka[0] === '0'); hannesw@2017: Assert.assertTrue(ka[1] === '1048575'); hannesw@2017: Assert.assertTrue(a.length === 1048576); hannesw@2017: Assert.assertTrue(a[0] === 2); hannesw@2017: Assert.assertTrue(a[1048575] = 1); hannesw@2017: hannesw@2017: var b = []; hannesw@2017: b[1048577] = 1; hannesw@2017: b.unshift(2); hannesw@2017: b.shift(); hannesw@2017: b[1] = 3; hannesw@2017: b.shift(); hannesw@2017: var kb = Object.keys(b); hannesw@2017: Assert.assertTrue(kb.length === 2); hannesw@2017: Assert.assertTrue(kb[0] === '0'); hannesw@2017: Assert.assertTrue(kb[1] === '1048576'); hannesw@2017: Assert.assertTrue(b.length === 1048577); hannesw@2017: Assert.assertTrue(b[0] === 3); hannesw@2017: Assert.assertTrue(b[1048576] = 1); hannesw@2017: