fastpushpop.js revision 1036:f0b5e3900a10
159191Skris/* 259191Skris * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 359191Skris * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 459191Skris * 559191Skris * This code is free software; you can redistribute it and/or modify it 659191Skris * under the terms of the GNU General Public License version 2 only, as 759191Skris * published by the Free Software Foundation. 859191Skris * 959191Skris * This code is distributed in the hope that it will be useful, but WITHOUT 1059191Skris * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1159191Skris * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1259191Skris * version 2 for more details (a copy is included in the LICENSE file that 1359191Skris * accompanied this code). 1459191Skris * 1559191Skris * You should have received a copy of the GNU General Public License version 1659191Skris * 2 along with this work; if not, write to the Free Software Foundation, 1759191Skris * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1859191Skris * 1959191Skris * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2059191Skris * or visit www.oracle.com if you need additional information or have any 2159191Skris * questions. 2259191Skris */ 2359191Skris 2459191Skris/** 2559191Skris * fastpushpop.js: make sure guards work for fast push implementation 2659191Skris * and normal one 2759191Skris * 2859191Skris * @test 2959191Skris * @run 3059191Skris */ 3159191Skris 3259191Skrisvar a = [1,2,3]; 3359191Skrisa.push(4); 3459191Skrisa.push(5); 3559191Skrisa.push(6); 3659191Skrisprint(a); 3759191Skris 3859191Skrisvar a2 = Object.defineProperty(a,"length", { writable: false }); 39109998Smarkmtry { 4059191Skris a2.push(7); 4159191Skris} catch (e) { 4259191Skris print("first: " + (e instanceof TypeError)); 4359191Skris} 4459191Skris 4559191Skrisprint(a2); 4659191Skris 4759191Skrisvar b = [1,2,3,,,,4711.17,"dingo!"]; 48b.push(4); 49b.push(5); 50b.push(6); 51print(b); 52 53var b2 = Object.defineProperty(b,"length", { writable: false }); 54try { 55 b2.push(7); 56} catch (e) { 57 print("second: " + (e instanceof TypeError)); 58} 59 60print(b2); 61 62