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

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

Issue 2624203002: Version 5.7.440.1 (cherry-pick) (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « test/cctest/test-code-stub-assembler.cc ('k') | test/mjsunit/thin-strings.js » ('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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 public: 1188 public:
1189 explicit OneByteVectorResource(i::Vector<const char> vector) 1189 explicit OneByteVectorResource(i::Vector<const char> vector)
1190 : data_(vector) {} 1190 : data_(vector) {}
1191 virtual ~OneByteVectorResource() {} 1191 virtual ~OneByteVectorResource() {}
1192 virtual size_t length() const { return data_.length(); } 1192 virtual size_t length() const { return data_.length(); }
1193 virtual const char* data() const { return data_.start(); } 1193 virtual const char* data() const { return data_.start(); }
1194 private: 1194 private:
1195 i::Vector<const char> data_; 1195 i::Vector<const char> data_;
1196 }; 1196 };
1197 1197
1198 TEST(InternalizeExternal) {
1199 i::Isolate* isolate = CcTest::i_isolate();
1200 Factory* factory = isolate->factory();
1201 // This won't leak; the external string mechanism will call Dispose() on it.
1202 OneByteVectorResource* resource =
1203 new OneByteVectorResource(i::Vector<const char>("prop", 4));
1204 {
1205 v8::HandleScope scope(CcTest::isolate());
1206 v8::Local<v8::String> ext_string =
1207 v8::String::NewExternalOneByte(CcTest::isolate(), resource)
1208 .ToLocalChecked();
1209 Handle<String> string = v8::Utils::OpenHandle(*ext_string);
1210 CHECK(string->IsExternalString());
1211 CHECK(!string->IsInternalizedString());
1212 CHECK(isolate->heap()->InNewSpace(*string));
1213 factory->InternalizeName(string);
1214 CHECK(string->IsThinString());
1215 CcTest::CollectGarbage(i::NEW_SPACE);
1216 CcTest::CollectGarbage(i::NEW_SPACE);
1217 CHECK(string->IsInternalizedString());
1218 CHECK(!isolate->heap()->InNewSpace(*string));
1219 }
1220 CcTest::CollectGarbage(i::OLD_SPACE);
1221 CcTest::CollectGarbage(i::OLD_SPACE);
1222 }
1223 1198
1224 TEST(SliceFromExternal) { 1199 TEST(SliceFromExternal) {
1225 FLAG_string_slices = true; 1200 FLAG_string_slices = true;
1226 CcTest::InitializeVM(); 1201 CcTest::InitializeVM();
1227 Factory* factory = CcTest::i_isolate()->factory(); 1202 Factory* factory = CcTest::i_isolate()->factory();
1228 v8::HandleScope scope(CcTest::isolate()); 1203 v8::HandleScope scope(CcTest::isolate());
1229 OneByteVectorResource resource( 1204 OneByteVectorResource resource(
1230 i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26)); 1205 i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
1231 Handle<String> string = 1206 Handle<String> string =
1232 factory->NewExternalStringFromOneByte(&resource).ToHandleChecked(); 1207 factory->NewExternalStringFromOneByte(&resource).ToHandleChecked();
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 CHECK_EQ(1, CompileRun("external.indexOf('', 1)") 1637 CHECK_EQ(1, CompileRun("external.indexOf('', 1)")
1663 ->Int32Value(context.local()) 1638 ->Int32Value(context.local())
1664 .FromJust()); 1639 .FromJust());
1665 CHECK_EQ(-1, CompileRun("external.indexOf('a', 1)") 1640 CHECK_EQ(-1, CompileRun("external.indexOf('a', 1)")
1666 ->Int32Value(context.local()) 1641 ->Int32Value(context.local())
1667 .FromJust()); 1642 .FromJust());
1668 CHECK_EQ(-1, CompileRun("external.indexOf('$')") 1643 CHECK_EQ(-1, CompileRun("external.indexOf('$')")
1669 ->Int32Value(context.local()) 1644 ->Int32Value(context.local())
1670 .FromJust()); 1645 .FromJust());
1671 } 1646 }
OLDNEW
« no previous file with comments | « test/cctest/test-code-stub-assembler.cc ('k') | test/mjsunit/thin-strings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698