Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Unified Diff: test/mjsunit/regress/regress-parse-use-strict.js

Issue 27025002: Fix pre-parsing of 'use strict' directive after string literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-parse-use-strict.js
diff --git a/test/mjsunit/regress/regress-crbug-248025.js b/test/mjsunit/regress/regress-parse-use-strict.js
similarity index 71%
copy from test/mjsunit/regress/regress-crbug-248025.js
copy to test/mjsunit/regress/regress-parse-use-strict.js
index c5988595663c9622853e98585ed4a4e9bed089b1..9dd0f4c97c026d74f2c2cc0213eb22d0e2a8a87e 100644
--- a/test/mjsunit/regress/regress-crbug-248025.js
+++ b/test/mjsunit/regress/regress-parse-use-strict.js
@@ -25,16 +25,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-iteration
-
// Filler long enough to trigger lazy parsing.
-var filler = "//" + new Array(1024).join('x');
+var filler = "/*" + new Array(1024).join('x') + "*/";
+
+// Snippet trying to switch to strict mode.
+var strict = '"use strict"; with({}) {}';
+
+// Test switching to strict mode after string literal.
+assertThrows('function f() { "use sanity";' + strict + '}');
+assertThrows('function f() { "use sanity";' + strict + filler + '}');
-// Test that the pre-parser does not crash when the expected contextual
-// keyword as part if a 'for' statement is not and identifier.
-try {
- eval(filler + "\nfunction f() { for (x : y) { } }");
- throw "not reached";
-} catch (e) {
- if (!(e instanceof SyntaxError)) throw e;
-}
+// Test switching to strict mode after function declaration.
+// We must use eval instead of assertDoesNotThrow here to make sure that
+// lazy parsing is triggered. Otherwise the bug won't reproduce.
+eval('function f() { function g() {}' + strict + '}');
+eval('function f() { function g() {}' + strict + filler + '}');
« no previous file with comments | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698