OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/factory.h" |
| 6 #include "src/handles-inl.h" |
| 7 #include "test/unittests/test-utils.h" |
| 8 #include "testing/gmock-support.h" |
| 9 |
| 10 using testing::BitEq; |
| 11 |
| 12 namespace v8 { |
| 13 namespace internal { |
| 14 |
| 15 typedef TestWithIsolate FactoryTest; |
| 16 |
| 17 |
| 18 namespace { |
| 19 |
| 20 const PretenureFlag kPretenureFlags[] = {TENURED, NOT_TENURED}; |
| 21 |
| 22 } // namespace |
| 23 |
| 24 |
| 25 TEST_F(FactoryTest, MinusZeroValue) { |
| 26 Handle<Object> minus_zero_value = factory()->minus_zero_value(); |
| 27 EXPECT_TRUE(minus_zero_value->IsHeapNumber()); |
| 28 EXPECT_THAT(minus_zero_value->Number(), BitEq(-0.0)); |
| 29 } |
| 30 |
| 31 |
| 32 TEST_F(FactoryTest, NewNumberWithMinusZero) { |
| 33 Handle<Object> minus_zero_value = factory()->minus_zero_value(); |
| 34 TRACED_FOREACH(PretenureFlag, pretenure_flag, kPretenureFlags) { |
| 35 EXPECT_TRUE(minus_zero_value.is_identical_to( |
| 36 factory()->NewNumber(-0.0, pretenure_flag))); |
| 37 } |
| 38 } |
| 39 |
| 40 |
| 41 TEST_F(FactoryTest, NewHeapNumberWithMinusZero) { |
| 42 TRACED_FOREACH(PretenureFlag, pretenure_flag, kPretenureFlags) { |
| 43 Handle<Object> value = |
| 44 factory()->NewHeapNumber(-0.0, IMMUTABLE, pretenure_flag); |
| 45 EXPECT_TRUE(value->IsHeapNumber()); |
| 46 EXPECT_THAT(value->Number(), BitEq(-0.0)); |
| 47 EXPECT_FALSE(value.is_identical_to(factory()->minus_zero_value())); |
| 48 } |
| 49 } |
| 50 |
| 51 } // namespace internal |
| 52 } // namespace v8 |
OLD | NEW |