| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 new Proxy(function(_, that, [x]) { receiver = that; value = x }, {})) | 464 new Proxy(function(_, that, [x]) { receiver = that; value = x }, {})) |
| 465 ) | 465 ) |
| 466 | 466 |
| 467 | 467 |
| 468 // Passing a proxy function to higher-order library functions. | 468 // Passing a proxy function to higher-order library functions. |
| 469 | 469 |
| 470 function TestHigherOrder(f) { | 470 function TestHigherOrder(f) { |
| 471 assertEquals(6, [6, 2].map(f)[0]) | 471 assertEquals(6, [6, 2].map(f)[0]) |
| 472 assertEquals(4, [5, 2].reduce(f, 4)) | 472 assertEquals(4, [5, 2].reduce(f, 4)) |
| 473 assertTrue([1, 2].some(f)) | 473 assertTrue([1, 2].some(f)) |
| 474 assertEquals("a.b.c", "a.b.c".replace(".", f)) | |
| 475 } | 474 } |
| 476 | 475 |
| 477 TestHigherOrder(function(x) { return x }) | 476 TestHigherOrder(function(x) { return x }) |
| 478 TestHigherOrder(function(x) { "use strict"; return x }) | 477 TestHigherOrder(function(x) { "use strict"; return x }) |
| 479 TestHigherOrder(new Proxy(function(x) { return x }, {})) | 478 TestHigherOrder(new Proxy(function(x) { return x }, {})) |
| 480 TestHigherOrder(Object.freeze(new Proxy(function(x) { return x }, {}))) | 479 TestHigherOrder(Object.freeze(new Proxy(function(x) { return x }, {}))) |
| 481 | 480 |
| 482 | 481 |
| 483 | 482 |
| 484 // TODO(rossberg): Ultimately, I want to have the following test function | 483 // TODO(rossberg): Ultimately, I want to have the following test function |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 with (this) { | 620 with (this) { |
| 622 assertEquals(this, fp()); | 621 assertEquals(this, fp()); |
| 623 assertEquals(this, gp()); | 622 assertEquals(this, gp()); |
| 624 } | 623 } |
| 625 | 624 |
| 626 with ({}) { | 625 with ({}) { |
| 627 assertEquals(undefined, fp()); | 626 assertEquals(undefined, fp()); |
| 628 assertEquals(undefined, gp()); | 627 assertEquals(undefined, gp()); |
| 629 } | 628 } |
| 630 } | 629 } |
| OLD | NEW |