From abf656204f2da4cd2ef1183d2e3d4eff357e60b4 Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Sat, 26 Mar 2016 15:05:48 +0100 Subject: [PATCH 1/3] try adding branch coverage --- test/TestMain.hx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/TestMain.hx b/test/TestMain.hx index ee8b13d3..2eed2664 100644 --- a/test/TestMain.hx +++ b/test/TestMain.hx @@ -6,6 +6,7 @@ import token.TokenTreeBuilderTest; import mcover.coverage.client.PrintClient; import mcover.coverage.data.CoverageResult; import mcover.coverage.data.Statement; +import mcover.coverage.data.Branch; import mcover.coverage.MCoverage; using StringTools; @@ -36,14 +37,23 @@ class TestMain { var report = { coverage: {} }; var classes = logger.coverage.getClasses(); for (cls in classes) { - var coverageData = [null]; + var coverageData:Array = [null]; var results:CoverageResult = cls.getResults(); - for (i in 1...results.l) coverageData[i] = 1; + for (i in 1...results.l) coverageData[i] = "1"; var c = cls.name.replace(".", "/") + ".hx"; var missingStatements:Array = cls.getMissingStatements(); for (stmt in missingStatements) { - for (line in stmt.lines) coverageData[line] = 0; + for (line in stmt.lines) coverageData[line] = "0"; + } + var missingBranches:Array = cls.getMissingBranches(); + for (branch in missingBranches) { + if (branch.lines.length <= 0) continue; + var count:Int = 0; + if (branch.trueCount > 0) count++; + if (branch.falseCount > 0) count++; + var line:Int = branch.lines[branch.lines.length - 1]; + coverageData[line] = count + "/2"; } Reflect.setField(report.coverage, c, coverageData); From 1cc711286862681c99154a35f2a1f818fb1ee2e2 Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Sat, 26 Mar 2016 15:20:25 +0100 Subject: [PATCH 2/3] try Dynamic for coverage results --- test/TestMain.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/TestMain.hx b/test/TestMain.hx index 2eed2664..936be377 100644 --- a/test/TestMain.hx +++ b/test/TestMain.hx @@ -37,14 +37,14 @@ class TestMain { var report = { coverage: {} }; var classes = logger.coverage.getClasses(); for (cls in classes) { - var coverageData:Array = [null]; + var coverageData:Array = [null]; var results:CoverageResult = cls.getResults(); - for (i in 1...results.l) coverageData[i] = "1"; + for (i in 1...results.l) coverageData[i] = 1; var c = cls.name.replace(".", "/") + ".hx"; var missingStatements:Array = cls.getMissingStatements(); for (stmt in missingStatements) { - for (line in stmt.lines) coverageData[line] = "0"; + for (line in stmt.lines) coverageData[line] = 0; } var missingBranches:Array = cls.getMissingBranches(); for (branch in missingBranches) { From b2983d23e369cebaefcb02927532469eec91829d Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Sat, 26 Mar 2016 15:28:47 +0100 Subject: [PATCH 3/3] suppress Dynamic warning for LineCoverageResult --- checkstyle.json | 3 ++- test/TestMain.hx | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/checkstyle.json b/checkstyle.json index e01ae35c..646f643f 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -517,7 +517,8 @@ "checkstyle.Main", "checkstyle.Checker", "checkstyle.ChecksInfo", - "checkstyle.checks.imports.UnusedImportCheck" + "checkstyle.checks.imports.UnusedImportCheck", + "TestMain" ], "MultipleStringLiterals": [ "checks", diff --git a/test/TestMain.hx b/test/TestMain.hx index 936be377..ea323e9d 100644 --- a/test/TestMain.hx +++ b/test/TestMain.hx @@ -37,7 +37,7 @@ class TestMain { var report = { coverage: {} }; var classes = logger.coverage.getClasses(); for (cls in classes) { - var coverageData:Array = [null]; + var coverageData:Array = [null]; var results:CoverageResult = cls.getResults(); for (i in 1...results.l) coverageData[i] = 1; var c = cls.name.replace(".", "/") + ".hx"; @@ -67,4 +67,6 @@ class TestMain { static function main() { new TestMain(); } -} \ No newline at end of file +} + +typedef LineCoverageResult = Dynamic; \ No newline at end of file