| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 assertDoesNotThrow("(function(arg){ 'use strict'; " + str + "})()"); | 61 assertDoesNotThrow("(function(arg){ 'use strict'; " + str + "})()"); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Test let declarations in statement positions. | 64 // Test let declarations in statement positions. |
| 65 TestLocalThrows("if (true) let x;", SyntaxError); | 65 TestLocalThrows("if (true) let x;", SyntaxError); |
| 66 TestLocalThrows("if (true) {} else let x;", SyntaxError); | 66 TestLocalThrows("if (true) {} else let x;", SyntaxError); |
| 67 TestLocalThrows("do let x; while (false)", SyntaxError); | 67 TestLocalThrows("do let x; while (false)", SyntaxError); |
| 68 TestLocalThrows("while (false) let x;", SyntaxError); | 68 TestLocalThrows("while (false) let x;", SyntaxError); |
| 69 TestLocalThrows("label: let x;", SyntaxError); | 69 TestLocalThrows("label: let x;", SyntaxError); |
| 70 TestLocalThrows("for (;false;) let x;", SyntaxError); | 70 TestLocalThrows("for (;false;) let x;", SyntaxError); |
| 71 TestLocalThrows("switch (true) { case true: let x; }", SyntaxError); | 71 TestLocalDoesNotThrow("switch (true) { case true: let x; }"); |
| 72 TestLocalThrows("switch (true) { default: let x; }", SyntaxError); | 72 TestLocalDoesNotThrow("switch (true) { default: let x; }"); |
| 73 | 73 |
| 74 // Test const declarations with initialisers in statement positions. | 74 // Test const declarations with initialisers in statement positions. |
| 75 TestLocalThrows("if (true) const x = 1;", SyntaxError); | 75 TestLocalThrows("if (true) const x = 1;", SyntaxError); |
| 76 TestLocalThrows("if (true) {} else const x = 1;", SyntaxError); | 76 TestLocalThrows("if (true) {} else const x = 1;", SyntaxError); |
| 77 TestLocalThrows("do const x = 1; while (false)", SyntaxError); | 77 TestLocalThrows("do const x = 1; while (false)", SyntaxError); |
| 78 TestLocalThrows("while (false) const x = 1;", SyntaxError); | 78 TestLocalThrows("while (false) const x = 1;", SyntaxError); |
| 79 TestLocalThrows("label: const x = 1;", SyntaxError); | 79 TestLocalThrows("label: const x = 1;", SyntaxError); |
| 80 TestLocalThrows("for (;false;) const x = 1;", SyntaxError); | 80 TestLocalThrows("for (;false;) const x = 1;", SyntaxError); |
| 81 TestLocalThrows("switch (true) { case true: const x = 1; }", SyntaxError); | 81 TestLocalDoesNotThrow("switch (true) { case true: const x = 1; }"); |
| 82 TestLocalThrows("switch (true) { default: const x = 1; }", SyntaxError); | 82 TestLocalDoesNotThrow("switch (true) { default: const x = 1; }"); |
| 83 | 83 |
| 84 // Test const declarations without initialisers. | 84 // Test const declarations without initialisers. |
| 85 TestLocalThrows("const x;", SyntaxError); | 85 TestLocalThrows("const x;", SyntaxError); |
| 86 TestLocalThrows("const x = 1, y;", SyntaxError); | 86 TestLocalThrows("const x = 1, y;", SyntaxError); |
| 87 TestLocalThrows("const x, y = 1;", SyntaxError); | 87 TestLocalThrows("const x, y = 1;", SyntaxError); |
| 88 | 88 |
| 89 // Test const declarations without initialisers in statement positions. | 89 // Test const declarations without initialisers in statement positions. |
| 90 TestLocalThrows("if (true) const x;", SyntaxError); | 90 TestLocalThrows("if (true) const x;", SyntaxError); |
| 91 TestLocalThrows("if (true) {} else const x;", SyntaxError); | 91 TestLocalThrows("if (true) {} else const x;", SyntaxError); |
| 92 TestLocalThrows("do const x; while (false)", SyntaxError); | 92 TestLocalThrows("do const x; while (false)", SyntaxError); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 function h1() { } | 140 function h1() { } |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 { | 143 { |
| 144 function g1() { } | 144 function g1() { } |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 f(); | 147 f(); |
| 148 | 148 |
| 149 // Test function declarations in statement position in strict mode. | 149 // Test function declarations in statement position in strict mode. |
| 150 TestLocalThrows("function f() { if (true) function g() {}", SyntaxError); | 150 TestLocalThrows("function f() { if (true) function g() {} }", SyntaxError); |
| 151 TestLocalThrows("function f() { if (true) {} else function g() {}", SyntaxError)
; | 151 TestLocalThrows("function f() { if (true) {} else function g() {} }", SyntaxErro
r); |
| 152 TestLocalThrows("function f() { do function g() {} while (false)", SyntaxError); | 152 TestLocalThrows("function f() { do function g() {} while (false) }", SyntaxError
); |
| 153 TestLocalThrows("function f() { while (false) function g() {}", SyntaxError); | 153 TestLocalThrows("function f() { while (false) function g() {} }", SyntaxError); |
| 154 TestLocalThrows("function f() { label: function g() {}", SyntaxError); | 154 TestLocalThrows("function f() { label: function g() {} }", SyntaxError); |
| 155 TestLocalThrows("function f() { for (;false;) function g() {}", SyntaxError); | 155 TestLocalThrows("function f() { for (;false;) function g() {} }", SyntaxError); |
| 156 TestLocalThrows("function f() { switch (true) { case true: function g() {} }", S
yntaxError); | 156 TestLocalDoesNotThrow("function f() { switch (true) { case true: function g() {}
} }"); |
| 157 TestLocalThrows("function f() { switch (true) { default: function g() {} }", Syn
taxError); | 157 TestLocalDoesNotThrow("function f() { switch (true) { default: function g() {} }
}"); |
| OLD | NEW |