X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftools%2Fgn%2Foperators_unittest.cc;h=2ad91b8718b09306d1389bbf9123b639eb7c26e0;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=529c883aa47659eaf0b89f7bd5eb26e9ff276608;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/tools/gn/operators_unittest.cc b/src/tools/gn/operators_unittest.cc index 529c883..2ad91b8 100644 --- a/src/tools/gn/operators_unittest.cc +++ b/src/tools/gn/operators_unittest.cc @@ -151,3 +151,53 @@ TEST(Operators, ListAppend) { ExecuteBinaryOperator(setup.scope(), &node, node.left(), node.right(), &err); EXPECT_TRUE(err.has_error()); } + +TEST(Operators, ShortCircuitAnd) { + Err err; + TestWithScope setup; + + // Set up the operator. + BinaryOpNode node; + const char token_value[] = "&&"; + Token op(Location(), Token::BOOLEAN_AND, token_value); + node.set_op(op); + + // Set the left to false. + const char false_str[] = "false"; + Token false_tok(Location(), Token::FALSE_TOKEN, false_str); + node.set_left(scoped_ptr(new LiteralNode(false_tok))); + + // Set right as foo, but don't define a value for it. + const char foo[] = "foo"; + Token identifier_token(Location(), Token::IDENTIFIER, foo); + node.set_right(scoped_ptr(new IdentifierNode(identifier_token))); + + Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(), + node.right(), &err); + EXPECT_FALSE(err.has_error()); +} + +TEST(Operators, ShortCircuitOr) { + Err err; + TestWithScope setup; + + // Set up the operator. + BinaryOpNode node; + const char token_value[] = "||"; + Token op(Location(), Token::BOOLEAN_OR, token_value); + node.set_op(op); + + // Set the left to false. + const char false_str[] = "true"; + Token false_tok(Location(), Token::TRUE_TOKEN, false_str); + node.set_left(scoped_ptr(new LiteralNode(false_tok))); + + // Set right as foo, but don't define a value for it. + const char foo[] = "foo"; + Token identifier_token(Location(), Token::IDENTIFIER, foo); + node.set_right(scoped_ptr(new IdentifierNode(identifier_token))); + + Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(), + node.right(), &err); + EXPECT_FALSE(err.has_error()); +}