test/script/basic/JDK-8035312_2.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 1095
3dbb4c9ff43c
permissions
-rw-r--r--

Merge

lagergren@1095 1 /*
lagergren@1095 2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
lagergren@1095 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
lagergren@1095 4 *
lagergren@1095 5 * This code is free software; you can redistribute it and/or modify it
lagergren@1095 6 * under the terms of the GNU General Public License version 2 only, as
lagergren@1095 7 * published by the Free Software Foundation.
lagergren@1095 8 *
lagergren@1095 9 * This code is distributed in the hope that it will be useful, but WITHOUT
lagergren@1095 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
lagergren@1095 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
lagergren@1095 12 * version 2 for more details (a copy is included in the LICENSE file that
lagergren@1095 13 * accompanied this code).
lagergren@1095 14 *
lagergren@1095 15 * You should have received a copy of the GNU General Public License version
lagergren@1095 16 * 2 along with this work; if not, write to the Free Software Foundation,
lagergren@1095 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
lagergren@1095 18 *
lagergren@1095 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
lagergren@1095 20 * or visit www.oracle.com if you need additional information or have any
lagergren@1095 21 * questions.
lagergren@1095 22 */
lagergren@1095 23
lagergren@1095 24 /**
lagergren@1095 25 * JDK-8035312_2 - length setter and iterators
lagergren@1095 26 *
lagergren@1095 27 * @test
lagergren@1095 28 * @run
lagergren@1095 29 */
lagergren@1095 30
lagergren@1095 31 "use strict"
lagergren@1095 32
lagergren@1095 33 function printArray(a,n) {
lagergren@1095 34 print("PRINT_ARRAY CALLED: length = " + a.length);
lagergren@1095 35 print();
lagergren@1095 36
lagergren@1095 37 print("INDEXED");
lagergren@1095 38 for (var x = 0; x<n; x++) {
lagergren@1095 39 print("\t" + x + ":"+a[x]);
lagergren@1095 40 }
lagergren@1095 41 print("KEYS");
lagergren@1095 42 for (var key in a) {
lagergren@1095 43 print("\t" + key + ";" + a[key]);
lagergren@1095 44 }
lagergren@1095 45 }
lagergren@1095 46
lagergren@1095 47 var b = [1,2,3];
lagergren@1095 48
lagergren@1095 49 Object.defineProperty(b, "length", { writable: false });
lagergren@1095 50 var high = 8;
lagergren@1095 51 b[high] = high;
lagergren@1095 52
lagergren@1095 53 printArray(b, high + 5);
lagergren@1095 54
lagergren@1095 55 var c = [1,2,3];
lagergren@1095 56 c[high] = high;
lagergren@1095 57 print();
lagergren@1095 58 print("element[" + high + "]: " + c.length + " " + c[high]);
lagergren@1095 59 print("Resetting length");
lagergren@1095 60 c.length = 3;
lagergren@1095 61 print("element[" + high + "]: " + c.length + " " + c[high]);
lagergren@1095 62 print();
lagergren@1095 63
lagergren@1095 64 printArray(c, high + 5);
lagergren@1095 65 print();

mercurial