public CoverageMapper(PythonAst ast, string filename, HashSet<int> hits) { _ast = ast; _filename = filename; GlobalScope = new CoverageScope(ast); CurScopes.Add(GlobalScope); _blockCount++; _hits = hits; }
public CoverageMapper(PythonAst ast, string filename, HashSet <int> hits) { _ast = ast; _filename = filename; GlobalScope = new CoverageScope(ast); CurScopes.Add(GlobalScope); _blockCount++; _hits = hits; }
private void AggregateStats(CoverageScope scope, ref int linesCovered, ref int linesNotCovered, ref int blocksCovered, ref int blocksNotCovered) { linesCovered += scope.LinesCovered; linesNotCovered += scope.LinesNotCovered; blocksCovered += scope.BlocksCovered; blocksNotCovered += scope.BlocksNotCovered; foreach (var child in scope.Children) { AggregateStats(child, ref linesCovered, ref linesNotCovered, ref blocksCovered, ref blocksNotCovered); } }
private void WriteMethods(CoverageScope klass) { foreach (var child in klass.Children) { FunctionDefinition funcDef = child.Statement as FunctionDefinition; if (funcDef != null) { WriteMethod(child, GetQualifiedFunctionName(child.Statement)); WriteMethods(child); } } }
private CoverageScope WalkScope(ScopeStatement node) { var prevScope = CurScope; var newScope = new CoverageScope(node); CurScopes.Add(newScope); var wasCovered = _blockCovered; _blockCovered = null; if (node.Body != null) { node.Body.Walk(this); } CurScopes.RemoveAt(CurScopes.Count - 1); _blockCovered = wasCovered; return(newScope); }
private void WriteClass(string filename, CoverageScope klass, string name) { _writer.WriteStartElement("Class"); WriteElement("ClassKeyName", filename + "!" + name); WriteElement("ClassName", name); WriteElement("NamespaceKeyName", filename + "!" + name); int linesCovered = 0, linesNotCovered = 0, blocksCovered = 0, blocksNotCovered = 0; AggregateStats(klass, ref linesCovered, ref linesNotCovered, ref blocksCovered, ref blocksNotCovered); WriteCoverageData(linesCovered, linesNotCovered, blocksCovered, blocksNotCovered); WriteMethod(klass, klass.Statement.Name); WriteMethods(klass); _writer.WriteEndElement(); }
private void WriteMethod(CoverageScope child, string name) { _writer.WriteStartElement("Method"); WriteElement("MethodKeyName", "method!" + ++_methodCount); WriteElement("MethodName", name); WriteElement("MethodFullName", name); WriteCoverageData(child); foreach (var line in child.Lines) { var lineNo = line.Key; var lineInfo = line.Value; _writer.WriteStartElement("Lines"); WriteElement("LnStart", lineNo); WriteElement("ColStart", lineInfo.ColumnStart); WriteElement("LnEnd", lineNo); WriteElement("ColEnd", lineInfo.ColumnEnd); WriteElement("Coverage", (int)(lineInfo.Covered ? CoverageStatus.Covered : CoverageStatus.NotCovered)); WriteElement("SourceFileID", _curFile + 1); WriteElement("LineID", line.Key); _writer.WriteEndElement(); } _writer.WriteEndElement(); }
private void WriteCoverageData(CoverageScope scope) { WriteCoverageData(scope.LinesCovered, scope.LinesNotCovered, scope.BlocksCovered, scope.BlocksNotCovered); }
private CoverageScope WalkScope(ScopeStatement node) { var prevScope = CurScope; var newScope = new CoverageScope(node); CurScopes.Add(newScope); var wasCovered = _blockCovered; _blockCovered = null; if (node.Body != null) { node.Body.Walk(this); } CurScopes.RemoveAt(CurScopes.Count - 1); _blockCovered = wasCovered; return newScope; }