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

Unified Diff: test/cctest/test-ast-expression-visitor.cc

Issue 1314843002: Visit additional AST nodes as expressions in AstExpressionVisitor . (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: revised Created 5 years, 4 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/ast-expression-visitor.cc ('k') | test/cctest/test-typing-reset.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-ast-expression-visitor.cc
diff --git a/test/cctest/test-ast-expression-visitor.cc b/test/cctest/test-ast-expression-visitor.cc
index bee0a73de1b0eeefbea0828c242028123e72a27b..c7ef3605fe38e10bde4ffdcb6f659745c4939909 100644
--- a/test/cctest/test-ast-expression-visitor.cc
+++ b/test/cctest/test-ast-expression-visitor.cc
@@ -163,10 +163,12 @@ TEST(VisitExpressions) {
CHECK_EXPR(BinaryOperation, DEFAULT_TYPE) {
CHECK_EXPR(Call, DEFAULT_TYPE) {
CHECK_VAR(log, DEFAULT_TYPE);
- CHECK_VAR(values, DEFAULT_TYPE);
- CHECK_EXPR(BinaryOperation, DEFAULT_TYPE) {
- CHECK_VAR(p, DEFAULT_TYPE);
- CHECK_EXPR(Literal, DEFAULT_TYPE);
+ CHECK_EXPR(Property, DEFAULT_TYPE) {
+ CHECK_VAR(values, DEFAULT_TYPE);
+ CHECK_EXPR(BinaryOperation, DEFAULT_TYPE) {
+ CHECK_VAR(p, DEFAULT_TYPE);
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
}
}
CHECK_EXPR(Literal, DEFAULT_TYPE);
@@ -228,23 +230,33 @@ TEST(VisitExpressions) {
// var exp = stdlib.Math.exp;
CHECK_EXPR(Assignment, DEFAULT_TYPE) {
CHECK_VAR(exp, DEFAULT_TYPE);
- CHECK_VAR(stdlib, DEFAULT_TYPE);
- CHECK_EXPR(Literal, DEFAULT_TYPE);
- CHECK_EXPR(Literal, DEFAULT_TYPE);
+ CHECK_EXPR(Property, DEFAULT_TYPE) {
+ CHECK_EXPR(Property, DEFAULT_TYPE) {
+ CHECK_VAR(stdlib, DEFAULT_TYPE);
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
}
// var log = stdlib.Math.log;
CHECK_EXPR(Assignment, DEFAULT_TYPE) {
CHECK_VAR(log, DEFAULT_TYPE);
- CHECK_VAR(stdlib, DEFAULT_TYPE);
- CHECK_EXPR(Literal, DEFAULT_TYPE);
- CHECK_EXPR(Literal, DEFAULT_TYPE);
+ CHECK_EXPR(Property, DEFAULT_TYPE) {
+ CHECK_EXPR(Property, DEFAULT_TYPE) {
+ CHECK_VAR(stdlib, DEFAULT_TYPE);
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
}
// var values = new stdlib.Float64Array(buffer);
CHECK_EXPR(Assignment, DEFAULT_TYPE) {
CHECK_VAR(values, DEFAULT_TYPE);
CHECK_EXPR(CallNew, DEFAULT_TYPE) {
- CHECK_VAR(stdlib, DEFAULT_TYPE);
- CHECK_EXPR(Literal, DEFAULT_TYPE);
+ CHECK_EXPR(Property, DEFAULT_TYPE) {
+ CHECK_VAR(stdlib, DEFAULT_TYPE);
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
CHECK_VAR(buffer, DEFAULT_TYPE);
}
}
@@ -297,3 +309,58 @@ TEST(VisitSwitchStatment) {
}
CHECK_TYPES_END
}
+
+
+TEST(VisitThrow) {
+ v8::V8::Initialize();
+ HandleAndZoneScope handles;
+ ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ // Check that traversing an empty for statement works.
+ const char test_function[] =
+ "function foo() {\n"
+ " throw 123;\n"
+ "}\n";
+ CollectTypes(&handles, test_function, &types);
+ CHECK_TYPES_BEGIN {
+ CHECK_EXPR(FunctionLiteral, DEFAULT_TYPE) {
+ CHECK_EXPR(Throw, DEFAULT_TYPE) { CHECK_EXPR(Literal, DEFAULT_TYPE); }
+ }
+ }
+ CHECK_TYPES_END
+}
+
+
+TEST(VisitYield) {
+ v8::V8::Initialize();
+ HandleAndZoneScope handles;
+ ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ // Check that traversing an empty for statement works.
+ const char test_function[] =
+ "function* foo() {\n"
+ " yield 123;\n"
+ "}\n";
+ CollectTypes(&handles, test_function, &types);
+ CHECK_TYPES_BEGIN {
+ CHECK_EXPR(FunctionLiteral, DEFAULT_TYPE) {
+ // Generator function yields generator on entry.
+ CHECK_EXPR(Yield, DEFAULT_TYPE) {
+ CHECK_VAR(.generator_object, DEFAULT_TYPE);
+ CHECK_EXPR(Assignment, DEFAULT_TYPE) {
+ CHECK_VAR(.generator_object, DEFAULT_TYPE);
+ CHECK_EXPR(CallRuntime, DEFAULT_TYPE);
+ }
+ }
+ // Then yields undefined.
+ CHECK_EXPR(Yield, DEFAULT_TYPE) {
+ CHECK_VAR(.generator_object, DEFAULT_TYPE);
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
+ // Then yields 123.
+ CHECK_EXPR(Yield, DEFAULT_TYPE) {
+ CHECK_VAR(.generator_object, DEFAULT_TYPE);
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
+ }
+ }
+ CHECK_TYPES_END
+}
« no previous file with comments | « src/ast-expression-visitor.cc ('k') | test/cctest/test-typing-reset.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698