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

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

Issue 1157843006: Flatten the Arrays returned and consumed by the v8::Map API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reject FromArray args with odd lengths Created 5 years, 7 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
« src/api.cc ('K') | « src/collection.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 93ed66b2180fa6ab8410a2de300ee36aca9e27cb..8e5278fe2c45ff4fb101d2b43e6c6ad2ef14b0a4 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21384,19 +21384,19 @@ TEST(Map) {
map = v8::Local<v8::Map>::Cast(val);
CHECK_EQ(2, map->Size());
- v8::Local<v8::Array> entries = map->AsArray();
- CHECK_EQ(2, entries->Length());
- v8::Local<v8::Array> entry = entries->Get(0).As<v8::Array>();
- CHECK_EQ(2, entry->Length());
- CHECK_EQ(1, entry->Get(0).As<v8::Int32>()->Value());
- CHECK_EQ(2, entry->Get(1).As<v8::Int32>()->Value());
- entry = entries->Get(1).As<v8::Array>();
- CHECK_EQ(2, entry->Length());
- CHECK_EQ(3, entry->Get(0).As<v8::Int32>()->Value());
- CHECK_EQ(4, entry->Get(1).As<v8::Int32>()->Value());
-
- map = v8::Map::FromArray(env.local(), entries).ToLocalChecked();
+ v8::Local<v8::Array> contents = map->AsArray();
+ CHECK_EQ(4, contents->Length());
+ CHECK_EQ(1, contents->Get(0).As<v8::Int32>()->Value());
+ CHECK_EQ(2, contents->Get(1).As<v8::Int32>()->Value());
+ CHECK_EQ(3, contents->Get(2).As<v8::Int32>()->Value());
+ CHECK_EQ(4, contents->Get(3).As<v8::Int32>()->Value());
+
+ map = v8::Map::FromArray(env.local(), contents).ToLocalChecked();
CHECK_EQ(2, map->Size());
+
+ // Odd lengths result in a null MaybeLocal.
+ contents = v8::Array::New(isolate, 41);
+ CHECK(v8::Map::FromArray(env.local(), contents).IsEmpty());
}
« src/api.cc ('K') | « src/collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698