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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 927953003: [strong] Forbid var. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: loop w const omg Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/preparser.cc ('k') | test/mjsunit/strong/var-let-const.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5435 matching lines...) Expand 10 before | Expand all | Expand 10 after
5446 "b, a, a", 5446 "b, a, a",
5447 "a, b, c, c", 5447 "a, b, c, c",
5448 "a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, w", 5448 "a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, w",
5449 NULL}; 5449 NULL};
5450 5450
5451 static const ParserFlag always_flags[] = { kAllowStrongMode }; 5451 static const ParserFlag always_flags[] = { kAllowStrongMode };
5452 RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags, 5452 RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags,
5453 arraysize(always_flags)); 5453 arraysize(always_flags));
5454 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, NULL, 0); 5454 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, NULL, 0);
5455 } 5455 }
5456
5457
5458 TEST(VarForbiddenInStrongMode) {
5459 const char* strong_context_data[][2] =
5460 {{"'use strong'; ", ""},
5461 {"function f() {'use strong'; ", "}"},
5462 {"function f() {'use strong'; while (true) { ", "} }"},
5463 {NULL, NULL}};
5464
5465 const char* strict_context_data[][2] =
5466 {{"'use strict'; ", ""},
5467 {"function f() {'use strict'; ", "}"},
5468 {"function f() {'use strict'; while (true) { ", "} }"},
5469 {NULL, NULL}};
5470
5471 const char* sloppy_context_data[][2] =
5472 {{"", ""},
5473 {"function f() { ", "}"},
5474 {NULL, NULL}};
5475
5476 const char* var_declarations[] = {
5477 "var x = 0;",
5478 "for (var i = 0; i < 10; i++) { }",
5479 NULL};
5480
5481 const char* let_declarations[] = {
5482 "let x = 0;",
5483 "for (let i = 0; i < 10; i++) { }",
5484 NULL};
5485
5486 const char* const_declarations[] = {
5487 "const x = 0;",
5488 NULL};
5489
5490 static const ParserFlag always_flags[] = {kAllowStrongMode,
5491 kAllowHarmonyScoping};
5492 RunParserSyncTest(strong_context_data, var_declarations, kError, NULL, 0,
5493 always_flags, arraysize(always_flags));
5494 RunParserSyncTest(strong_context_data, let_declarations, kSuccess, NULL, 0,
5495 always_flags, arraysize(always_flags));
5496 RunParserSyncTest(strong_context_data, const_declarations, kSuccess, NULL, 0,
5497 always_flags, arraysize(always_flags));
5498
5499 RunParserSyncTest(strict_context_data, var_declarations, kSuccess, NULL, 0,
5500 always_flags, arraysize(always_flags));
5501 RunParserSyncTest(strict_context_data, let_declarations, kSuccess, NULL, 0,
5502 always_flags, arraysize(always_flags));
5503
5504 RunParserSyncTest(sloppy_context_data, var_declarations, kSuccess, NULL, 0,
5505 always_flags, arraysize(always_flags));
5506 // At the moment, let declarations are only available in strict mode.
5507 RunParserSyncTest(sloppy_context_data, let_declarations, kError, NULL, 0,
5508 always_flags, arraysize(always_flags));
5509 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | test/mjsunit/strong/var-let-const.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698