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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 CHECK(Top::context()->global()->HasLocalProperty(obj_name)); | 241 CHECK(Top::context()->global()->HasLocalProperty(obj_name)); |
242 CHECK(Top::context()->global()->GetProperty(obj_name)->IsJSObject()); | 242 CHECK(Top::context()->global()->GetProperty(obj_name)->IsJSObject()); |
243 obj = JSObject::cast(Top::context()->global()->GetProperty(obj_name)); | 243 obj = JSObject::cast(Top::context()->global()->GetProperty(obj_name)); |
244 prop_name = String::cast(Heap::LookupAsciiSymbol("theSlot")); | 244 prop_name = String::cast(Heap::LookupAsciiSymbol("theSlot")); |
245 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(prop_name)); | 245 CHECK_EQ(Smi::FromInt(23), obj->GetProperty(prop_name)); |
246 } | 246 } |
247 | 247 |
248 | 248 |
249 static void VerifyStringAllocation(const char* string) { | 249 static void VerifyStringAllocation(const char* string) { |
250 String* s = String::cast(Heap::AllocateStringFromUtf8(CStrVector(string))); | 250 String* s = String::cast(Heap::AllocateStringFromUtf8(CStrVector(string))); |
251 CHECK_EQ(static_cast<int>(strlen(string)), s->length()); | 251 StringShape shape(s); |
252 for (int index = 0; index < s->length(); index++) { | 252 CHECK_EQ(static_cast<int>(strlen(string)), s->length(shape)); |
253 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index)); } | 253 for (int index = 0; index < s->length(shape); index++) { |
| 254 CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(shape, index)); } |
254 } | 255 } |
255 | 256 |
256 | 257 |
257 TEST(String) { | 258 TEST(String) { |
258 InitializeVM(); | 259 InitializeVM(); |
259 | 260 |
260 VerifyStringAllocation("a"); | 261 VerifyStringAllocation("a"); |
261 VerifyStringAllocation("ab"); | 262 VerifyStringAllocation("ab"); |
262 VerifyStringAllocation("abc"); | 263 VerifyStringAllocation("abc"); |
263 VerifyStringAllocation("abcd"); | 264 VerifyStringAllocation("abcd"); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 objs[next_objs_index++] = | 771 objs[next_objs_index++] = |
771 Factory::NewStringFromAscii(CStrVector(str), TENURED); | 772 Factory::NewStringFromAscii(CStrVector(str), TENURED); |
772 delete[] str; | 773 delete[] str; |
773 | 774 |
774 // Add a Map object to look for. | 775 // Add a Map object to look for. |
775 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 776 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
776 | 777 |
777 CHECK_EQ(objs_count, next_objs_index); | 778 CHECK_EQ(objs_count, next_objs_index); |
778 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); | 779 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); |
779 } | 780 } |
OLD | NEW |