OLD | NEW |
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 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 // .toString() throws on non-RegExps that aren't RegExp.prototype | 1960 // .toString() throws on non-RegExps that aren't RegExp.prototype |
1961 v8::Local<v8::Value> resultToStringError = CompileRun( | 1961 v8::Local<v8::Value> resultToStringError = CompileRun( |
1962 "var exception;" | 1962 "var exception;" |
1963 "try { RegExp.prototype.toString.call(null) }" | 1963 "try { RegExp.prototype.toString.call(null) }" |
1964 "catch (e) { exception = e; }" | 1964 "catch (e) { exception = e; }" |
1965 "exception"); | 1965 "exception"); |
1966 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1966 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1967 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1967 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1968 CHECK(resultToStringError->IsObject()); | 1968 CHECK(resultToStringError->IsObject()); |
1969 } | 1969 } |
| 1970 |
| 1971 class UncachedExternalString |
| 1972 : public v8::String::ExternalOneByteStringResource { |
| 1973 public: |
| 1974 const char* data() const override { return "abcdefghijklmnopqrstuvwxyz"; } |
| 1975 size_t length() const override { return 26; } |
| 1976 bool IsCompressible() const override { return true; } |
| 1977 }; |
| 1978 |
| 1979 TEST(UncachedExternalString) { |
| 1980 v8::Isolate* isolate = CcTest::isolate(); |
| 1981 v8::HandleScope scope(isolate); |
| 1982 LocalContext env; |
| 1983 v8::Local<v8::String> external = |
| 1984 v8::String::NewExternalOneByte(isolate, new UncachedExternalString()) |
| 1985 .ToLocalChecked(); |
| 1986 CHECK(v8::Utils::OpenHandle(*external)->map() == |
| 1987 CcTest::i_isolate()->heap()->short_external_one_byte_string_map()); |
| 1988 v8::Local<v8::Object> global = env->Global(); |
| 1989 global->Set(env.local(), v8_str("external"), external).FromJust(); |
| 1990 CompileRun("var re = /y(.)/; re.test('ab');"); |
| 1991 ExpectString("external.substring(1).match(re)[1]", "z"); |
| 1992 } |
OLD | NEW |