| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return "(function constvar() { " + use + "; })();"; | 86 return "(function constvar() { " + use + "; })();"; |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 // Function expression name, assign from eval. | 90 // Function expression name, assign from eval. |
| 91 function constDecl9(use) { | 91 function constDecl9(use) { |
| 92 use = "eval('(function(){" + use + "})')()"; | 92 use = "eval('(function(){" + use + "})')()"; |
| 93 return "(function constvar() { " + use + "; })();"; | 93 return "(function constvar() { " + use + "; })();"; |
| 94 } | 94 } |
| 95 | 95 |
| 96 // For loop variable. |
| 97 function constDecl10(use) { |
| 98 return "(function() { for (const constvar = 0; ;) { " + use + "; } })();"; |
| 99 } |
| 100 |
| 101 // For-in loop variable. |
| 102 function constDecl11(use) { |
| 103 return "(function() { for (const constvar in {a: 1}) { " + use + "; } })();"; |
| 104 } |
| 105 |
| 106 // For-of loop variable. |
| 107 function constDecl12(use) { |
| 108 return "(function() { for (const constvar of [1]) { " + use + "; } })();"; |
| 109 } |
| 110 |
| 111 |
| 96 let decls = [ constDecl0, | 112 let decls = [ constDecl0, |
| 97 constDecl1, | 113 constDecl1, |
| 98 constDecl2, | 114 constDecl2, |
| 99 constDecl3, | 115 constDecl3, |
| 100 constDecl4, | 116 constDecl4, |
| 101 constDecl5, | 117 constDecl5, |
| 102 constDecl6, | 118 constDecl6, |
| 103 constDecl7, | 119 constDecl7, |
| 104 constDecl8, | 120 constDecl8, |
| 105 constDecl9 | 121 constDecl9, |
| 122 constDecl10, |
| 123 constDecl11, |
| 124 constDecl12 |
| 106 ]; | 125 ]; |
| 107 let declsForTDZ = new Set([constDecl1, constDecl3, constDecl5, constDecl7]); | 126 let declsForTDZ = new Set([constDecl1, constDecl3, constDecl5, constDecl7]); |
| 108 let uses = [ 'constvar = 1;', | 127 let uses = [ 'constvar = 1;', |
| 109 'constvar += 1;', | 128 'constvar += 1;', |
| 110 '++constvar;', | 129 '++constvar;', |
| 111 'constvar++;' | 130 'constvar++;' |
| 112 ]; | 131 ]; |
| 113 | 132 |
| 114 function Test(d,u) { | 133 function Test(d,u) { |
| 115 'use strict'; | 134 'use strict'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 128 return; | 147 return; |
| 129 } | 148 } |
| 130 assertUnreachable(); | 149 assertUnreachable(); |
| 131 } | 150 } |
| 132 | 151 |
| 133 for (var d = 0; d < decls.length; ++d) { | 152 for (var d = 0; d < decls.length; ++d) { |
| 134 for (var u = 0; u < uses.length; ++u) { | 153 for (var u = 0; u < uses.length; ++u) { |
| 135 Test(decls[d], uses[u]); | 154 Test(decls[d], uses[u]); |
| 136 } | 155 } |
| 137 } | 156 } |
| OLD | NEW |