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

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

Issue 1148383007: Add {Map,Set}::AsArray to the API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased 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
« no previous file with comments | « src/api.cc ('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 af83daaf376651077634a187d41e4c684cc455c9..395450d94c00583edba3ddb367fb23e5fecdc088 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21116,6 +21116,17 @@ TEST(Map) {
CHECK(val->IsMap());
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());
}
@@ -21133,4 +21144,9 @@ TEST(Set) {
CHECK(val->IsSet());
set = v8::Local<v8::Set>::Cast(val);
CHECK_EQ(2, set->Size());
+
+ v8::Local<v8::Array> keys = set->AsArray();
+ CHECK_EQ(2, keys->Length());
+ CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value());
+ CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value());
}
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698