OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 5278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5289 | 5289 |
5290 memset(buf, 0x1, sizeof(buf)); | 5290 memset(buf, 0x1, sizeof(buf)); |
5291 memset(wbuf, 0x1, sizeof(wbuf)); | 5291 memset(wbuf, 0x1, sizeof(wbuf)); |
5292 len = str->WriteAscii(buf, 3, 1); | 5292 len = str->WriteAscii(buf, 3, 1); |
5293 CHECK_EQ(1, len); | 5293 CHECK_EQ(1, len); |
5294 len = str->Write(wbuf, 3, 1); | 5294 len = str->Write(wbuf, 3, 1); |
5295 CHECK_EQ(1, len); | 5295 CHECK_EQ(1, len); |
5296 CHECK_EQ(0, strncmp("d\1", buf, 2)); | 5296 CHECK_EQ(0, strncmp("d\1", buf, 2)); |
5297 uint16_t answer7[] = {'d', 0x101}; | 5297 uint16_t answer7[] = {'d', 0x101}; |
5298 CHECK_EQ(0, StrNCmp16(answer7, wbuf, 2)); | 5298 CHECK_EQ(0, StrNCmp16(answer7, wbuf, 2)); |
| 5299 |
| 5300 memset(wbuf, 0x1, sizeof(wbuf)); |
| 5301 wbuf[5] = 'X'; |
| 5302 len = str->Write(wbuf, 0, 6, String::WRITE_NO_NULL_TERMINATION); |
| 5303 CHECK_EQ(5, len); |
| 5304 CHECK_EQ('X', wbuf[5]); |
| 5305 uint16_t answer8a[] = {'a', 'b', 'c', 'd', 'e'}; |
| 5306 uint16_t answer8b[] = {'a', 'b', 'c', 'd', 'e', '\0'}; |
| 5307 CHECK_EQ(0, StrNCmp16(answer8a, wbuf, 5)); |
| 5308 CHECK_NE(0, StrCmp16(answer8b, wbuf)); |
| 5309 wbuf[5] = '\0'; |
| 5310 CHECK_EQ(0, StrCmp16(answer8b, wbuf)); |
| 5311 |
| 5312 memset(buf, 0x1, sizeof(buf)); |
| 5313 buf[5] = 'X'; |
| 5314 len = str->WriteAscii(buf, 0, 6, String::WRITE_NO_NULL_TERMINATION); |
| 5315 CHECK_EQ(5, len); |
| 5316 CHECK_EQ('X', buf[5]); |
| 5317 CHECK_EQ(0, strncmp("abcde", buf, 5)); |
| 5318 CHECK_NE(0, strcmp("abcde", buf)); |
| 5319 buf[5] = '\0'; |
| 5320 CHECK_EQ(0, strcmp("abcde", buf)); |
| 5321 |
| 5322 memset(utf8buf, 0x1, sizeof(utf8buf)); |
| 5323 utf8buf[8] = 'X'; |
| 5324 len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen, |
| 5325 String::WRITE_NO_NULL_TERMINATION); |
| 5326 CHECK_EQ(8, len); |
| 5327 CHECK_EQ('X', utf8buf[8]); |
| 5328 CHECK_EQ(5, charlen); |
| 5329 CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\342\230\203", 8)); |
| 5330 CHECK_NE(0, strcmp(utf8buf, "abc\303\260\342\230\203")); |
| 5331 utf8buf[8] = '\0'; |
| 5332 CHECK_EQ(0, strcmp(utf8buf, "abc\303\260\342\230\203")); |
5299 } | 5333 } |
5300 | 5334 |
5301 | 5335 |
5302 THREADED_TEST(ToArrayIndex) { | 5336 THREADED_TEST(ToArrayIndex) { |
5303 v8::HandleScope scope; | 5337 v8::HandleScope scope; |
5304 LocalContext context; | 5338 LocalContext context; |
5305 | 5339 |
5306 v8::Handle<String> str = v8_str("42"); | 5340 v8::Handle<String> str = v8_str("42"); |
5307 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); | 5341 v8::Handle<v8::Uint32> index = str->ToArrayIndex(); |
5308 CHECK(!index.IsEmpty()); | 5342 CHECK(!index.IsEmpty()); |
(...skipping 9587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14896 } | 14930 } |
14897 | 14931 |
14898 i::Isolate::Current()->heap()->CollectAllGarbage(true); | 14932 i::Isolate::Current()->heap()->CollectAllGarbage(true); |
14899 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); | 14933 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); |
14900 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { | 14934 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { |
14901 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); | 14935 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); |
14902 CHECK_GT(elements, map_cache->NumberOfElements()); | 14936 CHECK_GT(elements, map_cache->NumberOfElements()); |
14903 } | 14937 } |
14904 } | 14938 } |
14905 } | 14939 } |
OLD | NEW |