/// <summary> /// Visits a single test block /// </summary> /// <param name="line">Line to add the tag for</param> /// <param name="context">TestBlockNode to visit</param> /// <param name="lineNo">Current line numer</param> /// <param name="collectedSpans">Collection of spans found</param> private void Visit(ITextSnapshotLine line, TestBlockNode context, int lineNo, List <TagSpan <Z80TestTokenTag> > collectedSpans) { if (context == null || lineNo < context.Span.StartLine || lineNo > context.Span.EndLine) { return; } Visit(line, context.TestKeywordSpan, lineNo, collectedSpans, Z80TestTokenType.Keyword); Visit(line, context.TestIdSpan, lineNo, collectedSpans, Z80TestTokenType.Identifier); Visit(line, context.CategoryKeywordSpan, lineNo, collectedSpans, Z80TestTokenType.Keyword); Visit(line, context.CategoryIdSpan, lineNo, collectedSpans, Z80TestTokenType.Identifier); Visit(line, context.TestOptions, lineNo, collectedSpans); Visit(line, context.Setup, lineNo, collectedSpans); Visit(line, context.Params, lineNo, collectedSpans); Visit(line, context.Arrange, lineNo, collectedSpans); Visit(line, context.Act, lineNo, collectedSpans); Visit(line, context.Breakpoints, lineNo, collectedSpans); foreach (var testCase in context.Cases) { Visit(line, testCase, lineNo, collectedSpans); } Visit(line, context.Assert, lineNo, collectedSpans); Visit(line, context.Cleanup, lineNo, collectedSpans); }
/// <summary> /// Visit a parse tree produced by <see cref="Z80TestParser.testBlock"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public override object VisitTestBlock(Z80TestParser.TestBlockContext context) { if (IsInvalidContext(context)) { return(null); } var node = new TestBlockNode(context); if (context.testOptions() != null) { node.TestOptions = (TestOptionsNode)VisitTestOptions(context.testOptions()); } if (context.testParams() != null) { node.Params = (ParamsNode)VisitTestParams(context.testParams()); } foreach (var testCase in context.testCase()) { node.Cases.Add((TestCaseNode)VisitTestCase(testCase)); } if (context.arrange() != null) { node.Arrange = (AssignmentsNode)VisitArrange(context.arrange()); } node.Act = (InvokeCodeNode)VisitAct(context.act()); if (context.breakpoint() != null) { node.Breakpoints = (BreakpointsNode)VisitBreakpoint(context.breakpoint()); } if (context.assert() != null) { node.Assert = (AssertNode)VisitAssert(context.assert()); } return(node); }
/// <summary> /// Visits a test block /// </summary> /// <param name="plan">Test file plan</param> /// <param name="testSetPlan">Test set plan to visit</param> /// <param name="block">Block to visit</param> /// <returns>Test block plan</returns> private TestBlockPlan VisitTestBlock(TestFilePlan plan, TestSetPlan testSetPlan, TestBlockNode block) { var testBlock = new TestBlockPlan(testSetPlan, block.TestId, block.Category, block.Span); if (block.TestOptions != null) { VisitTestOptions(plan, testSetPlan, block.TestOptions, out var disableInterrupt, out var timeout); testBlock.DisableInterrupt = disableInterrupt; testBlock.TimeoutValue = timeout; } if (block.Setup != null) { testBlock.Setup = VisitInvoke(plan, testSetPlan, block.Setup); } VisitTestParameters(plan, testBlock, block.Params); VisitTestCases(plan, testBlock, block.Cases); var invoke = VisitInvoke(plan, testSetPlan, block.Act); if (invoke != null) { testBlock.Act = invoke; } VisitArrange(plan, testBlock, block.Arrange); if (block.Breakpoints != null) { VisitBreakPoints(plan, testBlock, block.Breakpoints); } testBlock.MachineContext = new CompileTimeMachineContext(); VisitAssert(plan, testBlock, block.Assert); if (block.Cleanup != null) { testBlock.Cleanup = VisitInvoke(plan, testSetPlan, block.Cleanup); } return(testBlock); }
/// <summary> /// Visits a test block /// </summary> /// <param name="plan"></param> /// <param name="testSetPlan"></param> /// <param name="block"></param> /// <returns>Test block plan</returns> private TestBlockPlan VisitTestBlock(TestFilePlan plan, TestSetPlan testSetPlan, TestBlockNode block) { var testBlock = new TestBlockPlan(testSetPlan, block.TestId, block.Category, block.Span); if (block.TestOptions != null) { VisitTestOptions(plan, testSetPlan, block.TestOptions, out var nonmi, out var timeout); testBlock.DisableInterrupt = nonmi; testBlock.TimeoutValue = timeout; } VisitTestParameters(plan, testBlock, block.Params); VisitTestCases(plan, testBlock, block.Cases); var invoke = VisitInvoke(plan, testSetPlan, block.Act); if (invoke != null) { testBlock.Act = invoke; } VisitArrange(plan, testBlock, block.Arrange); if (block.Breakpoints != null) { VisitBreakPoints(plan, testBlock, block.Breakpoints); } testBlock.SignMachineAvalilable(); VisitAssert(plan, testBlock, block.Assert); return(testBlock); }