protected virtual StatementSuspiciousnessInfo applyRating(StatementSuspiciousnessInfo line, uint passed, uint failed) { // <pex> if (failed + passed == 0uL) throw new ArgumentException("failed + passed == 0uL", "passed"); if (line == (StatementSuspiciousnessInfo)null) throw new ArgumentNullException("line"); // </pex> return line; }
protected override StatementSuspiciousnessInfo applyRating(StatementSuspiciousnessInfo line, uint passed, uint failed) { base.applyRating(line, passed, failed); if ((float)failed == 0) { line.SuspiciousnessRatings.Add(this, 0); return line; } float denominator = (float)Math.Sqrt(failed * (line.Failed + line.Passed)); float rating = line.Failed / denominator; Debug.Assert(!Double.IsNaN(rating)); line.SuspiciousnessRatings.Add(this, rating); return line; }
protected override StatementSuspiciousnessInfo applyRating(StatementSuspiciousnessInfo line, uint passed, uint failed) { base.applyRating(line, passed, failed); line.SuspiciousnessRatings.Add(this, Math.Max(line.Passed, line.Failed)); return line; }
public static IEnumerable<StatementSuspiciousnessInfo> BuildDiagnosisMatrix(IEnumerable<ExecutedTest> tests) { var testedLines = new Dictionary<SourceCodeLocation, StatementSuspiciousnessInfo>(); uint passed = 0; uint failed = 0; foreach(var test in tests) { Console.WriteLine(test); if(test.Result) passed++; else failed++; CoverageDS data = test.CoverageData; foreach(var line in test.Lines) { var location = new SourceCodeLocation(data.SourceFileNames.Where(s => s.SourceFileID == line.SourceFileID).Select(s => s.SourceFileName).First(), (int) line.LnStart, (int) line.LnEnd, (int) line.ColStart, (int) line.ColEnd); StatementSuspiciousnessInfo currentLine; if(!testedLines.TryGetValue(location, out currentLine)) { currentLine = new StatementSuspiciousnessInfo(location); testedLines.Add(location, currentLine); } currentLine.Tests.Add(test); } test.ClearCoverageData(); } return testedLines.Values; }