OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 function func(expected, a0, a1, a2) { | 224 function func(expected, a0, a1, a2) { |
225 assertEquals(expected, Array.prototype.slice.call(arguments, 1)); | 225 assertEquals(expected, Array.prototype.slice.call(arguments, 1)); |
226 } | 226 } |
227 | 227 |
228 func([]); | 228 func([]); |
229 func(['a'], 'a'); | 229 func(['a'], 'a'); |
230 func(['a', 1], 'a', 1); | 230 func(['a', 1], 'a', 1); |
231 func(['a', 1, undefined], 'a', 1, undefined); | 231 func(['a', 1, undefined], 'a', 1, undefined); |
232 func(['a', 1, undefined, void(0)], 'a', 1, undefined, void(0)); | 232 func(['a', 1, undefined, void(0)], 'a', 1, undefined, void(0)); |
233 })(); | 233 })(); |
| 234 |
| 235 // Check slicing on arguments object when missing arguments get assigined. |
| 236 (function() { |
| 237 function func(x, y) { |
| 238 assertEquals(1, arguments.length); |
| 239 assertEquals(undefined, y); |
| 240 y = 239; |
| 241 assertEquals(1, arguments.length); // arguments length is the same. |
| 242 assertEquals([x], Array.prototype.slice.call(arguments, 0)); |
| 243 } |
| 244 |
| 245 func('a'); |
| 246 })(); |
| 247 |
| 248 // Check slicing on arguments object when length property has been set. |
| 249 (function() { |
| 250 function func(x, y) { |
| 251 assertEquals(1, arguments.length); |
| 252 arguments.length = 7; |
| 253 assertEquals([x,,,,,,,], Array.prototype.slice.call(arguments, 0)); |
| 254 } |
| 255 |
| 256 func('a'); |
| 257 })(); |
| 258 |
| 259 // Check slicing on arguments object when length property has been set to |
| 260 // some strange value. |
| 261 (function() { |
| 262 function func(x, y) { |
| 263 assertEquals(1, arguments.length); |
| 264 arguments.length = 'foobar'; |
| 265 assertEquals([], Array.prototype.slice.call(arguments, 0)); |
| 266 } |
| 267 |
| 268 func('a'); |
| 269 })(); |
| 270 |
| 271 // Check slicing on arguments object when extra argument has been added |
| 272 // via indexed assignment. |
| 273 (function() { |
| 274 function func(x, y) { |
| 275 assertEquals(1, arguments.length); |
| 276 arguments[3] = 239; |
| 277 assertEquals([x], Array.prototype.slice.call(arguments, 0)); |
| 278 } |
| 279 |
| 280 func('a'); |
| 281 })(); |
| 282 |
| 283 // Check slicing on arguments object when argument has been deleted by index. |
| 284 (function() { |
| 285 function func(x, y, z) { |
| 286 assertEquals(3, arguments.length); |
| 287 delete arguments[1]; |
| 288 assertEquals([x,,z], Array.prototype.slice.call(arguments, 0)); |
| 289 } |
| 290 |
| 291 func('a', 'b', 'c'); |
| 292 })(); |
OLD | NEW |