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

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

Issue 168583008: (Pre)Parser: Simplify NewExpression handling (fixed). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: one more comment Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/preparser.cc ('k') | no next file » | 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 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 2056
2057 const char* statement_data[] = { 2057 const char* statement_data[] = {
2058 "%someintrinsic(arg)", 2058 "%someintrinsic(arg)",
2059 NULL 2059 NULL
2060 }; 2060 };
2061 2061
2062 // Parsing will fail or succeed depending on whether we allow natives syntax 2062 // Parsing will fail or succeed depending on whether we allow natives syntax
2063 // or not. 2063 // or not.
2064 RunParserSyncTest(context_data, statement_data, kSuccessOrError); 2064 RunParserSyncTest(context_data, statement_data, kSuccessOrError);
2065 } 2065 }
2066
2067
2068 TEST(NoErrorsNewExpression) {
2069 const char* context_data[][2] = {
2070 {"", ""},
2071 {"var f =", ""},
2072 { NULL, NULL }
2073 };
2074
2075 const char* statement_data[] = {
2076 "new foo",
2077 "new foo();",
2078 "new foo(1);",
2079 "new foo(1, 2);",
2080 // The first () will be processed as a part of the NewExpression and the
2081 // second () will be processed as part of LeftHandSideExpression.
2082 "new foo()();",
2083 // The first () will be processed as a part of the inner NewExpression and
2084 // the second () will be processed as a part of the outer NewExpression.
2085 "new new foo()();",
2086 "new foo.bar;",
2087 "new foo.bar();",
2088 "new foo.bar.baz;",
2089 "new foo.bar().baz;",
2090 "new foo[bar];",
2091 "new foo[bar]();",
2092 "new foo[bar][baz];",
2093 "new foo[bar]()[baz];",
2094 "new foo[bar].baz(baz)()[bar].baz;",
2095 "new \"foo\"", // Runtime error
2096 "new 1", // Runtime error
2097 "new foo++",
2098 // This even runs:
2099 "(new new Function(\"this.x = 1\")).x;",
2100 "new new Test_Two(String, 2).v(0123).length;",
2101 NULL
2102 };
2103
2104 RunParserSyncTest(context_data, statement_data, kSuccess);
2105 }
2106
2107
2108 TEST(ErrorsNewExpression) {
2109 const char* context_data[][2] = {
2110 {"", ""},
2111 {"var f =", ""},
2112 { NULL, NULL }
2113 };
2114
2115 const char* statement_data[] = {
2116 "new foo bar",
2117 "new ) foo",
2118 "new ++foo",
2119 NULL
2120 };
2121
2122 RunParserSyncTest(context_data, statement_data, kError);
2123 }
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698