Fri, 14 Jul 2017 14:30:06 -0700
Merge
hannesw@2017 | 1 | /* |
hannesw@2017 | 2 | * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
hannesw@2017 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
hannesw@2017 | 4 | * |
hannesw@2017 | 5 | * This code is free software; you can redistribute it and/or modify it |
hannesw@2017 | 6 | * under the terms of the GNU General Public License version 2 only, as |
hannesw@2017 | 7 | * published by the Free Software Foundation. |
hannesw@2017 | 8 | * |
hannesw@2017 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
hannesw@2017 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
hannesw@2017 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
hannesw@2017 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
hannesw@2017 | 13 | * accompanied this code). |
hannesw@2017 | 14 | * |
hannesw@2017 | 15 | * You should have received a copy of the GNU General Public License version |
hannesw@2017 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
hannesw@2017 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
hannesw@2017 | 18 | * |
hannesw@2017 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
hannesw@2017 | 20 | * or visit www.oracle.com if you need additional information or have any |
hannesw@2017 | 21 | * questions. |
hannesw@2017 | 22 | */ |
hannesw@2017 | 23 | |
hannesw@2017 | 24 | /** |
hannesw@2017 | 25 | * JDK-8171219: Missing checks in sparse array shift() implementation |
hannesw@2017 | 26 | * |
hannesw@2017 | 27 | * @test |
hannesw@2017 | 28 | * @run |
hannesw@2017 | 29 | */ |
hannesw@2017 | 30 | |
hannesw@2017 | 31 | var a = []; |
hannesw@2017 | 32 | a[1048577] = 1; |
hannesw@2017 | 33 | a.shift(); |
hannesw@2017 | 34 | a[1] = 2; |
hannesw@2017 | 35 | a.shift(); |
hannesw@2017 | 36 | var ka = Object.keys(a); |
hannesw@2017 | 37 | Assert.assertTrue(ka.length === 2); |
hannesw@2017 | 38 | Assert.assertTrue(ka[0] === '0'); |
hannesw@2017 | 39 | Assert.assertTrue(ka[1] === '1048575'); |
hannesw@2017 | 40 | Assert.assertTrue(a.length === 1048576); |
hannesw@2017 | 41 | Assert.assertTrue(a[0] === 2); |
hannesw@2017 | 42 | Assert.assertTrue(a[1048575] = 1); |
hannesw@2017 | 43 | |
hannesw@2017 | 44 | var b = []; |
hannesw@2017 | 45 | b[1048577] = 1; |
hannesw@2017 | 46 | b.unshift(2); |
hannesw@2017 | 47 | b.shift(); |
hannesw@2017 | 48 | b[1] = 3; |
hannesw@2017 | 49 | b.shift(); |
hannesw@2017 | 50 | var kb = Object.keys(b); |
hannesw@2017 | 51 | Assert.assertTrue(kb.length === 2); |
hannesw@2017 | 52 | Assert.assertTrue(kb[0] === '0'); |
hannesw@2017 | 53 | Assert.assertTrue(kb[1] === '1048576'); |
hannesw@2017 | 54 | Assert.assertTrue(b.length === 1048577); |
hannesw@2017 | 55 | Assert.assertTrue(b[0] === 3); |
hannesw@2017 | 56 | Assert.assertTrue(b[1048576] = 1); |
hannesw@2017 | 57 |