Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / v8 / test / mjsunit / argument-assigned.js
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 //     * Redistributions of source code must retain the above copyright
7 //       notice, this list of conditions and the following disclaimer.
8 //     * Redistributions in binary form must reproduce the above
9 //       copyright notice, this list of conditions and the following
10 //       disclaimer in the documentation and/or other materials provided
11 //       with the distribution.
12 //     * Neither the name of Google Inc. nor the names of its
13 //       contributors may be used to endorse or promote products derived
14 //       from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 (function() {
29   function f(x) {
30     var arguments = [ 1, 2, 3 ];
31     return x;
32   }
33   assertEquals(7, f(7));
34 })();
35
36
37 (function() {
38   function f(x) {
39     arguments[0] = 991;
40     var arguments = [ 1, 2, 3 ];
41     return x;
42   }
43   assertEquals(991, f(7));
44 })();
45
46
47 (function() {
48   function f(x) {
49     arguments[0] = 991;
50     for (var i = 0; i < 10; i++) {
51       if (i == 5) {
52         var arguments = [ 1, 2, 3 ];
53       }
54     }
55     return x;
56   }
57   assertEquals(991, f(7));
58 })();
59
60
61 (function() {
62   function f(x, s) {
63     eval(s);
64     return x;
65   }
66   assertEquals(7, f(7, "var arguments = [ 1, 2, 3 ];"));
67 })();
68
69
70 (function() {
71   function f(x, s) {
72     var tmp = arguments[0];
73     eval(s);
74     return tmp;
75   }
76   assertEquals(7, f(7, "var arguments = [ 1, 2, 3 ];"));
77 })();
78
79
80 (function() {
81   function f(x, s) {
82     var tmp = arguments[0];
83     eval(s);
84     return tmp;
85   }
86   assertEquals(7, f(7, ""));
87 })();
88
89
90 (function() {
91   function f(x, s) {
92     var tmp = arguments[0];
93     eval(s);
94     return x;
95   }
96   assertEquals(7, f(7, "var arguments = [ 1, 2, 3 ];"));
97 })();
98
99
100 (function() {
101   function f(x, s) {
102     var tmp = arguments[0];
103     eval(s);
104     return x;
105   }
106   assertEquals(7, f(7, ""));
107 })();
108
109
110 (function() {
111   function f(x) {
112     function g(y) {
113       x = y;
114     }
115     arguments = {};
116     g(991);
117     return x;
118   }
119   assertEquals(991, f(7));
120 })();
121
122
123 (function() {
124   function f(x) {
125     function g(y, s) {
126       eval(s);
127     }
128     arguments = {};
129     g(991, "x = y;");
130     return x;
131   }
132   assertEquals(991, f(7));
133 })();