public static void ChildNodesReturnsBlockStartAndBlockEnd() { var start = new StatementBlockStart(default(int)); var end = new BlockEnd(default(int)); var codeBlock = new CodeBlock(start, end); Assert.True(codeBlock.ChildNodes().SequenceEqual(new SyntaxNode[] { start, end })); }
public static void AcceptCallsVisitCodeBlockMethodOfSyntaxNodeVisitor() { var visitor = Substitute.For<SyntaxNodeVisitor>(); var codeBlock = new CodeBlock(new StatementBlockStart(0), new BlockEnd(0)); codeBlock.Accept(visitor); visitor.Received().VisitCodeBlock(codeBlock); }
public static void VisitNonterminalNodeVisitsChildNodesToAllowProcessingAllNodesRecursively() { var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>(); var nonterminalNode = new CodeBlock(new StatementBlockStart(0), new BlockEnd(0)); visitor.VisitNonterminalNode(nonterminalNode); Assert.Equal(3, visitor.ReceivedCalls().Count(call => call.GetMethodInfo().Name == "VisitSyntaxNode")); }
public static void VisitNonterminalNodeCallsVisitSyntaxNodeToAllowProcessingAllSyntaxNodesPolymorphically() { var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>(); var nonterminalNode = new CodeBlock(new StatementBlockStart(0), new BlockEnd(0)); visitor.VisitNonterminalNode(nonterminalNode); Assert.Equal(1, visitor.ReceivedCalls().Count(call => call.GetMethodInfo().Name == "VisitSyntaxNode" && call.GetArguments()[0] == nonterminalNode)); Assert.Equal(typeof(SyntaxNode), typeof(NonterminalNode).BaseType); }
public static void VisitCodeBlockCallsVisitNonterminalNodeToAllowProcessingAllNonterminalNodesPolymorphically() { var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>(); var codeBlock = new CodeBlock(new StatementBlockStart(0), new BlockEnd(0)); visitor.VisitCodeBlock(codeBlock); visitor.Received().VisitNonterminalNode(codeBlock); Assert.Equal(typeof(NonterminalNode), typeof(CodeBlock).BaseType); }
protected internal virtual void VisitCodeBlock(CodeBlock node) { this.VisitNonterminalNode(node); }
public static void PositionReturnsPositionOfCodeBlockStart() { var target = new CodeBlock(new StatementBlockStart(0, new Position(4, 2)), new BlockEnd(0)); Assert.Equal(new Position(4, 2), target.Position); }
public static void SpanEndsAtBlockEnd() { BlockEnd end; var codeBlock = new CodeBlock(new StatementBlockStart(0), end = new BlockEnd(40)); Assert.Equal(end.Span.End, codeBlock.Span.End); }
public static void SpanStartsAtBlockStart() { StatementBlockStart start; var codeBlock = new CodeBlock(start = new StatementBlockStart(42), new BlockEnd(100)); Assert.Equal(start.Span.Start, codeBlock.Span.Start); }