Chromium Code Reviews| Index: test/cctest/test-strings.cc |
| diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc |
| index 55c21417d0edeb5df29090f3280ac9580cc003bd..bc69d63d2f06d7ad7795e2cee73e0c24f6e71cbd 100644 |
| --- a/test/cctest/test-strings.cc |
| +++ b/test/cctest/test-strings.cc |
| @@ -502,6 +502,36 @@ TEST(SliceFromCons) { |
| } |
| +class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { |
| + public: |
| + explicit AsciiVectorResource(i::Vector<const char> vector) |
| + : data_(vector) {} |
| + virtual ~AsciiVectorResource() {} |
| + virtual size_t length() const { return data_.length(); } |
| + virtual const char* data() const { return data_.start(); } |
| + private: |
| + i::Vector<const char> data_; |
| +}; |
| + |
| + |
| +TEST(SliceFromExternal) { |
|
Vitaly Repeshko
2011/09/13 18:20:25
Do we have a test for the case of the underlying s
Yang
2011/09/15 11:01:22
Both the cctest test-api/MorphCompositeStringTest
|
| + FLAG_string_slices = true; |
| + InitializeVM(); |
| + v8::HandleScope scope; |
| + AsciiVectorResource resource( |
| + i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26)); |
| + Handle<String> string = FACTORY->NewExternalStringFromAscii(&resource); |
| + CHECK(string->IsExternalString()); |
| + Handle<String> slice = FACTORY->NewSubString(string, 1, 25); |
| + // After slicing, the original string becomes a flat cons. |
|
Vitaly Repeshko
2011/09/13 18:20:25
Update the comment.
|
| + CHECK(slice->IsSlicedString()); |
| + CHECK(string->IsExternalString()); |
| + CHECK_EQ(SlicedString::cast(*slice)->parent(), *string); |
| + CHECK(SlicedString::cast(*slice)->parent()->IsExternalString()); |
| + CHECK(slice->IsFlat()); |
| +} |
| + |
| + |
| TEST(TrivialSlice) { |
| // This tests whether a slice that contains the entire parent string |
| // actually creates a new string (it should not). |