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

Unified Diff: tools/gn/operators_unittest.cc

Issue 2554083003: gn: Fix integer subtraction. (Closed)
Patch Set: Created 4 years 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 | « tools/gn/operators.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/operators_unittest.cc
diff --git a/tools/gn/operators_unittest.cc b/tools/gn/operators_unittest.cc
index fa163a1775823498d5677cbafab6a60c7e530928..4c9c670a133d514cfa2d01f5da5a87f12147bc64 100644
--- a/tools/gn/operators_unittest.cc
+++ b/tools/gn/operators_unittest.cc
@@ -237,6 +237,34 @@ TEST(Operators, ListRemove) {
EXPECT_EQ("bar", new_value->list_value()[0].string_value());
}
+TEST(Operators, IntegerAdd) {
+ Err err;
+ TestWithScope setup;
+
+ TestBinaryOpNode node(Token::PLUS, "+");
+ node.SetLeftToValue(Value(nullptr, static_cast<int64_t>(123)));
+ node.SetRightToValue(Value(nullptr, static_cast<int64_t>(456)));
+ Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(),
+ node.right(), &err);
+ ASSERT_FALSE(err.has_error());
+ ASSERT_EQ(Value::INTEGER, ret.type());
+ EXPECT_EQ(579, ret.int_value());
+}
+
+TEST(Operators, IntegerSubtract) {
+ Err err;
+ TestWithScope setup;
+
+ TestBinaryOpNode node(Token::MINUS, "-");
+ node.SetLeftToValue(Value(nullptr, static_cast<int64_t>(123)));
+ node.SetRightToValue(Value(nullptr, static_cast<int64_t>(456)));
+ Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(),
+ node.right(), &err);
+ ASSERT_FALSE(err.has_error());
+ ASSERT_EQ(Value::INTEGER, ret.type());
+ EXPECT_EQ(-333, ret.int_value());
+}
+
TEST(Operators, ShortCircuitAnd) {
Err err;
TestWithScope setup;
« no previous file with comments | « tools/gn/operators.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698