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

Unified Diff: runtime/vm/hash_table_test.cc

Issue 397413002: Reimplement Symbols using hash table template. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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: runtime/vm/hash_table_test.cc
===================================================================
--- runtime/vm/hash_table_test.cc (revision 38342)
+++ runtime/vm/hash_table_test.cc (working copy)
@@ -33,6 +33,9 @@
static uword Hash(const Object& obj) {
return String::Cast(obj).Length();
}
+ static RawObject* NewKey(const char* key) {
+ return String::New(key);
+ }
};
@@ -128,6 +131,18 @@
EXPECT(a_value.Equals("AAA"));
Object& null_value = Object::Handle(table.GetOrNull("0"));
EXPECT(null_value.IsNull());
+
+ // Test on-demand allocation of a new key object using NewKey in traits.
+ String& b_value = String::Handle();
+ b_value ^=
+ table.InsertNewOrGetValue("b", String::Handle(String::New("BBB")));
+ EXPECT(b_value.Equals("BBB"));
+ {
+ // When the key is already present, there should be no allocation.
+ NoGCScope no_gc;
+ b_value ^= table.InsertNewOrGetValue("b", a_value);
+ EXPECT(b_value.Equals("BBB"));
+ }
table.Release();
}
« no previous file with comments | « runtime/vm/hash_table.h ('k') | runtime/vm/object.h » ('j') | runtime/vm/symbols.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698