| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 assertEquals(3, g2()); | 121 assertEquals(3, g2()); |
| 122 assertEquals(3, eval("g2()")); | 122 assertEquals(3, eval("g2()")); |
| 123 // function scoped function declaration | 123 // function scoped function declaration |
| 124 function g2() { | 124 function g2() { |
| 125 return 3; | 125 return 3; |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 f(); | 128 f(); |
| 129 | 129 |
| 130 // Test that a function declaration introduces a block scoped variable. | 130 // Test that a function declaration introduces a block scoped variable |
| 131 TestAll('{ function k() { return 0; } }; k(); '); | 131 // and no function hoisting if there is a conflict. |
| 132 TestFunctionLocal('{ function k() { return 0; } }; k(); let k;'); |
| 132 | 133 |
| 133 // Test that a function declaration sees the scope it resides in. | 134 // Test that a function declaration sees the scope it resides in. |
| 134 function f2() { | 135 function f2() { |
| 135 let m, n, o, p; | 136 let m, n, o, p; |
| 136 { | 137 { |
| 137 m = g; | 138 m = g; |
| 138 function g() { | 139 function g() { |
| 139 return a; | 140 return a; |
| 140 } | 141 } |
| 141 let a = 1; | 142 let a = 1; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 184 } |
| 184 eval("1 + 1"); | 185 eval("1 + 1"); |
| 185 return x + inner(); | 186 return x + inner(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 let x = 1; | 189 let x = 1; |
| 189 return middle(); | 190 return middle(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 assertEquals(2, outer()); | 193 assertEquals(2, outer()); |
| OLD | NEW |