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

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

Issue 16365008: ReturnValue::Set(uint32_t) is wrong (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added tests 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
« include/v8.h ('K') | « 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 bc72e37154fc18f352c328e6e46dc34a526e849b..81db16d9ca9b19fb8ae59d80d4319c08890c1bd9 100755
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -1025,8 +1025,8 @@ template<typename T>
void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info);
// constant return values
-static const int32_t kFastReturnValueInt32 = 471;
-static const uint32_t kFastReturnValueUint32 = 571;
+static int32_t fast_return_value_int32 = 471;
+static uint32_t fast_return_value_uint32 = 571;
static const double kFastReturnValueDouble = 2.7;
// variable return values
static bool fast_return_value_bool = false;
@@ -1037,14 +1037,14 @@ template<>
void FastReturnValueCallback<int32_t>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
CheckReturnValue(info);
- info.GetReturnValue().Set(kFastReturnValueInt32);
+ info.GetReturnValue().Set(fast_return_value_int32);
}
template<>
void FastReturnValueCallback<uint32_t>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
CheckReturnValue(info);
- info.GetReturnValue().Set(kFastReturnValueUint32);
+ info.GetReturnValue().Set(fast_return_value_uint32);
}
template<>
@@ -1093,16 +1093,26 @@ Handle<Value> TestFastReturnValues() {
}
THREADED_TEST(FastReturnValues) {
+ LocalContext env;
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Handle<v8::Value> value;
- // check int_32
- value = TestFastReturnValues<int32_t>();
- CHECK(value->IsInt32());
- CHECK_EQ(kFastReturnValueInt32, value->Int32Value());
- // check uint32_t
- value = TestFastReturnValues<uint32_t>();
- CHECK(value->IsInt32());
- CHECK_EQ(kFastReturnValueUint32, value->Int32Value());
+ // check int32_t and uint32_t
+ int32_t int_values[] = {
+ 0, 1, -1, 234, -723,
+ i::Smi::kMinValue, i::Smi::kMinValue-1,
+ i::Smi::kMaxValue, i::Smi::kMaxValue+1};
+ for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) {
+ // check int32_t
+ fast_return_value_int32 = int_values[i];
+ value = TestFastReturnValues<int32_t>();
+ CHECK(value->IsInt32());
+ CHECK(fast_return_value_int32 == value->Int32Value());
+ // check uint32_t
+ fast_return_value_uint32 = static_cast<uint32_t>(int_values[i]);
+ value = TestFastReturnValues<uint32_t>();
+ CHECK(value->IsUint32());
+ CHECK(fast_return_value_uint32 == value->Uint32Value());
+ }
// check double
value = TestFastReturnValues<double>();
CHECK(value->IsNumber());
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698