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

Unified Diff: test/cctest/cctest.h

Issue 190503002: Refactor script compilation / running & use of helper funcs in test-api.cc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/cctest.h
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index a4991a5a19711f8d71c2a38a151b9c953d815aac..c4066d0bde192efbbd7b52c0dbe7d6695cbd90aa 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -308,10 +308,33 @@ static inline v8::Local<v8::Script> v8_compile(const char* x) {
}
-// Helper function that compiles and runs the source.
+static inline v8::Local<v8::Script> v8_compile(v8::Local<v8::String> x) {
+ return v8::Script::Compile(x);
+}
+
+
+static inline v8::Local<v8::Script> CompileWithOrigin(const char* source,
+ const char* origin_url) {
+ v8::ScriptOrigin origin(v8_str(origin_url));
+ return v8::Script::Compile(v8_str(source), &origin);
+}
+
+
+static inline v8::Local<v8::Script> CompileWithOrigin(
+ v8::Local<v8::String> source, const char* origin_url) {
+ v8::ScriptOrigin origin(v8_str(origin_url));
+ return v8::Script::Compile(source, &origin);
+}
+
+
+// Helper functions that compile and run the source.
static inline v8::Local<v8::Value> CompileRun(const char* source) {
- return v8::Script::Compile(
- v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run();
+ return v8::Script::Compile(v8_str(source))->Run();
+}
+
+
+static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) {
+ return v8::Script::Compile(source)->Run();
}
@@ -327,17 +350,23 @@ static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) {
}
-// Helper function that compiles and runs the source with given origin.
+// Helper functions that compile and run the source with given origin.
static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
const char* origin_url,
int line_number,
int column_number) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url),
+ v8::ScriptOrigin origin(v8_str(origin_url),
v8::Integer::New(isolate, line_number),
v8::Integer::New(isolate, column_number));
- return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin)
- ->Run();
+ return v8::Script::Compile(v8_str(source), &origin)->Run();
+}
+
+
+static inline v8::Local<v8::Value> CompileRunWithOrigin(
+ const char* source, const char* origin_url) {
+ v8::ScriptOrigin origin(v8_str(origin_url));
+ return v8::Script::Compile(v8_str(source), &origin)->Run();
}
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698