JDK-8035312_4.js revision 1101:be3f5ca1edbf
1252602Spjd/*
2252602Spjd * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
3252603Spjd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4252602Spjd *
51553Srgrimes * This code is free software; you can redistribute it and/or modify it
61553Srgrimes * under the terms of the GNU General Public License version 2 only, as
71553Srgrimes * published by the Free Software Foundation.
81553Srgrimes *
91553Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
101553Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111553Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
121553Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
131553Srgrimes * accompanied this code).
141553Srgrimes *
151553Srgrimes * You should have received a copy of the GNU General Public License version
161553Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
171553Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
181553Srgrimes *
191553Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
201553Srgrimes * or visit www.oracle.com if you need additional information or have any
211553Srgrimes * questions.
221553Srgrimes */
231553Srgrimes
241553Srgrimes/**
251553Srgrimes * JDK-8035312_4 - pushes and pops for non writable length
261553Srgrimes *
271553Srgrimes * @test
281553Srgrimes * @run
291553Srgrimes */
301553Srgrimes
311553Srgrimesvar b = [1,2,3];
3230380ScharnierObject.defineProperty(b, "length", { writable: false });
331553Srgrimes
341553Srgrimestry {
351553Srgrimes    b.push(4);
361553Srgrimes} catch (e) {
37117278Scharnier    print("length = " + b.length);
381553Srgrimes    print("i caught an error");
391553Srgrimes}
40117278Scharnierprint(b);
4130380Scharnierprint(b[3]);
421553Srgrimesprint("length = " + b.length);
43117278Scharnier
44117278Scharniervar c = [1,2,3];
45117278ScharnierObject.defineProperty(c, "length", { writable: false });
46312033Sngie
47263234Srwatsonfor (var i = 0; i < 5; i++) {
48312033Sngie    try {
49312033Sngie	c.pop();
501553Srgrimes    } catch (e) {
511553Srgrimes	print("length = " + c.length);
521553Srgrimes	print("I caught an error");
531553Srgrimes	print(c);
54252603Spjd    }
551553Srgrimes}
561553Srgrimes
571553Srgrimesprint(c);
581553Srgrimesprint(c[3]);
591553Srgrimesprint("length = " + b.length);
6070284Siedowse