test/script/basic/JDK-8171219.js

Sun, 24 Jun 2018 23:15:05 +0100

author
alitvinov
date
Sun, 24 Jun 2018 23:15:05 +0100
changeset 2351
41ac91662b75
parent 2017
0ebfc2dd5e17
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 2016, 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  */
    24 /**
    25  * JDK-8171219: Missing checks in sparse array shift() implementation
    26  *
    27  * @test
    28  * @run
    29  */
    31 var a = [];
    32 a[1048577] = 1;
    33 a.shift();
    34 a[1] = 2;
    35 a.shift();
    36 var ka = Object.keys(a);
    37 Assert.assertTrue(ka.length === 2);
    38 Assert.assertTrue(ka[0] === '0');
    39 Assert.assertTrue(ka[1] === '1048575');
    40 Assert.assertTrue(a.length === 1048576);
    41 Assert.assertTrue(a[0] === 2);
    42 Assert.assertTrue(a[1048575] = 1);
    44 var b = [];
    45 b[1048577] = 1;
    46 b.unshift(2);
    47 b.shift();
    48 b[1] = 3;
    49 b.shift();
    50 var kb = Object.keys(b);
    51 Assert.assertTrue(kb.length === 2);
    52 Assert.assertTrue(kb[0] === '0');
    53 Assert.assertTrue(kb[1] === '1048576');
    54 Assert.assertTrue(b.length === 1048577);
    55 Assert.assertTrue(b[0] === 3);
    56 Assert.assertTrue(b[1048576] = 1);

mercurial