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