| 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/factory.h" | 7 #include "src/factory.h" |
| 8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
| 9 #include "src/heap/heap-inl.h" | 9 #include "src/heap/heap-inl.h" |
| 10 #include "src/runtime/runtime.h" | 10 #include "src/runtime/runtime.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 TEST_F(RuntimeInterpreterTest, TestOperatorsWithIntegers) { | 73 TEST_F(RuntimeInterpreterTest, TestOperatorsWithIntegers) { |
| 74 int32_t inputs[] = {kMinInt, Smi::kMinValue, -17, -1, 0, 1, | 74 int32_t inputs[] = {kMinInt, Smi::kMinValue, -17, -1, 0, 1, |
| 75 991, Smi::kMaxValue, kMaxInt}; | 75 991, Smi::kMaxValue, kMaxInt}; |
| 76 TRACED_FOREACH(int, lhs, inputs) { | 76 TRACED_FOREACH(int, lhs, inputs) { |
| 77 TRACED_FOREACH(int, rhs, inputs) { | 77 TRACED_FOREACH(int, rhs, inputs) { |
| 78 #define INTEGER_OPERATOR_CHECK(r, op, x, y) \ | 78 #define INTEGER_OPERATOR_CHECK(r, op, x, y) \ |
| 79 CHECK(TestOperator(Runtime_Interpreter##r, x, y, x op y)) | 79 CHECK(TestOperator(Runtime_Interpreter##r, x, y, x op y)) |
| 80 INTEGER_OPERATOR_CHECK(Equals, ==, lhs, rhs); | |
| 81 INTEGER_OPERATOR_CHECK(NotEquals, !=, lhs, rhs); | |
| 82 INTEGER_OPERATOR_CHECK(StrictEquals, ==, lhs, rhs); | |
| 83 INTEGER_OPERATOR_CHECK(StrictNotEquals, !=, lhs, rhs); | |
| 84 INTEGER_OPERATOR_CHECK(LessThan, <, lhs, rhs); | 80 INTEGER_OPERATOR_CHECK(LessThan, <, lhs, rhs); |
| 85 INTEGER_OPERATOR_CHECK(GreaterThan, >, lhs, rhs); | 81 INTEGER_OPERATOR_CHECK(GreaterThan, >, lhs, rhs); |
| 86 INTEGER_OPERATOR_CHECK(LessThanOrEqual, <=, lhs, rhs); | 82 INTEGER_OPERATOR_CHECK(LessThanOrEqual, <=, lhs, rhs); |
| 87 INTEGER_OPERATOR_CHECK(GreaterThanOrEqual, >=, lhs, rhs); | 83 INTEGER_OPERATOR_CHECK(GreaterThanOrEqual, >=, lhs, rhs); |
| 88 #undef INTEGER_OPERATOR_CHECK | 84 #undef INTEGER_OPERATOR_CHECK |
| 89 } | 85 } |
| 90 } | 86 } |
| 91 } | 87 } |
| 92 | 88 |
| 93 | 89 |
| 94 TEST_F(RuntimeInterpreterTest, TestOperatorsWithDoubles) { | 90 TEST_F(RuntimeInterpreterTest, TestOperatorsWithDoubles) { |
| 95 double inputs[] = {std::numeric_limits<double>::min(), | 91 double inputs[] = {std::numeric_limits<double>::min(), |
| 96 std::numeric_limits<double>::max(), | 92 std::numeric_limits<double>::max(), |
| 97 -0.001, | 93 -0.001, |
| 98 0.01, | 94 0.01, |
| 99 3.14, | 95 3.14, |
| 100 -6.02214086e23}; | 96 -6.02214086e23}; |
| 101 TRACED_FOREACH(double, lhs, inputs) { | 97 TRACED_FOREACH(double, lhs, inputs) { |
| 102 TRACED_FOREACH(double, rhs, inputs) { | 98 TRACED_FOREACH(double, rhs, inputs) { |
| 103 #define DOUBLE_OPERATOR_CHECK(r, op, x, y) \ | 99 #define DOUBLE_OPERATOR_CHECK(r, op, x, y) \ |
| 104 CHECK(TestOperator(Runtime_Interpreter##r, x, y, x op y)) | 100 CHECK(TestOperator(Runtime_Interpreter##r, x, y, x op y)) |
| 105 DOUBLE_OPERATOR_CHECK(Equals, ==, lhs, rhs); | |
| 106 DOUBLE_OPERATOR_CHECK(NotEquals, !=, lhs, rhs); | |
| 107 DOUBLE_OPERATOR_CHECK(StrictEquals, ==, lhs, rhs); | |
| 108 DOUBLE_OPERATOR_CHECK(StrictNotEquals, !=, lhs, rhs); | |
| 109 DOUBLE_OPERATOR_CHECK(LessThan, <, lhs, rhs); | 101 DOUBLE_OPERATOR_CHECK(LessThan, <, lhs, rhs); |
| 110 DOUBLE_OPERATOR_CHECK(GreaterThan, >, lhs, rhs); | 102 DOUBLE_OPERATOR_CHECK(GreaterThan, >, lhs, rhs); |
| 111 DOUBLE_OPERATOR_CHECK(LessThanOrEqual, <=, lhs, rhs); | 103 DOUBLE_OPERATOR_CHECK(LessThanOrEqual, <=, lhs, rhs); |
| 112 DOUBLE_OPERATOR_CHECK(GreaterThanOrEqual, >=, lhs, rhs); | 104 DOUBLE_OPERATOR_CHECK(GreaterThanOrEqual, >=, lhs, rhs); |
| 113 #undef DOUBLE_OPERATOR_CHECK | 105 #undef DOUBLE_OPERATOR_CHECK |
| 114 } | 106 } |
| 115 } | 107 } |
| 116 } | 108 } |
| 117 | 109 |
| 118 | 110 |
| 119 TEST_F(RuntimeInterpreterTest, TestOperatorsWithString) { | 111 TEST_F(RuntimeInterpreterTest, TestOperatorsWithString) { |
| 120 const char* inputs[] = {"abc", "a", "def", "0"}; | 112 const char* inputs[] = {"abc", "a", "def", "0"}; |
| 121 TRACED_FOREACH(const char*, lhs, inputs) { | 113 TRACED_FOREACH(const char*, lhs, inputs) { |
| 122 TRACED_FOREACH(const char*, rhs, inputs) { | 114 TRACED_FOREACH(const char*, rhs, inputs) { |
| 123 #define STRING_OPERATOR_CHECK(r, op, x, y) \ | 115 #define STRING_OPERATOR_CHECK(r, op, x, y) \ |
| 124 CHECK(TestOperator(Runtime_Interpreter##r, x, y, \ | 116 CHECK(TestOperator(Runtime_Interpreter##r, x, y, \ |
| 125 std::string(x) op std::string(y))) | 117 std::string(x) op std::string(y))) |
| 126 STRING_OPERATOR_CHECK(Equals, ==, lhs, rhs); | |
| 127 STRING_OPERATOR_CHECK(NotEquals, !=, lhs, rhs); | |
| 128 STRING_OPERATOR_CHECK(StrictEquals, ==, lhs, rhs); | |
| 129 STRING_OPERATOR_CHECK(StrictNotEquals, !=, lhs, rhs); | |
| 130 STRING_OPERATOR_CHECK(LessThan, <, lhs, rhs); | 118 STRING_OPERATOR_CHECK(LessThan, <, lhs, rhs); |
| 131 STRING_OPERATOR_CHECK(GreaterThan, >, lhs, rhs); | 119 STRING_OPERATOR_CHECK(GreaterThan, >, lhs, rhs); |
| 132 STRING_OPERATOR_CHECK(LessThanOrEqual, <=, lhs, rhs); | 120 STRING_OPERATOR_CHECK(LessThanOrEqual, <=, lhs, rhs); |
| 133 STRING_OPERATOR_CHECK(GreaterThanOrEqual, >=, lhs, rhs); | 121 STRING_OPERATOR_CHECK(GreaterThanOrEqual, >=, lhs, rhs); |
| 134 #undef STRING_OPERATOR_CHECK | 122 #undef STRING_OPERATOR_CHECK |
| 135 } | 123 } |
| 136 } | 124 } |
| 137 } | 125 } |
| 138 | 126 |
| 139 | 127 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 163 Runtime_InterpreterToBoolean(1, &args_object[0], isolate()), isolate()); | 151 Runtime_InterpreterToBoolean(1, &args_object[0], isolate()), isolate()); |
| 164 CHECK(result->IsBoolean()); | 152 CHECK(result->IsBoolean()); |
| 165 CHECK_EQ(result->IsTrue(), value_expected_tuple.second); | 153 CHECK_EQ(result->IsTrue(), value_expected_tuple.second); |
| 166 } | 154 } |
| 167 } | 155 } |
| 168 | 156 |
| 169 | 157 |
| 170 } // namespace interpreter | 158 } // namespace interpreter |
| 171 } // namespace internal | 159 } // namespace internal |
| 172 } // namespace v8 | 160 } // namespace v8 |
| OLD | NEW |