Index: test/cctest/test-regexp.cc |
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc |
index 29c227d3a85eccde7979cda21de511cf47299779..0a153b78e05b145d822ba65656bd42807a369232 100644 |
--- a/test/cctest/test-regexp.cc |
+++ b/test/cctest/test-regexp.cc |
@@ -1973,3 +1973,26 @@ TEST(UseCountRegExp) { |
CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
CHECK(resultToStringError->IsObject()); |
} |
+ |
+class UncachedExternalString |
+ : public v8::String::ExternalOneByteStringResource { |
+ public: |
+ const char* data() const override { return "abcdefghijklmnopqrstuvwxyz"; } |
+ size_t length() const override { return 26; } |
+ bool IsCompressible() const override { return true; } |
+}; |
+ |
+TEST(UncachedExternalString) { |
+ v8::Isolate* isolate = CcTest::isolate(); |
+ v8::HandleScope scope(isolate); |
+ LocalContext env; |
+ v8::Local<v8::String> external = |
+ v8::String::NewExternalOneByte(isolate, new UncachedExternalString()) |
+ .ToLocalChecked(); |
+ CHECK(v8::Utils::OpenHandle(*external)->map() == |
+ CcTest::i_isolate()->heap()->short_external_one_byte_string_map()); |
+ v8::Local<v8::Object> global = env->Global(); |
+ global->Set(env.local(), v8_str("external"), external).FromJust(); |
+ CompileRun("var re = /y(.)/; re.test('ab');"); |
+ ExpectString("external.substring(1).match(re)[1]", "z"); |
+} |