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

Unified Diff: test/cctest/test-api.cc

Issue 16621004: make empty string returnable by ReturnValue (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nit Created 7 years, 6 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 | « include/v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index a69fe902a4293740a692416e4f4b5c0b57b08f5c..f5e315bad101c850f0cfa3d9d9e78dbaa8c954d2 100755
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -1037,7 +1037,12 @@ static uint32_t fast_return_value_uint32 = 571;
static const double kFastReturnValueDouble = 2.7;
// variable return values
static bool fast_return_value_bool = false;
-static bool fast_return_value_void_is_null = false;
+enum ReturnValueOddball {
+ kNullReturnValue,
+ kUndefinedReturnValue,
+ kEmptyStringReturnValue
+};
+static ReturnValueOddball fast_return_value_void;
static bool fast_return_value_object_is_empty = false;
template<>
@@ -1072,10 +1077,16 @@ template<>
void FastReturnValueCallback<void>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
CheckReturnValue(info);
- if (fast_return_value_void_is_null) {
- info.GetReturnValue().SetNull();
- } else {
- info.GetReturnValue().SetUndefined();
+ switch (fast_return_value_void) {
+ case kNullReturnValue:
+ info.GetReturnValue().SetNull();
+ break;
+ case kUndefinedReturnValue:
+ info.GetReturnValue().SetUndefined();
+ break;
+ case kEmptyStringReturnValue:
+ info.GetReturnValue().SetEmptyString();
+ break;
}
}
@@ -1135,13 +1146,25 @@ THREADED_TEST(FastReturnValues) {
CHECK_EQ(fast_return_value_bool, value->ToBoolean()->Value());
}
// check oddballs
- for (int i = 0; i < 2; i++) {
- fast_return_value_void_is_null = i == 0;
+ ReturnValueOddball oddballs[] = {
+ kNullReturnValue,
+ kUndefinedReturnValue,
+ kEmptyStringReturnValue
+ };
+ for (size_t i = 0; i < ARRAY_SIZE(oddballs); i++) {
+ fast_return_value_void = oddballs[i];
value = TestFastReturnValues<void>();
- if (fast_return_value_void_is_null) {
- CHECK(value->IsNull());
- } else {
- CHECK(value->IsUndefined());
+ switch (fast_return_value_void) {
+ case kNullReturnValue:
+ CHECK(value->IsNull());
+ break;
+ case kUndefinedReturnValue:
+ CHECK(value->IsUndefined());
+ break;
+ case kEmptyStringReturnValue:
+ CHECK(value->IsString());
+ CHECK_EQ(0, v8::String::Cast(*value)->Length());
+ break;
}
}
// check handles
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698