apply_to_call2.js revision 877:cf4d2252d444
1112158Sdas/*
2112158Sdas * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
3112158Sdas * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4112158Sdas *
5112158Sdas * This code is free software; you can redistribute it and/or modify it
6112158Sdas * under the terms of the GNU General Public License version 2 only, as
7112158Sdas * published by the Free Software Foundation.
8112158Sdas *
9112158Sdas * This code is distributed in the hope that it will be useful, but WITHOUT
10112158Sdas * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11112158Sdas * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12112158Sdas * version 2 for more details (a copy is included in the LICENSE file that
13112158Sdas * accompanied this code).
14112158Sdas *
15112158Sdas * You should have received a copy of the GNU General Public License version
16112158Sdas * 2 along with this work; if not, write to the Free Software Foundation,
17112158Sdas * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18112158Sdas *
19112158Sdas * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20112158Sdas * or visit www.oracle.com if you need additional information or have any
21112158Sdas * questions.
22112158Sdas */
23112158Sdas
24112158Sdas/**
25112158Sdas * apply_to_call2.js - do one apply to call specialization, then override call and make sure it reverts (i.e. stops
26112158Sdas * calling call)
27112158Sdas *
28112158Sdas * @test
29165743Sdas * @run
30165743Sdas */
31112158Sdas
32112158Sdasprint("start");
33112158Sdas
34112158Sdasvar x = {
35112158Sdas    a : 0,
36112158Sdas    b : 0,
37112158Sdas    c : 0,
38112158Sdas    initialize : function(x,y,z) {
39112158Sdas    this.a = x;
40112158Sdas    this.b = y;
41112158Sdas    this.c = z;
42112158Sdas    }
43112158Sdas};
44112158Sdas
45112158Sdasfunction test() {
46112158Sdas    x.initialize.apply(x, arguments);
47112158Sdas}
48112158Sdas
49112158Sdastest(4711,23,17);
50112158Sdasprint(x.a);
51112158Sdasprint(x.b);
52112158Sdasprint(x.c);
53112158Sdas
54187808Sdasprint("Overwriting call now");
55112158Sdas
56187808SdasFunction.prototype.call = function() {
57112158Sdas    throw "this should never be thrown - test should revert to builtin apply";
58112158Sdas};
59187808Sdas
60112158Sdastest(1,2,3);
61112158Sdasprint(x.a);
62112158Sdasprint(x.b);
63187808Sdasprint(x.c);
64187808Sdas