| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Tests loading of properties across eval calls. | 28 // Tests loading of properties across eval calls. |
| 29 | 29 |
| 30 var x = 1; | 30 var x = 1; |
| 31 function global_function() { return 'global'; } | 31 function global_function() { return 'global'; } |
| 32 const const_uninitialized; | 32 const const_uninitialized; |
| 33 const const_initialized = function() { return "const_global"; } | 33 const const_initialized = function() { return "const_global"; }; |
| 34 | 34 |
| 35 // Test loading across an eval call that does not shadow variables. | 35 // Test loading across an eval call that does not shadow variables. |
| 36 function testNoShadowing() { | 36 function testNoShadowing() { |
| 37 var y = 2; | 37 var y = 2; |
| 38 function local_function() { return 'local'; } | 38 function local_function() { return 'local'; } |
| 39 const local_const_uninitialized; | 39 const local_const_uninitialized; |
| 40 const local_const_initialized = function() { return "const_local"; } | 40 const local_const_initialized = function() { return "const_local"; }; |
| 41 function f() { | 41 function f() { |
| 42 eval('1'); | 42 eval('1'); |
| 43 assertEquals(1, x); | 43 assertEquals(1, x); |
| 44 try { typeof(asdf); } catch(e) { assertUnreachable(); } | 44 try { typeof(asdf); } catch(e) { assertUnreachable(); } |
| 45 assertEquals(2, y); | 45 assertEquals(2, y); |
| 46 assertEquals('global', global_function()); | 46 assertEquals('global', global_function()); |
| 47 assertEquals('local', local_function()); | 47 assertEquals('local', local_function()); |
| 48 var exception = false; | 48 var exception = false; |
| 49 try { | 49 try { |
| 50 const_uninitialized(); | 50 const_uninitialized(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 assertEquals(4, y); | 132 assertEquals(4, y); |
| 133 assertEquals('new_nonglobal', global_function()); | 133 assertEquals('new_nonglobal', global_function()); |
| 134 assertEquals('new_local', local_function()); | 134 assertEquals('new_local', local_function()); |
| 135 } | 135 } |
| 136 g(); | 136 g(); |
| 137 } | 137 } |
| 138 f(); | 138 f(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 testShadowing(); | 141 testShadowing(); |
| OLD | NEW |