diff --git a/bin/moon b/bin/moon index 8ce4982..b6ef27f 100755 --- a/bin/moon +++ b/bin/moon @@ -108,6 +108,7 @@ if not opts.d then else if cov then cov:stop() + cov:print_results() end end else diff --git a/moonscript/cmd/coverage.lua b/moonscript/cmd/coverage.lua index daac16f..8c585e8 100644 --- a/moonscript/cmd/coverage.lua +++ b/moonscript/cmd/coverage.lua @@ -59,8 +59,10 @@ end local CodeCoverage do local _base_0 = { - start = function(self) + reset = function(self) self.line_counts = create_counter() + end, + start = function(self) return debug.sethook((function() local _base_1 = self local _fn_0 = _base_1.process_line @@ -70,8 +72,9 @@ do end)(), "l") end, stop = function(self) - debug.sethook() - local line_table = require("moonscript.line_tables") + return debug.sethook() + end, + print_results = function(self) return self:format_results() end, process_line = function(self, _, line_no) @@ -118,7 +121,9 @@ do } _base_0.__index = _base_0 local _class_0 = setmetatable({ - __init = function() end, + __init = function(self) + return self:reset() + end, __base = _base_0, __name = "CodeCoverage" }, { diff --git a/moonscript/cmd/coverage.moon b/moonscript/cmd/coverage.moon index 55e6a78..dd1d1fa 100644 --- a/moonscript/cmd/coverage.moon +++ b/moonscript/cmd/coverage.moon @@ -40,14 +40,19 @@ format_file = (fname, positions) -> class CodeCoverage - start: => + new: => + @reset! + + reset: => @line_counts = create_counter! + + start: => debug.sethook @\process_line, "l" stop: => debug.sethook! - line_table = require "moonscript.line_tables" + print_results: => @format_results! process_line: (_, line_no) =>