public void Handles_nested_parenthesis_precedence() { var parser = new ScriptParser("a + b * (c / (d - e))"); var expr = parser.ParseExpression(); ScriptAssert.Nodes(expr, new TestBinary( new TestIdentifier("a"), BinaryOperator.Add, new TestBinary( new TestIdentifier("b"), BinaryOperator.Multiply, new TestBinary( new TestIdentifier("c"), BinaryOperator.Divide, new TestBinary( new TestIdentifier("d"), BinaryOperator.Subtract, new TestIdentifier("e") ) ) ) ) ); }
public void Handles_simple_update_prefix2() { var parser = new ScriptParser("++b"); var expr = parser.ParseExpression(); ScriptAssert.Nodes(expr, new TestUpdate(UpdateOperator.Increment, new TestIdentifier("b"))); }
public void Handles_simple_unary2() { var parser = new ScriptParser("not b"); var expr = parser.ParseExpression(); ScriptAssert.Nodes(expr, new TestUnary(UnaryOperator.Not, new TestIdentifier("b"))); }
public void Handles_simple_precedence() { var parser = new ScriptParser("a + b * c - d"); var expr = parser.ParseExpression(); ScriptAssert.Nodes(expr, new TestBinary( new TestBinary( new TestIdentifier("a"), BinaryOperator.Add, new TestBinary( new TestIdentifier("b"), BinaryOperator.Multiply, new TestIdentifier("c") ) ), BinaryOperator.Subtract, new TestIdentifier("d") ) ); }