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

Side by Side Diff: test/cctest/test-ordered-hash-table.cc

Issue 256743008: OrderedHashMap::Lookup() and ObjectHashTable::Lookup() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebasing Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-dictionary.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 CHECK_EQ(0, ordered_map->NumberOfDeletedElements()); 155 CHECK_EQ(0, ordered_map->NumberOfDeletedElements());
156 156
157 Handle<JSMapIterator> value_iterator = 157 Handle<JSMapIterator> value_iterator =
158 JSMapIterator::Create(ordered_map, JSMapIterator::kKindValues); 158 JSMapIterator::Create(ordered_map, JSMapIterator::kKindValues);
159 Handle<JSMapIterator> key_iterator = 159 Handle<JSMapIterator> key_iterator =
160 JSMapIterator::Create(ordered_map, JSMapIterator::kKindKeys); 160 JSMapIterator::Create(ordered_map, JSMapIterator::kKindKeys);
161 161
162 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 162 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
163 Handle<JSObject> obj = factory->NewJSObjectFromMap(map); 163 Handle<JSObject> obj = factory->NewJSObjectFromMap(map);
164 Handle<JSObject> val = factory->NewJSObjectFromMap(map); 164 Handle<JSObject> val = factory->NewJSObjectFromMap(map);
165 CHECK(ordered_map->Lookup(*obj)->IsTheHole()); 165 CHECK(ordered_map->Lookup(obj)->IsTheHole());
166 ordered_map = OrderedHashMap::Put(ordered_map, obj, val); 166 ordered_map = OrderedHashMap::Put(ordered_map, obj, val);
167 CHECK_EQ(1, ordered_map->NumberOfElements()); 167 CHECK_EQ(1, ordered_map->NumberOfElements());
168 CHECK(ordered_map->Lookup(*obj)->SameValue(*val)); 168 CHECK(ordered_map->Lookup(obj)->SameValue(*val));
169 ordered_map = OrderedHashMap::Put( 169 ordered_map = OrderedHashMap::Put(
170 ordered_map, obj, factory->the_hole_value()); 170 ordered_map, obj, factory->the_hole_value());
171 CHECK_EQ(0, ordered_map->NumberOfElements()); 171 CHECK_EQ(0, ordered_map->NumberOfElements());
172 CHECK(ordered_map->Lookup(*obj)->IsTheHole()); 172 CHECK(ordered_map->Lookup(obj)->IsTheHole());
173 173
174 // Test for collisions/chaining 174 // Test for collisions/chaining
175 Handle<JSObject> obj1 = factory->NewJSObjectFromMap(map); 175 Handle<JSObject> obj1 = factory->NewJSObjectFromMap(map);
176 Handle<JSObject> obj2 = factory->NewJSObjectFromMap(map); 176 Handle<JSObject> obj2 = factory->NewJSObjectFromMap(map);
177 Handle<JSObject> obj3 = factory->NewJSObjectFromMap(map); 177 Handle<JSObject> obj3 = factory->NewJSObjectFromMap(map);
178 Handle<JSObject> val1 = factory->NewJSObjectFromMap(map); 178 Handle<JSObject> val1 = factory->NewJSObjectFromMap(map);
179 Handle<JSObject> val2 = factory->NewJSObjectFromMap(map); 179 Handle<JSObject> val2 = factory->NewJSObjectFromMap(map);
180 Handle<JSObject> val3 = factory->NewJSObjectFromMap(map); 180 Handle<JSObject> val3 = factory->NewJSObjectFromMap(map);
181 ordered_map = OrderedHashMap::Put(ordered_map, obj1, val1); 181 ordered_map = OrderedHashMap::Put(ordered_map, obj1, val1);
182 ordered_map = OrderedHashMap::Put(ordered_map, obj2, val2); 182 ordered_map = OrderedHashMap::Put(ordered_map, obj2, val2);
183 ordered_map = OrderedHashMap::Put(ordered_map, obj3, val3); 183 ordered_map = OrderedHashMap::Put(ordered_map, obj3, val3);
184 CHECK_EQ(3, ordered_map->NumberOfElements()); 184 CHECK_EQ(3, ordered_map->NumberOfElements());
185 CHECK(ordered_map->Lookup(*obj1)->SameValue(*val1)); 185 CHECK(ordered_map->Lookup(obj1)->SameValue(*val1));
186 CHECK(ordered_map->Lookup(*obj2)->SameValue(*val2)); 186 CHECK(ordered_map->Lookup(obj2)->SameValue(*val2));
187 CHECK(ordered_map->Lookup(*obj3)->SameValue(*val3)); 187 CHECK(ordered_map->Lookup(obj3)->SameValue(*val3));
188 188
189 // Test iteration 189 // Test iteration
190 CheckIterResultObject( 190 CheckIterResultObject(
191 isolate, JSMapIterator::Next(value_iterator), val1, false); 191 isolate, JSMapIterator::Next(value_iterator), val1, false);
192 CheckIterResultObject( 192 CheckIterResultObject(
193 isolate, JSMapIterator::Next(value_iterator), val2, false); 193 isolate, JSMapIterator::Next(value_iterator), val2, false);
194 CheckIterResultObject( 194 CheckIterResultObject(
195 isolate, JSMapIterator::Next(value_iterator), val3, false); 195 isolate, JSMapIterator::Next(value_iterator), val3, false);
196 CheckIterResultObject(isolate, 196 CheckIterResultObject(isolate,
197 JSMapIterator::Next(value_iterator), 197 JSMapIterator::Next(value_iterator),
198 factory->undefined_value(), 198 factory->undefined_value(),
199 true); 199 true);
200 200
201 // Test growth 201 // Test growth
202 ordered_map = OrderedHashMap::Put(ordered_map, obj, val); 202 ordered_map = OrderedHashMap::Put(ordered_map, obj, val);
203 Handle<JSObject> obj4 = factory->NewJSObjectFromMap(map); 203 Handle<JSObject> obj4 = factory->NewJSObjectFromMap(map);
204 Handle<JSObject> val4 = factory->NewJSObjectFromMap(map); 204 Handle<JSObject> val4 = factory->NewJSObjectFromMap(map);
205 ordered_map = OrderedHashMap::Put(ordered_map, obj4, val4); 205 ordered_map = OrderedHashMap::Put(ordered_map, obj4, val4);
206 CHECK(ordered_map->Lookup(*obj)->SameValue(*val)); 206 CHECK(ordered_map->Lookup(obj)->SameValue(*val));
207 CHECK(ordered_map->Lookup(*obj1)->SameValue(*val1)); 207 CHECK(ordered_map->Lookup(obj1)->SameValue(*val1));
208 CHECK(ordered_map->Lookup(*obj2)->SameValue(*val2)); 208 CHECK(ordered_map->Lookup(obj2)->SameValue(*val2));
209 CHECK(ordered_map->Lookup(*obj3)->SameValue(*val3)); 209 CHECK(ordered_map->Lookup(obj3)->SameValue(*val3));
210 CHECK(ordered_map->Lookup(*obj4)->SameValue(*val4)); 210 CHECK(ordered_map->Lookup(obj4)->SameValue(*val4));
211 CHECK_EQ(5, ordered_map->NumberOfElements()); 211 CHECK_EQ(5, ordered_map->NumberOfElements());
212 CHECK_EQ(4, ordered_map->NumberOfBuckets()); 212 CHECK_EQ(4, ordered_map->NumberOfBuckets());
213 213
214 // Test iteration after growth 214 // Test iteration after growth
215 CheckIterResultObject( 215 CheckIterResultObject(
216 isolate, JSMapIterator::Next(key_iterator), obj1, false); 216 isolate, JSMapIterator::Next(key_iterator), obj1, false);
217 CheckIterResultObject( 217 CheckIterResultObject(
218 isolate, JSMapIterator::Next(key_iterator), obj2, false); 218 isolate, JSMapIterator::Next(key_iterator), obj2, false);
219 CheckIterResultObject( 219 CheckIterResultObject(
220 isolate, JSMapIterator::Next(key_iterator), obj3, false); 220 isolate, JSMapIterator::Next(key_iterator), obj3, false);
(...skipping 14 matching lines...) Expand all
235 ordered_map = OrderedHashMap::Put( 235 ordered_map = OrderedHashMap::Put(
236 ordered_map, obj2, factory->the_hole_value()); 236 ordered_map, obj2, factory->the_hole_value());
237 ordered_map = OrderedHashMap::Put( 237 ordered_map = OrderedHashMap::Put(
238 ordered_map, obj3, factory->the_hole_value()); 238 ordered_map, obj3, factory->the_hole_value());
239 CHECK_EQ(1, ordered_map->NumberOfElements()); 239 CHECK_EQ(1, ordered_map->NumberOfElements());
240 CHECK_EQ(2, ordered_map->NumberOfBuckets()); 240 CHECK_EQ(2, ordered_map->NumberOfBuckets());
241 } 241 }
242 242
243 243
244 } 244 }
OLDNEW
« no previous file with comments | « test/cctest/test-dictionary.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698