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

Unified Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1509273005: Adds additional tests for bytecode graph builder (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added tests for ToName to interpreter. 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 | « test/cctest/compiler/test-run-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/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index beaa4e34cf9825097dc2ec9ad3361dade1df38d8..9e8ee1e2d8bb0118beada53d1d2635cb9736f194 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -3051,6 +3051,48 @@ TEST(InterpreterAssignmentInExpressions) {
}
+TEST(InterpreterToName) {
+ HandleAndZoneScope handles;
+ i::Isolate* isolate = handles.main_isolate();
+ i::Factory* factory = isolate->factory();
+
+ std::pair<const char*, Handle<Object>> to_name_tests[] = {
+ {"var a = 'val'; var obj = {[a] : 10}; return obj.val;",
+ factory->NewNumberFromInt(10)},
+ {"var a = 20; var obj = {[a] : 10}; return obj['20'];",
+ factory->NewNumberFromInt(10)},
+ {"var a = 20; var obj = {[a] : 10}; return obj[20];",
+ factory->NewNumberFromInt(10)},
+ {"var a = {val:23}; var obj = {[a] : 10}; return obj[a];",
+ factory->NewNumberFromInt(10)},
+ {"var a = {val:23}; var obj = {[a] : 10};\n"
+ "return obj['[object Object]'];",
+ factory->NewNumberFromInt(10)},
+ {"var a = {toString : function() { return 'x'}};\n"
+ "var obj = {[a] : 10};\n"
+ "return obj.x;",
+ factory->NewNumberFromInt(10)},
+ {"var a = {valueOf : function() { return 'x'}};\n"
+ "var obj = {[a] : 10};\n"
+ "return obj.x;",
+ factory->undefined_value()},
+ {"var a = {[Symbol.toPrimitive] : function() { return 'x'}};\n"
+ "var obj = {[a] : 10};\n"
+ "return obj.x;",
+ factory->NewNumberFromInt(10)},
+ };
+
+ for (size_t i = 0; i < arraysize(to_name_tests); i++) {
+ std::string source(
+ InterpreterTester::SourceForBody(to_name_tests[i].first));
+ InterpreterTester tester(handles.main_isolate(), source.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<i::Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*to_name_tests[i].second));
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698