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

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

Issue 251100: Introduce v8::Integer::NewFromUnsigned method. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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 | « src/x64/macro-assembler-x64.cc ('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
===================================================================
--- test/cctest/test-api.cc (revision 3030)
+++ test/cctest/test-api.cc (working copy)
@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdlib.h>
-
#include "v8.h"
#include "api.h"
@@ -702,6 +700,79 @@
}
+THREADED_TEST(TinyInteger) {
+ v8::HandleScope scope;
+ LocalContext env;
+ int32_t value = 239;
+ Local<v8::Integer> value_obj = v8::Integer::New(value);
+ CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
+}
+
+
+THREADED_TEST(BigSmiInteger) {
+ v8::HandleScope scope;
+ LocalContext env;
+ int32_t value = i::Smi::kMaxValue;
+ CHECK(i::Smi::IsValid(value));
+ CHECK(!i::Smi::IsValid(value + 1));
+ Local<v8::Integer> value_obj = v8::Integer::New(value);
+ CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
+}
+
+
+THREADED_TEST(BigInteger) {
+ v8::HandleScope scope;
+ LocalContext env;
+ int32_t value = i::Smi::kMaxValue + 1;
+ CHECK(value > i::Smi::kMaxValue);
+ CHECK(!i::Smi::IsValid(value));
+ Local<v8::Integer> value_obj = v8::Integer::New(value);
+ CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
+}
+
+
+THREADED_TEST(TinyUnsignedInteger) {
+ v8::HandleScope scope;
+ LocalContext env;
+ uint32_t value = 239;
+ Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
+ CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
+}
+
+
+THREADED_TEST(BigUnsignedSmiInteger) {
+ v8::HandleScope scope;
+ LocalContext env;
+ uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue);
+ CHECK(i::Smi::IsValid(value));
+ CHECK(!i::Smi::IsValid(value + 1));
+ Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
+ CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
+}
+
+
+THREADED_TEST(BigUnsignedInteger) {
+ v8::HandleScope scope;
+ LocalContext env;
+ uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1;
+ CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue));
+ CHECK(!i::Smi::IsValid(value));
+ Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
+ CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
+}
+
+
+THREADED_TEST(OutOfSignedRangeUnsignedInteger) {
+ v8::HandleScope scope;
+ LocalContext env;
+ uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1;
+ uint32_t value = INT32_MAX_AS_UINT + 1;
+ CHECK(value > INT32_MAX_AS_UINT); // No overflow.
+ Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
+ CHECK_EQ(static_cast<int64_t>(value), value_obj->Value());
+}
+
+
THREADED_TEST(Number) {
v8::HandleScope scope;
LocalContext env;
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698