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

Unified Diff: test/mjsunit/regress/regress-2470.js

Issue 12613007: Harden Function()'s parsing of function literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 7 years, 9 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 | « test/mjsunit/new-function.js ('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-2470.js
diff --git a/test/mjsunit/parallel-optimize-disabled.js b/test/mjsunit/regress/regress-2470.js
similarity index 70%
copy from test/mjsunit/parallel-optimize-disabled.js
copy to test/mjsunit/regress/regress-2470.js
index 2487964bd99a5497c9166c52fe8de4862ac55ba9..eed381699d66de7f90f6a8ad2ff3ff59213134ab 100644
--- a/test/mjsunit/parallel-optimize-disabled.js
+++ b/test/mjsunit/regress/regress-2470.js
@@ -25,22 +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: --nodead-code-elimination --parallel-recompilation
-// Flags: --allow-natives-syntax
+// Test whether the opening parenthesis can be eaten up by a comment.
+assertThrows('Function("/*", "*/){");', SyntaxError);
-function g() { // g() cannot be optimized.
- const x = 1;
- x++;
-}
+// Test whether the function literal can be closed prematurely.
+assertThrows('Function("});(function(){");', SyntaxError);
-function f(x) {
- g();
-}
-
-f();
-f();
-%OptimizeFunctionOnNextCall(g, "parallel");
-%OptimizeFunctionOnNextCall(f);
-f(0); // g() is disabled for optimization on inlining attempt.
-g(); // Attempt to optimize g() should not run into any assertion.
+// Test whether block comments are handled correctly.
+assertDoesNotThrow('Function("/*", "*/", "/**/");');
+assertDoesNotThrow('Function("/*", "a", "*/", "/**/");');
+assertThrows('Function("a", "/*", "*/", "/**/");', SyntaxError);
+// Test whether line comments are handled correctly.
+assertDoesNotThrow('Function("//", "//")');
+assertDoesNotThrow('Function("//", "//", "//")');
+assertThrows('Function("a", "//", "//")', SyntaxError);
« no previous file with comments | « test/mjsunit/new-function.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698