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

Unified Diff: test/cctest/compiler/test-run-bytecode-graph-builder.cc

Issue 1499593002: [Interpreter] Adds support for Increment and Decrement to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/compiler/bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-bytecode-graph-builder.cc
diff --git a/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
index 5b5876f3ccffb98c22d25946ac7c654d6dafd3dd..91bed3147ab293fb21706836a6dacad32fded116 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -789,6 +789,61 @@ TEST(BytecodeGraphBuilderTypeOf) {
}
+TEST(BytecodeGraphBuilderCountOperation) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<1> snippets[] = {
+ {"return ++p1;",
+ {factory->NewNumberFromInt(11), factory->NewNumberFromInt(10)}},
+ {"return p1++;",
+ {factory->NewNumberFromInt(10), factory->NewNumberFromInt(10)}},
+ {"return p1++ + 10;",
+ {factory->NewHeapNumber(15.23), factory->NewHeapNumber(5.23)}},
+ {"return 20 + ++p1;",
+ {factory->NewHeapNumber(27.23), factory->NewHeapNumber(6.23)}},
+ {"return --p1;",
+ {factory->NewHeapNumber(9.8), factory->NewHeapNumber(10.8)}},
+ {"return p1--;",
+ {factory->NewHeapNumber(10.8), factory->NewHeapNumber(10.8)}},
+ {"return p1-- + 10;",
+ {factory->NewNumberFromInt(20), factory->NewNumberFromInt(10)}},
+ {"return 20 + --p1;",
+ {factory->NewNumberFromInt(29), factory->NewNumberFromInt(10)}},
+ {"return p1.val--;",
+ {factory->NewNumberFromInt(10),
+ BytecodeGraphTester::NewObject("({val : 10})")}},
+ {"return ++p1['val'];",
+ {factory->NewNumberFromInt(11),
+ BytecodeGraphTester::NewObject("({val : 10})")}},
+ {"return ++p1[1];",
+ {factory->NewNumberFromInt(11),
+ BytecodeGraphTester::NewObject("({1 : 10})")}},
+ {" function inner() { return p1 } return --p1;",
+ {factory->NewNumberFromInt(9), factory->NewNumberFromInt(10)}},
+ {" function inner() { return p1 } return p1--;",
+ {factory->NewNumberFromInt(10), factory->NewNumberFromInt(10)}},
+ {"return ++p1;",
+ {factory->nan_value(), factory->NewStringFromStaticChars("String")}},
+ };
+
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
+ ScopedVector<char> script(1024);
+ SNPrintF(script, "function %s(p1) { %s }\n%s({});", kFunctionName,
+ snippets[i].code_snippet, kFunctionName);
+
+ BytecodeGraphTester tester(isolate, zone, script.start());
+ auto callable = tester.GetCallable<Handle<Object>>();
+ Handle<Object> return_value =
+ callable(snippets[i].parameter(0)).ToHandleChecked();
+ CHECK(return_value->SameValue(*snippets[i].return_value()));
+ }
+}
+
+
TEST(BytecodeGraphBuilderDelete) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698