apply_to_call2.js revision 837:ddda121eca56
11573Srgrimes/*
21573Srgrimes * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
31573Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41573Srgrimes *
51573Srgrimes * This code is free software; you can redistribute it and/or modify it
61573Srgrimes * under the terms of the GNU General Public License version 2 only, as
71573Srgrimes * published by the Free Software Foundation.
81573Srgrimes *
91573Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
101573Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111573Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
121573Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
131573Srgrimes * accompanied this code).
141573Srgrimes *
151573Srgrimes * You should have received a copy of the GNU General Public License version
161573Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
171573Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
181573Srgrimes *
191573Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
201573Srgrimes * or visit www.oracle.com if you need additional information or have any
211573Srgrimes * questions.
221573Srgrimes */
231573Srgrimes
241573Srgrimes/**
251573Srgrimes * apply_to_call2.js - do one apply to call specialization, then override call and make sure it reverts (i.e. stops
261573Srgrimes * calling call)
271573Srgrimes *
281573Srgrimes * @test
291573Srgrimes * @run
301573Srgrimes */
311573Srgrimes
321573Srgrimesprint("start");
331573Srgrimes
341573Srgrimesvar x = {
3584260Sobrien    a : 0,
3684260Sobrien    b : 0,
371573Srgrimes    c : 0,
381573Srgrimes    initialize : function(x,y,z) {
391573Srgrimes	this.a = x;
401573Srgrimes	this.b = y;
411573Srgrimes	this.c = z;
4284260Sobrien    }
4384260Sobrien};
441573Srgrimes
451573Srgrimesfunction test() {
461573Srgrimes    x.initialize.apply(x, arguments);
471573Srgrimes}
481573Srgrimes
491573Srgrimestest(4711,23,17);
501573Srgrimesprint(x.a);
511573Srgrimesprint(x.b);
521573Srgrimesprint(x.c);
531573Srgrimes
541573Srgrimesprint("Overwriting call now");
551573Srgrimes
5684260SobrienFunction.prototype.call = function() {
5784260Sobrien    throw "this should never be thrown - test should revert to builtin apply";
5884260Sobrien};
5984260Sobrien
6084260Sobrientest(1,2,3);
611573Srgrimesprint(x.a);
621573Srgrimesprint(x.b);
6384260Sobrienprint(x.c);
641573Srgrimes