test/script/basic/JDK-8061391_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 1071
78eb2b415108
permissions
-rw-r--r--

Merge

lagergren@1071 1 /*
lagergren@1071 2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
lagergren@1071 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
lagergren@1071 4 *
lagergren@1071 5 * This code is free software; you can redistribute it and/or modify it
lagergren@1071 6 * under the terms of the GNU General Public License version 2 only, as
lagergren@1071 7 * published by the Free Software Foundation.
lagergren@1071 8 *
lagergren@1071 9 * This code is distributed in the hope that it will be useful, but WITHOUT
lagergren@1071 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
lagergren@1071 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
lagergren@1071 12 * version 2 for more details (a copy is included in the LICENSE file that
lagergren@1071 13 * accompanied this code).
lagergren@1071 14 *
lagergren@1071 15 * You should have received a copy of the GNU General Public License version
lagergren@1071 16 * 2 along with this work; if not, write to the Free Software Foundation,
lagergren@1071 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
lagergren@1071 18 *
lagergren@1071 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
lagergren@1071 20 * or visit www.oracle.com if you need additional information or have any
lagergren@1071 21 * questions.
lagergren@1071 22 */
lagergren@1071 23
lagergren@1071 24 /**
lagergren@1071 25 * Array extension check
lagergren@1071 26 *
lagergren@1071 27 * @test
lagergren@1071 28 * @run
lagergren@1071 29 */
lagergren@1071 30
lagergren@1071 31 "use strict";
lagergren@1071 32 var a = [1,2,3];
lagergren@1071 33 Object.preventExtensions(a);
lagergren@1071 34 try {
lagergren@1071 35 a[4] = 4;
lagergren@1071 36 print(a);
lagergren@1071 37 } catch (e) {
lagergren@1071 38 if (!(e instanceof TypeError)) {
lagergren@1071 39 print("TypeError expected but got e");
lagergren@1071 40 }
lagergren@1071 41 }
lagergren@1071 42
lagergren@1071 43 if (a[0] != 1) {
lagergren@1071 44 throw "element 0 is wrong";
lagergren@1071 45 }
lagergren@1071 46 if (a[1] != 2) {
lagergren@1071 47 throw "element 1 is wrong";
lagergren@1071 48 }
lagergren@1071 49 if (a[2] != 3) {
lagergren@1071 50 throw "element 2 is wrong";
lagergren@1071 51 }
lagergren@1071 52

mercurial