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

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

Issue 1923523002: Version 5.1.281.18 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.1
Patch Set: Created 4 years, 7 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 | « src/x87/code-stubs-x87.cc ('k') | no next file » | 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 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 // .toString() throws on non-RegExps that aren't RegExp.prototype 1966 // .toString() throws on non-RegExps that aren't RegExp.prototype
1967 v8::Local<v8::Value> resultToStringError = CompileRun( 1967 v8::Local<v8::Value> resultToStringError = CompileRun(
1968 "var exception;" 1968 "var exception;"
1969 "try { RegExp.prototype.toString.call(null) }" 1969 "try { RegExp.prototype.toString.call(null) }"
1970 "catch (e) { exception = e; }" 1970 "catch (e) { exception = e; }"
1971 "exception"); 1971 "exception");
1972 CHECK_EQ(2, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); 1972 CHECK_EQ(2, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]);
1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); 1973 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]);
1974 CHECK(resultToStringError->IsObject()); 1974 CHECK(resultToStringError->IsObject());
1975 } 1975 }
1976
1977 class UncachedExternalString
1978 : public v8::String::ExternalOneByteStringResource {
1979 public:
1980 const char* data() const override { return "abcdefghijklmnopqrstuvwxyz"; }
1981 size_t length() const override { return 26; }
1982 bool IsCompressible() const override { return true; }
1983 };
1984
1985 TEST(UncachedExternalString) {
1986 v8::Isolate* isolate = CcTest::isolate();
1987 v8::HandleScope scope(isolate);
1988 LocalContext env;
1989 v8::Local<v8::String> external =
1990 v8::String::NewExternalOneByte(isolate, new UncachedExternalString())
1991 .ToLocalChecked();
1992 CHECK(v8::Utils::OpenHandle(*external)->map() ==
1993 CcTest::i_isolate()->heap()->short_external_one_byte_string_map());
1994 v8::Local<v8::Object> global = env->Global();
1995 global->Set(env.local(), v8_str("external"), external).FromJust();
1996 CompileRun("var re = /y(.)/; re.test('ab');");
1997 ExpectString("external.substring(1).match(re)[1]", "z");
1998 }
OLDNEW
« no previous file with comments | « src/x87/code-stubs-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698