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

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

Issue 9298049: Improvements to v8::Value comments to make a little easier for new users to Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 11 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
===================================================================
--- test/cctest/test-api.cc (revision 10541)
+++ test/cctest/test-api.cc (working copy)
@@ -678,6 +678,7 @@
Local<Script> script = Script::Compile(source);
Local<Value> value = script->Run();
CHECK(value->IsNumber());
+ CHECK(!value->IsNumberObject());
CHECK_EQ(7, value->Int32Value());
HEAP->CollectAllAvailableGarbage();
CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
@@ -699,6 +700,7 @@
Local<Script> script = Script::Compile(source);
Local<Value> value = script->Run();
CHECK(value->IsNumber());
+ CHECK(!value->IsNumberObject());
CHECK_EQ(7, value->Int32Value());
HEAP->CollectAllAvailableGarbage();
CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count);
@@ -1045,9 +1047,13 @@
v8::HandleScope scope;
LocalContext env;
v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")");
+ CHECK(boxed_string->IsObject());
CHECK(boxed_string->IsStringObject());
+ CHECK(!boxed_string->IsString());
v8::Handle<Value> unboxed_string = CompileRun("\"test\"");
+ CHECK(!unboxed_string->IsObject());
CHECK(!unboxed_string->IsStringObject());
+ CHECK(unboxed_string->IsString());
v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)");
CHECK(!boxed_not_string->IsStringObject());
v8::Handle<Value> not_object = CompileRun("0");
@@ -1070,9 +1076,13 @@
v8::HandleScope scope;
LocalContext env;
v8::Handle<Value> boxed_number = CompileRun("new Number(42)");
+ CHECK(boxed_number->IsObject());
CHECK(boxed_number->IsNumberObject());
+ CHECK(!boxed_number->IsNumber());
v8::Handle<Value> unboxed_number = CompileRun("42");
+ CHECK(!unboxed_number->IsObject());
CHECK(!unboxed_number->IsNumberObject());
+ CHECK(unboxed_number->IsNumber());
v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)");
CHECK(!boxed_not_number->IsNumberObject());
v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>();
@@ -1091,9 +1101,14 @@
v8::HandleScope scope;
LocalContext env;
v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)");
+ CHECK(boxed_boolean->IsObject());
CHECK(boxed_boolean->IsBooleanObject());
+ CHECK(!boxed_boolean->IsTrue());
+ CHECK(!boxed_boolean->IsFalse());
+ CHECK(!boxed_boolean->IsBoolean());
v8::Handle<Value> unboxed_boolean = CompileRun("true");
CHECK(!unboxed_boolean->IsBooleanObject());
+ CHECK(unboxed_boolean->IsBoolean());
v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)");
CHECK(!boxed_not_boolean->IsBooleanObject());
v8::Handle<v8::BooleanObject> as_boxed =
@@ -1138,6 +1153,8 @@
LocalContext env;
double PI = 3.1415926;
Local<Value> date = v8::Date::New(PI);
+ CHECK(date->IsObject());
+ CHECK(date->IsDate());
CHECK_EQ(3.0, date->NumberValue());
date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42));
CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value());
@@ -1149,8 +1166,18 @@
LocalContext env;
v8::Handle<v8::Boolean> t = v8::True();
CHECK(t->Value());
+ CHECK(t->IsTrue());
+ CHECK(!t->IsFalse());
+ CHECK(t->IsBoolean());
+ CHECK(!t->IsObject());
+ CHECK(!t->IsBooleanObject());
v8::Handle<v8::Boolean> f = v8::False();
CHECK(!f->Value());
+ CHECK(!f->IsTrue());
+ CHECK(f->IsFalse());
+ CHECK(f->IsBoolean());
+ CHECK(!f->IsObject());
+ CHECK(!f->IsBooleanObject());
v8::Handle<v8::Primitive> u = v8::Undefined();
CHECK(!u->BooleanValue());
v8::Handle<v8::Primitive> n = v8::Null();
@@ -2493,6 +2520,8 @@
v8::HandleScope scope;
LocalContext context;
Local<v8::Array> array = v8::Array::New();
+ CHECK(array->IsObject());
+ CHECK(array->IsArray());
CHECK_EQ(0, array->Length());
CHECK(array->Get(0)->IsUndefined());
CHECK(!array->Has(0));
@@ -2506,6 +2535,8 @@
CHECK_EQ(7, array->Get(2)->Int32Value());
Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run();
Local<v8::Array> arr = obj.As<v8::Array>();
+ CHECK(arr->IsObject());
+ CHECK(arr->IsArray());
CHECK_EQ(3, arr->Length());
CHECK_EQ(1, arr->Get(0)->Int32Value());
CHECK_EQ(2, arr->Get(1)->Int32Value());
@@ -15153,6 +15184,7 @@
LocalContext context;
v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone);
+ CHECK(re->IsObject());
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("foo")));
CHECK_EQ(v8::RegExp::kNone, re->GetFlags());
@@ -15160,6 +15192,7 @@
re = v8::RegExp::New(v8_str("bar"),
static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
v8::RegExp::kGlobal));
+ CHECK(re->IsObject());
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("bar")));
CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal,
@@ -15168,17 +15201,20 @@
re = v8::RegExp::New(v8_str("baz"),
static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
v8::RegExp::kMultiline));
+ CHECK(re->IsObject());
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("baz")));
CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,
static_cast<int>(re->GetFlags()));
re = CompileRun("/quux/").As<v8::RegExp>();
+ CHECK(re->IsObject());
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("quux")));
CHECK_EQ(v8::RegExp::kNone, re->GetFlags());
re = CompileRun("/quux/gm").As<v8::RegExp>();
+ CHECK(re->IsObject());
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("quux")));
CHECK_EQ(v8::RegExp::kGlobal | v8::RegExp::kMultiline,
@@ -15189,6 +15225,7 @@
CompileRun("RegExp = function() {}");
re = v8::RegExp::New(v8_str("foobar"), v8::RegExp::kNone);
+ CHECK(re->IsObject());
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("foobar")));
CHECK_EQ(v8::RegExp::kNone, re->GetFlags());
@@ -15196,6 +15233,7 @@
re = v8::RegExp::New(v8_str("foobarbaz"),
static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
v8::RegExp::kMultiline));
+ CHECK(re->IsObject());
CHECK(re->IsRegExp());
CHECK(re->GetSource()->Equals(v8_str("foobarbaz")));
CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,
« 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