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

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

Issue 21013003: Added unit tests for the slightly confusing Boolean/BooleanObject API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed copy-n-paste typo Created 7 years, 5 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 | 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 7cb3c04087b69d5238b904861e20d4aaf75fc3fa..e25642ed948b054c63f0c205467930d786fe982a 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -55,6 +55,8 @@ static const bool kLogThreading = false;
using ::v8::AccessorInfo;
using ::v8::Arguments;
+using ::v8::Boolean;
+using ::v8::BooleanObject;
using ::v8::Context;
using ::v8::Extension;
using ::v8::Function;
@@ -1544,6 +1546,54 @@ THREADED_TEST(BooleanObject) {
}
+THREADED_TEST(PrimitiveAndWrappedBooleans) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+ Local<Value> primitive_false = Boolean::New(false);
+ CHECK(primitive_false->IsBoolean());
+ CHECK(!primitive_false->IsBooleanObject());
+ CHECK(!primitive_false->BooleanValue());
+ CHECK(!primitive_false->IsTrue());
+ CHECK(primitive_false->IsFalse());
+
+ Local<Value> false_value = BooleanObject::New(false);
+ CHECK(!false_value->IsBoolean());
+ CHECK(false_value->IsBooleanObject());
+ CHECK(false_value->BooleanValue());
+ CHECK(!false_value->IsTrue());
+ CHECK(!false_value->IsFalse());
+
+ Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>();
+ CHECK(!false_boolean_object->IsBoolean());
+ CHECK(false_boolean_object->IsBooleanObject());
+ CHECK(!false_boolean_object->BooleanValue());
+ CHECK(!false_boolean_object->IsTrue());
+ CHECK(!false_boolean_object->IsFalse());
+
+ Local<Value> primitive_true = Boolean::New(true);
+ CHECK(primitive_true->IsBoolean());
+ CHECK(!primitive_true->IsBooleanObject());
+ CHECK(primitive_true->BooleanValue());
+ CHECK(primitive_true->IsTrue());
+ CHECK(!primitive_true->IsFalse());
+
+ Local<Value> true_value = BooleanObject::New(true);
+ CHECK(!true_value->IsBoolean());
+ CHECK(true_value->IsBooleanObject());
+ CHECK(true_value->BooleanValue());
+ CHECK(!true_value->IsTrue());
+ CHECK(!true_value->IsFalse());
+
+ Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>();
+ CHECK(!true_boolean_object->IsBoolean());
+ CHECK(true_boolean_object->IsBooleanObject());
+ CHECK(true_boolean_object->BooleanValue());
+ CHECK(!true_boolean_object->IsTrue());
+ CHECK(!true_boolean_object->IsFalse());
+}
+
+
THREADED_TEST(Number) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698