public void It_Should_Group_Expressions_In_Parens() { // Arrange var ast = CreateAST("Result : {% if true and (false or false) %}FALSE{% endif %}"); var visitor = new DebuggingVisitor(); StartVisiting(visitor, ast.RootNode); // Assert var tagExpressions = FindNodesWithType(ast, typeof(IfThenElseBlockTag)).ToList(); var ifThenElseTag = (IfThenElseBlockTag)tagExpressions[0].Data; Assert.That(tagExpressions.Count, Is.EqualTo(1)); //Assert.That(ifThenElseTag.IfElseClauses[0].RootNode.Data, Is.TypeOf<AndExpression>()); //TODO: TextMessageWriter otu the tree //Assert.That(ifThenElseTag.IfElseClauses[0].RootNode[0].Data, Is.TypeOf<AndExpression>()); var ifTagSymbol = ifThenElseTag.IfElseClauses[0]; //Assert.That(ifTagSymbol.RootNode.Data, Is.TypeOf<AndExpression>()); var expressionSymbolTree = ifTagSymbol.LiquidExpressionTree; Assert.That(expressionSymbolTree.Data.Expression, Is.TypeOf <AndExpression>()); Assert.That(expressionSymbolTree.Children.Count, Is.EqualTo(2)); Assert.That(expressionSymbolTree[0].Data.Expression, Is.TypeOf <LiquidBoolean>()); Assert.That(expressionSymbolTree[1].Data.Expression, Is.TypeOf <GroupedExpression>()); Assert.That(expressionSymbolTree[1].Children.Count, Is.EqualTo(1)); Assert.That(expressionSymbolTree[1][0].Data.Expression, Is.TypeOf <OrExpression>()); Assert.That(expressionSymbolTree[1][0][0].Data.Expression, Is.TypeOf <LiquidBoolean>()); Assert.That(expressionSymbolTree[1][0][1].Data.Expression, Is.TypeOf <LiquidBoolean>()); //Assert.That(ifThenElseTag.IfElseClauses[0].LiquidExpression[2].Data, Is.TypeOf<GroupedExpression>()); //Assert.That(liquidExpressions, Is.Not.Null); //Assert.That(((LiquidExpression)liquidExpressions.Data).FilterSymbols.Count(), Is.EqualTo(1)); }
public void It_Should_Group_Expressions_In_Parens() { // Arrange var ast = CreateAST("Result : {% if true and (false or false) %}FALSE{% endif %}"); var visitor = new DebuggingVisitor(); StartVisiting(visitor, ast.RootNode); // Assert var tagExpressions = FindNodesWithType(ast, typeof(IfThenElseBlockTag)).ToList(); var ifThenElseTag = (IfThenElseBlockTag)tagExpressions[0].Data; Assert.Single(tagExpressions); //Assert.IsType<AndExpression>(ifThenElseTag.IfElseClauses[0].RootNode.Data); //Assert.IsType<AndExpression>(ifThenElseTag.IfElseClauses[0].RootNode[0].Data); var ifTagSymbol = ifThenElseTag.IfElseClauses[0]; //Assert.IsType<AndExpression>(ifTagSymbol.RootNode.Data); var expressionSymbolTree = ifTagSymbol.LiquidExpressionTree; Assert.IsType <AndExpression>(expressionSymbolTree.Data.Expression); Assert.Equal(2, expressionSymbolTree.Children.Count); Assert.IsType <LiquidBoolean>(expressionSymbolTree[0].Data.Expression); Assert.IsType <GroupedExpression>(expressionSymbolTree[1].Data.Expression); Assert.Single(expressionSymbolTree[1].Children); Assert.IsType <OrExpression>(expressionSymbolTree[1][0].Data.Expression); Assert.IsType <LiquidBoolean>(expressionSymbolTree[1][0][0].Data.Expression); Assert.IsType <LiquidBoolean>(expressionSymbolTree[1][0][1].Data.Expression); //Assert.IsType<GroupedExpression>(ifThenElseTag.IfElseClauses[0].LiquidExpression[2].Data); //Assert.NotNull(liquidExpressions); //Assert.Equal(1, ((LiquidExpression)liquidExpressions.Data).FilterSymbols.Count()); }
public void It_Should_Group_Expressions_In_Parens() { // Arrange LiquidASTGenerator generator = new LiquidASTGenerator(); // Act LiquidAST ast = generator.Generate("Result : {% if true and (false or false) %}FALSE{% endif %}"); var visitor= new DebuggingVisitor(); StartVisiting(visitor,ast.RootNode); // Assert var tagExpressions = FindNodesWithType(ast, typeof(IfThenElseBlockTag)).ToList(); var ifThenElseTag = (IfThenElseBlockTag) tagExpressions[0].Data; Assert.That(tagExpressions.Count(), Is.EqualTo(1)); //Assert.That(ifThenElseTag.IfElseClauses[0].RootNode.Data, Is.TypeOf<AndExpression>()); //TODO: TextMessageWriter otu the tree //Assert.That(ifThenElseTag.IfElseClauses[0].RootNode[0].Data, Is.TypeOf<AndExpression>()); var ifTagSymbol = ifThenElseTag.IfElseClauses[0]; //Assert.That(ifTagSymbol.RootNode.Data, Is.TypeOf<AndExpression>()); var expressionSymbolTree = ifTagSymbol.LiquidExpressionTree; Assert.That(expressionSymbolTree.Data.Expression, Is.TypeOf<AndExpression>()); Assert.That(expressionSymbolTree.Children.Count, Is.EqualTo(2)); Assert.That(expressionSymbolTree[0].Data.Expression, Is.TypeOf<BooleanValue>()); Assert.That(expressionSymbolTree[1].Data.Expression, Is.TypeOf<GroupedExpression>()); Assert.That(expressionSymbolTree[1].Children.Count, Is.EqualTo(1)); Assert.That(expressionSymbolTree[1][0].Data.Expression, Is.TypeOf<OrExpression>()); Assert.That(expressionSymbolTree[1][0][0].Data.Expression, Is.TypeOf<BooleanValue>()); Assert.That(expressionSymbolTree[1][0][1].Data.Expression, Is.TypeOf<BooleanValue>()); //Assert.That(ifThenElseTag.IfElseClauses[0].LiquidExpression[2].Data, Is.TypeOf<GroupedExpression>()); //Assert.That(liquidExpressions, Is.Not.Null); //Assert.That(((LiquidExpression)liquidExpressions.Data).FilterSymbols.Count(), Is.EqualTo(1)); }