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

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

Issue 239143003: Remove further unhandlified call sites of number allocations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/objects-inl.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-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index eec5264eb8c4b9c46c600d9f617087eeb8cbbd69..2fe601e7840dfba9a38c4df79e1b36e46154a5bf 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -99,12 +99,11 @@ static void CheckSmi(Isolate* isolate, int value, const char* string) {
static void CheckNumber(Isolate* isolate, double value, const char* string) {
- Object* obj = CcTest::heap()->NumberFromDouble(value)->ToObjectChecked();
- CHECK(obj->IsNumber());
- Handle<Object> handle(obj, isolate);
- Object* print_string =
- *Execution::ToString(isolate, handle).ToHandleChecked();
- CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
+ Handle<Object> number = isolate->factory()->NewNumber(value);
+ CHECK(number->IsNumber());
+ Handle<Object> print_string =
+ Execution::ToString(isolate, number).ToHandleChecked();
+ CHECK(String::cast(*print_string)->IsUtf8EqualTo(CStrVector(string)));
}
@@ -162,57 +161,54 @@ TEST(HeapObjects) {
Heap* heap = isolate->heap();
HandleScope sc(isolate);
- Object* value = heap->NumberFromDouble(1.000123)->ToObjectChecked();
+ Handle<Object> value = factory->NewNumber(1.000123);
CHECK(value->IsHeapNumber());
CHECK(value->IsNumber());
CHECK_EQ(1.000123, value->Number());
- value = heap->NumberFromDouble(1.0)->ToObjectChecked();
+ value = factory->NewNumber(1.0);
CHECK(value->IsSmi());
CHECK(value->IsNumber());
CHECK_EQ(1.0, value->Number());
- value = heap->NumberFromInt32(1024)->ToObjectChecked();
+ value = factory->NewNumberFromInt(1024);
CHECK(value->IsSmi());
CHECK(value->IsNumber());
CHECK_EQ(1024.0, value->Number());
- value = heap->NumberFromInt32(Smi::kMinValue)->ToObjectChecked();
+ value = factory->NewNumberFromInt(Smi::kMinValue);
CHECK(value->IsSmi());
CHECK(value->IsNumber());
- CHECK_EQ(Smi::kMinValue, Smi::cast(value)->value());
+ CHECK_EQ(Smi::kMinValue, Handle<Smi>::cast(value)->value());
- value = heap->NumberFromInt32(Smi::kMaxValue)->ToObjectChecked();
+ value = factory->NewNumberFromInt(Smi::kMaxValue);
CHECK(value->IsSmi());
CHECK(value->IsNumber());
- CHECK_EQ(Smi::kMaxValue, Smi::cast(value)->value());
+ CHECK_EQ(Smi::kMaxValue, Handle<Smi>::cast(value)->value());
#if !defined(V8_TARGET_ARCH_X64) && !defined(V8_TARGET_ARCH_ARM64)
// TODO(lrn): We need a NumberFromIntptr function in order to test this.
- value = heap->NumberFromInt32(Smi::kMinValue - 1)->ToObjectChecked();
+ value = factory->NewNumberFromInt(Smi::kMinValue - 1);
CHECK(value->IsHeapNumber());
CHECK(value->IsNumber());
CHECK_EQ(static_cast<double>(Smi::kMinValue - 1), value->Number());
#endif
- MaybeObject* maybe_value =
- heap->NumberFromUint32(static_cast<uint32_t>(Smi::kMaxValue) + 1);
- value = maybe_value->ToObjectChecked();
+ value = factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
CHECK(value->IsHeapNumber());
CHECK(value->IsNumber());
CHECK_EQ(static_cast<double>(static_cast<uint32_t>(Smi::kMaxValue) + 1),
value->Number());
- maybe_value = heap->NumberFromUint32(static_cast<uint32_t>(1) << 31);
- value = maybe_value->ToObjectChecked();
+ value = factory->NewNumberFromUint(static_cast<uint32_t>(1) << 31);
CHECK(value->IsHeapNumber());
CHECK(value->IsNumber());
CHECK_EQ(static_cast<double>(static_cast<uint32_t>(1) << 31),
value->Number());
// nan oddball checks
- CHECK(heap->nan_value()->IsNumber());
- CHECK(std::isnan(heap->nan_value()->Number()));
+ CHECK(factory->nan_value()->IsNumber());
+ CHECK(std::isnan(factory->nan_value()->Number()));
Handle<String> s = factory->NewStringFromAscii(CStrVector("fisk hest "));
CHECK(s->IsString());
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698