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

Unified Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 829303002: [turbofan] Generalize constant propagation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation on Mac Created 5 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
Index: test/unittests/compiler/js-typed-lowering-unittest.cc
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc
index e4ea4a581f6b3e937ed8cbd8fa5043db5749d2ae..618764a1748b87c7499f40071c6c1d68981c4137 100644
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <climits>
+
#include "src/compiler/access-builder.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-operator.h"
@@ -12,6 +14,10 @@
#include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/compiler/graph-unittest.h"
#include "test/unittests/compiler/node-test-utils.h"
+#include "testing/gmock-support.h"
+
+using testing::IsNaN;
+
namespace v8 {
namespace internal {
@@ -69,6 +75,37 @@ class JSTypedLoweringTest : public TypedGraphTest {
// -----------------------------------------------------------------------------
+// Constant propagation
+
+
+TEST_F(JSTypedLoweringTest, ParameterWithMinusZero) {
+ Reduction r = Reduce(Parameter(Type::MinusZero()));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsNumberConstant(-0.0));
+}
Jarin 2015/01/05 09:41:21 Could we have test checking that type 0 <union> -0
Benedikt Meurer 2015/01/05 12:37:12 Done.
+
+
+TEST_F(JSTypedLoweringTest, ParameterWithNaN) {
+ Reduction r = Reduce(Parameter(Type::NaN()));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsNumberConstant(IsNaN()));
+}
+
+
+TEST_F(JSTypedLoweringTest, ParameterWithSingletonRange) {
+ static const double kValues[] = {
+ -V8_INFINITY, INT_MIN, -1000.0, -42.0, -1.0, 0.0,
+ 1.0, 42.0, 1000.0, INT_MAX, UINT_MAX, +V8_INFINITY};
+ TRACED_FOREACH(double, value, kValues) {
+ Handle<Object> constant = factory()->NewNumber(value);
+ Reduction r = Reduce(Parameter(Type::Range(constant, constant, zone())));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsNumberConstant(value));
+ }
+}
+
+
+// -----------------------------------------------------------------------------
// JSToBoolean

Powered by Google App Engine
This is Rietveld 408576698