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

Unified Diff: test/cctest/cctest.h

Issue 310063002: Add tests for FuncNameInferrer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 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 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 01d765e2b26c7a3641b1c5a8546cb4917596f346..1ada105f5693361b88e25ea46d104637feb92235 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -311,6 +311,15 @@ class LocalContext {
v8::Isolate* isolate_;
};
+
+static inline uint16_t* AsciiToTwoByteString(const char* source) {
+ int array_length = i::StrLength(source) + 1;
+ uint16_t* converted = i::NewArray<uint16_t>(array_length);
+ for (int i = 0; i < array_length; i++) converted[i] = source[i];
+ return converted;
+}
+
+
static inline v8::Local<v8::Value> v8_num(double x) {
return v8::Number::New(v8::Isolate::GetCurrent(), x);
}
@@ -403,6 +412,52 @@ static inline v8::Local<v8::Value> CompileRunWithOrigin(
}
+
+static inline void ExpectString(const char* code, const char* expected) {
+ v8::Local<v8::Value> result = CompileRun(code);
+ CHECK(result->IsString());
+ v8::String::Utf8Value utf8(result);
+ CHECK_EQ(expected, *utf8);
+}
+
+
+static inline void ExpectInt32(const char* code, int expected) {
+ v8::Local<v8::Value> result = CompileRun(code);
+ CHECK(result->IsInt32());
+ CHECK_EQ(expected, result->Int32Value());
+}
+
+
+static inline void ExpectBoolean(const char* code, bool expected) {
+ v8::Local<v8::Value> result = CompileRun(code);
+ CHECK(result->IsBoolean());
+ CHECK_EQ(expected, result->BooleanValue());
+}
+
+
+static inline void ExpectTrue(const char* code) {
+ ExpectBoolean(code, true);
+}
+
+
+static inline void ExpectFalse(const char* code) {
+ ExpectBoolean(code, false);
+}
+
+
+static inline void ExpectObject(const char* code,
+ v8::Local<v8::Value> expected) {
+ v8::Local<v8::Value> result = CompileRun(code);
+ CHECK(result->SameValue(expected));
+}
+
+
+static inline void ExpectUndefined(const char* code) {
+ v8::Local<v8::Value> result = CompileRun(code);
+ CHECK(result->IsUndefined());
+}
+
+
// Helper function that simulates a full new-space in the heap.
static inline void SimulateFullSpace(v8::internal::NewSpace* space) {
int new_linear_size = static_cast<int>(
« 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