test/script/basic/fastpushpop.js

Thu, 25 Sep 2014 15:53:47 +0200

author
lagergren
date
Thu, 25 Sep 2014 15:53:47 +0200
changeset 1028
d79265f2fa92
permissions
-rw-r--r--

8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
Reviewed-by: hannesw, attila, sundar

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

mercurial