Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/objects.h" | 7 #include "src/objects.h" |
| 8 #include "src/ostreams.h" | 8 #include "src/ostreams.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| 11 using namespace v8::internal; | 11 using namespace v8::internal; |
| 12 | 12 |
| 13 | 13 |
| 14 TEST(SameValue) { | 14 TEST(SameValue) { |
|
rossberg
2015/07/29 14:37:56
Any reason not to test the other types, too?
bbudge
2015/07/30 13:46:58
I just forgot about these. Done.
| |
| 15 CcTest::InitializeVM(); | 15 CcTest::InitializeVM(); |
| 16 Isolate* isolate = CcTest::i_isolate(); | 16 Isolate* isolate = CcTest::i_isolate(); |
| 17 Factory* factory = isolate->factory(); | 17 Factory* factory = isolate->factory(); |
| 18 | 18 |
| 19 HandleScope sc(isolate); | 19 HandleScope sc(isolate); |
| 20 | 20 |
| 21 float nan = std::numeric_limits<float>::quiet_NaN(); | 21 float nan = std::numeric_limits<float>::quiet_NaN(); |
| 22 | 22 float lanes[4] = {0, 0, 0, 0}; |
| 23 Handle<Float32x4> a = factory->NewFloat32x4(0, 0, 0, 0); | 23 Handle<Float32x4> a = factory->NewFloat32x4(lanes); |
| 24 Handle<Float32x4> b = factory->NewFloat32x4(0, 0, 0, 0); | 24 Handle<Float32x4> b = factory->NewFloat32x4(lanes); |
| 25 CHECK(a->SameValue(*b)); | 25 CHECK(a->SameValue(*b)); |
| 26 for (int i = 0; i < 4; i++) { | 26 for (int i = 0; i < 4; i++) { |
| 27 a->set_lane(i, nan); | 27 a->set_lane(i, nan); |
| 28 CHECK(!a->SameValue(*b)); | 28 CHECK(!a->SameValue(*b)); |
| 29 CHECK(!a->SameValueZero(*b)); | 29 CHECK(!a->SameValueZero(*b)); |
| 30 b->set_lane(i, nan); | 30 b->set_lane(i, nan); |
| 31 CHECK(a->SameValue(*b)); | 31 CHECK(a->SameValue(*b)); |
| 32 CHECK(a->SameValueZero(*b)); | 32 CHECK(a->SameValueZero(*b)); |
| 33 a->set_lane(i, -0.0); | 33 a->set_lane(i, -0.0); |
| 34 CHECK(!a->SameValue(*b)); | 34 CHECK(!a->SameValue(*b)); |
| 35 b->set_lane(i, 0); | 35 b->set_lane(i, 0); |
| 36 CHECK(!a->SameValue(*b)); | 36 CHECK(!a->SameValue(*b)); |
| 37 CHECK(a->SameValueZero(*b)); | 37 CHECK(a->SameValueZero(*b)); |
| 38 b->set_lane(i, -0.0); | 38 b->set_lane(i, -0.0); |
| 39 CHECK(a->SameValue(*b)); | 39 CHECK(a->SameValue(*b)); |
| 40 CHECK(a->SameValueZero(*b)); | 40 CHECK(a->SameValueZero(*b)); |
| 41 | 41 |
| 42 a->set_lane(i, 0); | 42 a->set_lane(i, 0); |
| 43 b->set_lane(i, 0); | 43 b->set_lane(i, 0); |
| 44 } | 44 } |
| 45 } | 45 } |
| OLD | NEW |