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

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

Issue 1412953007: [Interpreter] Fill out function prologue support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 2 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
Index: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index ba038aed49387d8d667a02f3db4d0355135d49c1..2994387bfd7f383f97a7b949d209022648c65dee 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -2199,3 +2199,68 @@ TEST(InterpreterGlobalCompoundExpressions) {
CHECK(return_value->SameValue(*compound_expr[i].second));
}
}
+
+
+TEST(InterpreterCreateArguments) {
+ HandleAndZoneScope handles;
+ i::Isolate* isolate = handles.main_isolate();
+ i::Factory* factory = isolate->factory();
+
+ std::pair<const char*, int> create_args[9] = {
+ std::make_pair("function f() { return arguments[0]; }", 0),
+ std::make_pair("function f(a) { return arguments[0]; }", 0),
+ std::make_pair("function f() { return arguments[2]; }", 2),
+ std::make_pair("function f(a) { return arguments[2]; }", 2),
+ std::make_pair("function f(a, b, c, d) { return arguments[2]; }", 2),
+ std::make_pair("function f(a) {"
+ "'use strict'; return arguments[0]; }",
+ 0),
+ std::make_pair("function f(a, b, c, d) {"
+ "'use strict'; return arguments[2]; }",
+ 2),
+ // Check arguments are mapped in sloppy mode and unmapped in strict.
+ std::make_pair("function f(a, b, c, d) {"
+ " c = b; return arguments[2]; }",
+ 1),
+ std::make_pair("function f(a, b, c, d) {"
+ " 'use strict'; c = b; return arguments[2]; }",
+ 2),
+ };
+
+ // Test passing no arguments.
+ for (size_t i = 0; i < arraysize(create_args); i++) {
+ InterpreterTester tester(handles.main_isolate(), create_args[i].first);
+ auto callable = tester.GetCallable<>();
+ Handle<Object> return_val = callable().ToHandleChecked();
+ CHECK(return_val.is_identical_to(factory->undefined_value()));
+ }
+
+ // Test passing one argument.
+ for (size_t i = 0; i < arraysize(create_args); i++) {
+ InterpreterTester tester(handles.main_isolate(), create_args[i].first);
+ auto callable = tester.GetCallable<Handle<Object>>();
+ Handle<Object> return_val =
+ callable(handle(Smi::FromInt(40), isolate)).ToHandleChecked();
+ if (create_args[i].second == 0) {
+ CHECK_EQ(Smi::cast(*return_val), Smi::FromInt(40));
+ } else {
+ CHECK(return_val.is_identical_to(factory->undefined_value()));
+ }
+ }
+
+ // Test passing three argument.
+ for (size_t i = 0; i < arraysize(create_args); i++) {
+ Handle<Object> args[3] = {
+ handle(Smi::FromInt(40), isolate),
+ handle(Smi::FromInt(60), isolate),
+ handle(Smi::FromInt(80), isolate),
+ };
+
+ InterpreterTester tester(handles.main_isolate(), create_args[i].first);
+ auto callable =
+ tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>();
+ Handle<Object> return_val =
+ callable(args[0], args[1], args[2]).ToHandleChecked();
+ CHECK(return_val->SameValue(*args[create_args[i].second]));
+ }
+}
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698