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

Unified Diff: runtime/vm/object_test.cc

Issue 1150103005: Provide a logical view of VM-internal maps in Observatory. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « runtime/vm/object.cc ('k') | runtime/vm/service/service.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object_test.cc
diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc
index ebe0ba0372ad153a428885260d1bd2d43303cae9..028455deab2356593c5ce032d5c27fb5384cafc0 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -4500,7 +4500,8 @@ TEST_CASE(PrintJSONPrimitives) {
"\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
"\"name\":\"_InternalLinkedHashMap\",\"_vmName\":\"\"},"
"\"kind\":\"Map\","
- "\"id\":\"\"}",
+ "\"id\":\"\","
+ "\"length\":0}",
buffer);
}
// UserTag reference
@@ -4706,4 +4707,46 @@ TEST_CASE(LinkedHashMap) {
CheckIdenticalHashStructure(dart_map, cc_map);
}
+
+TEST_CASE(LinkedHashMap_iteration) {
+ const char* kScript =
+ "makeMap() {\n"
+ " var map = {'x': 3, 'y': 4, 'z': 5, 'w': 6};\n"
+ " map.remove('y');\n"
+ " map.remove('w');\n"
+ " return map;\n"
+ "}";
+ Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(h_lib);
+ Library& lib = Library::Handle();
+ lib ^= Api::UnwrapHandle(h_lib);
+ EXPECT(!lib.IsNull());
+ Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, NULL);
+ EXPECT_VALID(h_result);
+
+ Instance& dart_map = Instance::Handle();
+ dart_map ^= Api::UnwrapHandle(h_result);
+ ASSERT(dart_map.IsLinkedHashMap());
+ const LinkedHashMap& cc_map = LinkedHashMap::Cast(dart_map);
+
+ EXPECT_EQ(2, cc_map.Length());
+
+ LinkedHashMap::Iterator iterator(cc_map);
+ Object& object = Object::Handle();
+
+ EXPECT(iterator.MoveNext());
+ object = iterator.CurrentKey();
+ EXPECT_STREQ("x", object.ToCString());
+ object = iterator.CurrentValue();
+ EXPECT_STREQ("3", object.ToCString());
+
+ EXPECT(iterator.MoveNext());
+ object = iterator.CurrentKey();
+ EXPECT_STREQ("z", object.ToCString());
+ object = iterator.CurrentValue();
+ EXPECT_STREQ("5", object.ToCString());
+
+ EXPECT(!iterator.MoveNext());
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/service/service.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698