OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 assertThrows(function() { delete_element(object, "1"); }, TypeError); | 429 assertThrows(function() { delete_element(object, "1"); }, TypeError); |
430 assertThrows(function() { delete_element(object, 1); }, TypeError); | 430 assertThrows(function() { delete_element(object, 1); }, TypeError); |
431 assertEquals(object[1], "one"); | 431 assertEquals(object[1], "one"); |
432 assertThrows(function() { delete_element(object, "7"); }, TypeError); | 432 assertThrows(function() { delete_element(object, "7"); }, TypeError); |
433 assertThrows(function() { delete_element(object, 7); }, TypeError); | 433 assertThrows(function() { delete_element(object, 7); }, TypeError); |
434 assertEquals(object[7], "seven"); | 434 assertEquals(object[7], "seven"); |
435 assertThrows(function() { delete_element(object, "3.14"); }, TypeError); | 435 assertThrows(function() { delete_element(object, "3.14"); }, TypeError); |
436 assertThrows(function() { delete_element(object, 3.14); }, TypeError); | 436 assertThrows(function() { delete_element(object, 3.14); }, TypeError); |
437 assertEquals(object[3.14], "pi"); | 437 assertEquals(object[3.14], "pi"); |
438 })(); | 438 })(); |
| 439 |
| 440 // Not transforming this in Function.call and Function.apply. |
| 441 (function testThisTransform() { |
| 442 function non_strict() { |
| 443 return this; |
| 444 } |
| 445 function strict() { |
| 446 "use strict"; |
| 447 return this; |
| 448 } |
| 449 |
| 450 var global_object = (function() { return this; })(); |
| 451 var object = {}; |
| 452 |
| 453 // Non-strict call. |
| 454 assertTrue(non_strict.call(null) === global_object); |
| 455 assertTrue(non_strict.call(undefined) === global_object); |
| 456 assertEquals(typeof non_strict.call(7), "object"); |
| 457 assertEquals(typeof non_strict.call("Hello"), "object"); |
| 458 assertTrue(non_strict.call(object) === object); |
| 459 |
| 460 // Non-strict apply. |
| 461 assertTrue(non_strict.apply(null) === global_object); |
| 462 assertTrue(non_strict.apply(undefined) === global_object); |
| 463 assertEquals(typeof non_strict.apply(7), "object"); |
| 464 assertEquals(typeof non_strict.apply("Hello"), "object"); |
| 465 assertTrue(non_strict.apply(object) === object); |
| 466 |
| 467 // Strict call. |
| 468 assertTrue(strict.call(null) === null); |
| 469 assertTrue(strict.call(undefined) === undefined); |
| 470 assertEquals(typeof strict.call(7), "number"); |
| 471 assertEquals(typeof strict.call("Hello"), "string"); |
| 472 assertTrue(strict.call(object) === object); |
| 473 |
| 474 // Strict apply. |
| 475 assertTrue(strict.apply(null) === null); |
| 476 assertTrue(strict.apply(undefined) === undefined); |
| 477 assertEquals(typeof strict.apply(7), "number"); |
| 478 assertEquals(typeof strict.apply("Hello"), "string"); |
| 479 assertTrue(strict.apply(object) === object); |
| 480 })(); |
OLD | NEW |