OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "execution.h" | 7 #include "execution.h" |
8 #include "factory.h" | 8 #include "factory.h" |
9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
10 #include "global-handles.h" | 10 #include "global-handles.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 CHECK(Top::context()->global()->HasLocalProperty(obj_name)); | 255 CHECK(Top::context()->global()->HasLocalProperty(obj_name)); |
256 CHECK(Top::context()->global()->GetProperty(obj_name)->IsJSObject()); | 256 CHECK(Top::context()->global()->GetProperty(obj_name)->IsJSObject()); |
257 obj = JSObject::cast(Top::context()->global()->GetProperty(obj_name)); | 257 obj = JSObject::cast(Top::context()->global()->GetProperty(obj_name)); |
258 prop_name = String::cast(Heap::LookupAsciiSymbol("theSlot")); | 258 prop_name = String::cast(Heap::LookupAsciiSymbol("theSlot")); |
259 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(prop_name)); | 259 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(prop_name)); |
260 } | 260 } |
261 | 261 |
262 | 262 |
263 static void VerifyStringAllocation(const char* string) { | 263 static void VerifyStringAllocation(const char* string) { |
264 String* s = String::cast(Heap::AllocateStringFromUtf8(CStrVector(string))); | 264 String* s = String::cast(Heap::AllocateStringFromUtf8(CStrVector(string))); |
265 CHECK_EQ(static_cast<int>(strlen(string)), s->length()); | 265 CHECK_EQ(StrLength(string), s->length()); |
266 for (int index = 0; index < s->length(); index++) { | 266 for (int index = 0; index < s->length(); index++) { |
267 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index)); } | 267 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index)); } |
268 } | 268 } |
269 | 269 |
270 | 270 |
271 TEST(String) { | 271 TEST(String) { |
272 InitializeVM(); | 272 InitializeVM(); |
273 | 273 |
274 VerifyStringAllocation("a"); | 274 VerifyStringAllocation("a"); |
275 VerifyStringAllocation("ab"); | 275 VerifyStringAllocation("ab"); |
276 VerifyStringAllocation("abc"); | 276 VerifyStringAllocation("abc"); |
277 VerifyStringAllocation("abcd"); | 277 VerifyStringAllocation("abcd"); |
278 VerifyStringAllocation("fiskerdrengen er paa havet"); | 278 VerifyStringAllocation("fiskerdrengen er paa havet"); |
279 } | 279 } |
280 | 280 |
281 | 281 |
282 TEST(LocalHandles) { | 282 TEST(LocalHandles) { |
283 InitializeVM(); | 283 InitializeVM(); |
284 | 284 |
285 v8::HandleScope scope; | 285 v8::HandleScope scope; |
286 const char* name = "Kasper the spunky"; | 286 const char* name = "Kasper the spunky"; |
287 Handle<String> string = Factory::NewStringFromAscii(CStrVector(name)); | 287 Handle<String> string = Factory::NewStringFromAscii(CStrVector(name)); |
288 CHECK_EQ(static_cast<int>(strlen(name)), string->length()); | 288 CHECK_EQ(StrLength(name), string->length()); |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 TEST(GlobalHandles) { | 292 TEST(GlobalHandles) { |
293 InitializeVM(); | 293 InitializeVM(); |
294 | 294 |
295 Object* i = Heap::AllocateStringFromAscii(CStrVector("fisk")); | 295 Object* i = Heap::AllocateStringFromAscii(CStrVector("fisk")); |
296 Object* u = Heap::AllocateHeapNumber(1.12344); | 296 Object* u = Heap::AllocateHeapNumber(1.12344); |
297 | 297 |
298 Handle<Object> h1 = GlobalHandles::Create(i); | 298 Handle<Object> h1 = GlobalHandles::Create(i); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 objs[next_objs_index++] = | 788 objs[next_objs_index++] = |
789 Factory::NewStringFromAscii(CStrVector(str), TENURED); | 789 Factory::NewStringFromAscii(CStrVector(str), TENURED); |
790 delete[] str; | 790 delete[] str; |
791 | 791 |
792 // Add a Map object to look for. | 792 // Add a Map object to look for. |
793 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 793 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
794 | 794 |
795 CHECK_EQ(objs_count, next_objs_index); | 795 CHECK_EQ(objs_count, next_objs_index); |
796 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); | 796 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); |
797 } | 797 } |
OLD | NEW |