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

Unified Diff: src/compiler/js-builtin-reducer-unittest.cc

Issue 598523002: Move test for reduction of Math.max to unittest. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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/compiler/graph-unittest.cc ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-builtin-reducer-unittest.cc
diff --git a/src/compiler/js-builtin-reducer-unittest.cc b/src/compiler/js-builtin-reducer-unittest.cc
index ca12c50d8b58cb38060466ec198bcc01be8bc281..557ce27fa3911d3931ea65281b57c7ada5160a95 100644
--- a/src/compiler/js-builtin-reducer-unittest.cc
+++ b/src/compiler/js-builtin-reducer-unittest.cc
@@ -7,6 +7,9 @@
#include "src/compiler/js-graph.h"
#include "src/compiler/node-properties-inl.h"
#include "src/compiler/typer.h"
+#include "testing/gmock-support.h"
+
+using testing::Capture;
namespace v8 {
namespace internal {
@@ -57,6 +60,71 @@ Type* const kNumberTypes[] = {
// -----------------------------------------------------------------------------
+// Math.max
+
+
+TEST_F(JSBuiltinReducerTest, MathMax0) {
+ Handle<JSFunction> f(isolate()->context()->math_max_fun());
+
+ Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
+ Node* call = graph()->NewNode(javascript()->Call(2, NO_CALL_FUNCTION_FLAGS),
+ fun, UndefinedConstant());
+ Reduction r = Reduce(call);
+
+ EXPECT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), IsNumberConstant(-V8_INFINITY));
+}
+
+
+TEST_F(JSBuiltinReducerTest, MathMax1) {
+ Handle<JSFunction> f(isolate()->context()->math_max_fun());
+
+ TRACED_FOREACH(Type*, t0, kNumberTypes) {
+ Node* p0 = Parameter(t0, 0);
+ Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
+ Node* call = graph()->NewNode(javascript()->Call(3, NO_CALL_FUNCTION_FLAGS),
+ fun, UndefinedConstant(), p0);
+ Reduction r = Reduce(call);
+
+ EXPECT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), p0);
+ }
+}
+
+
+TEST_F(JSBuiltinReducerTest, MathMax2) {
+ Handle<JSFunction> f(isolate()->context()->math_max_fun());
+
+ TRACED_FOREACH(Type*, t0, kNumberTypes) {
+ TRACED_FOREACH(Type*, t1, kNumberTypes) {
+ Node* p0 = Parameter(t0, 0);
+ Node* p1 = Parameter(t1, 1);
+ Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
+ Node* call =
+ graph()->NewNode(javascript()->Call(4, NO_CALL_FUNCTION_FLAGS), fun,
+ UndefinedConstant(), p0, p1);
+ Reduction r = Reduce(call);
+
+ if (t0->Is(Type::Integral32()) && t1->Is(Type::Integral32())) {
+ Capture<Node*> branch;
+ EXPECT_TRUE(r.Changed());
+ EXPECT_THAT(
+ r.replacement(),
+ IsPhi(kMachNone, p1, p0,
+ IsMerge(IsIfTrue(CaptureEq(&branch)),
+ IsIfFalse(AllOf(CaptureEq(&branch),
+ IsBranch(IsNumberLessThan(p0, p1),
+ graph()->start()))))));
+ } else {
+ EXPECT_FALSE(r.Changed());
+ EXPECT_EQ(IrOpcode::kJSCallFunction, call->opcode());
+ }
+ }
+ }
+}
+
+
+// -----------------------------------------------------------------------------
// Math.imul
« no previous file with comments | « src/compiler/graph-unittest.cc ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698