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

Side by Side Diff: test/cctest/test-api.cc

Issue 228093004: Implement handlified String::Flatten. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: even shorter Created 6 years, 8 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 | « src/runtime.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 7571 matching lines...) Expand 10 before | Expand all | Expand 10 after
7582 a++; 7582 a++;
7583 b++; 7583 b++;
7584 } 7584 }
7585 } 7585 }
7586 7586
7587 7587
7588 int GetUtf8Length(Handle<String> str) { 7588 int GetUtf8Length(Handle<String> str) {
7589 int len = str->Utf8Length(); 7589 int len = str->Utf8Length();
7590 if (len < 0) { 7590 if (len < 0) {
7591 i::Handle<i::String> istr(v8::Utils::OpenHandle(*str)); 7591 i::Handle<i::String> istr(v8::Utils::OpenHandle(*str));
7592 i::FlattenString(istr); 7592 i::String::Flatten(istr);
7593 len = str->Utf8Length(); 7593 len = str->Utf8Length();
7594 } 7594 }
7595 return len; 7595 return len;
7596 } 7596 }
7597 7597
7598 7598
7599 THREADED_TEST(StringWrite) { 7599 THREADED_TEST(StringWrite) {
7600 LocalContext context; 7600 LocalContext context;
7601 v8::HandleScope scope(context->GetIsolate()); 7601 v8::HandleScope scope(context->GetIsolate());
7602 v8::Handle<String> str = v8_str("abcde"); 7602 v8::Handle<String> str = v8_str("abcde");
(...skipping 11325 matching lines...) Expand 10 before | Expand all | Expand 10 after
18928 Local<Value> result = CompileRun(init_code); 18928 Local<Value> result = CompileRun(init_code);
18929 18929
18930 Local<Value> indexof = CompileRun("str2.indexOf('els')"); 18930 Local<Value> indexof = CompileRun("str2.indexOf('els')");
18931 Local<Value> lastindexof = CompileRun("str2.lastIndexOf('dab')"); 18931 Local<Value> lastindexof = CompileRun("str2.lastIndexOf('dab')");
18932 18932
18933 CHECK(result->IsString()); 18933 CHECK(result->IsString());
18934 i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result)); 18934 i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result));
18935 int length = string->length(); 18935 int length = string->length();
18936 CHECK(string->IsOneByteRepresentation()); 18936 CHECK(string->IsOneByteRepresentation());
18937 18937
18938 FlattenString(string); 18938 i::Handle<i::String> flat_string = i::String::Flatten(string);
18939 i::Handle<i::String> flat_string = FlattenGetString(string);
18940 18939
18941 CHECK(string->IsOneByteRepresentation()); 18940 CHECK(string->IsOneByteRepresentation());
18942 CHECK(flat_string->IsOneByteRepresentation()); 18941 CHECK(flat_string->IsOneByteRepresentation());
18943 18942
18944 // Create external resource. 18943 // Create external resource.
18945 uint16_t* uc16_buffer = new uint16_t[length + 1]; 18944 uint16_t* uc16_buffer = new uint16_t[length + 1];
18946 18945
18947 i::String::WriteToFlat(*flat_string, uc16_buffer, 0, length); 18946 i::String::WriteToFlat(*flat_string, uc16_buffer, 0, length);
18948 uc16_buffer[length] = 0; 18947 uc16_buffer[length] = 0;
18949 18948
(...skipping 3443 matching lines...) Expand 10 before | Expand all | Expand 10 after
22393 "f.call(friend);"); 22392 "f.call(friend);");
22394 CHECK_EQ(2, named_access_count); 22393 CHECK_EQ(2, named_access_count);
22395 22394
22396 // Test access using Object.setPrototypeOf reflective method. 22395 // Test access using Object.setPrototypeOf reflective method.
22397 named_access_count = 0; 22396 named_access_count = 0;
22398 CompileRun("Object.setPrototypeOf(friend, {});"); 22397 CompileRun("Object.setPrototypeOf(friend, {});");
22399 CHECK_EQ(1, named_access_count); 22398 CHECK_EQ(1, named_access_count);
22400 CompileRun("Object.getPrototypeOf(friend);"); 22399 CompileRun("Object.getPrototypeOf(friend);");
22401 CHECK_EQ(2, named_access_count); 22400 CHECK_EQ(2, named_access_count);
22402 } 22401 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698