diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cli.lua | 6 | ||||
-rw-r--r-- | tests/coroutines/expected.out | 43 | ||||
-rw-r--r-- | tests/filefilter/expected.out | 17 | ||||
-rw-r--r-- | tests/filefilter/expected2.out | 11 | ||||
-rw-r--r-- | tests/hook/expected.out | 27 | ||||
-rw-r--r-- | tests/nested/expected.out | 41 | ||||
-rw-r--r-- | tests/simple/expected.out | 17 |
7 files changed, 84 insertions, 78 deletions
diff --git a/tests/cli.lua b/tests/cli.lua index 528aa02..4f7370d 100644 --- a/tests/cli.lua +++ b/tests/cli.lua @@ -22,7 +22,7 @@ local function read(file) end -- dir must be a subdir of tests/ containing expected.out or expected_file. --- The file can contain 'H' to match any number of hits. +-- The file can contain 'X' to match any number of hits. -- flags will be passed to luacov. local function test(dir, expected_file, flags) ntests = ntests + 1 @@ -45,8 +45,8 @@ local function test(dir, expected_file, flags) local ok - if expected:find("H") then - local expected_pattern = expected:gsub("%p", "%%%0"):gsub("H", "%%d+") + if expected:find("X") then + local expected_pattern = expected:gsub("%p", "%%%0"):gsub("X", "%%d+") ok = actual:match("^" .. expected_pattern .. "$") else ok = actual == expected diff --git a/tests/coroutines/expected.out b/tests/coroutines/expected.out index f4c60c7..8a9468f 100644 --- a/tests/coroutines/expected.out +++ b/tests/coroutines/expected.out @@ -1,29 +1,30 @@ - ============================================================================== test.lua ============================================================================== - 1 local runner = require "luacov.runner" - - local function f(x) - H return coroutine.yield(x + 1) + 2 - end - - local function g(x) - H return coroutine.yield(x + 3) + 4 - end - - H local wf = coroutine.wrap(f) - H local wg = corowrap(runner.with_luacov(g)) - - 1 assert(wf(3) == 4) - 1 assert(wf(5) == 7) - 1 assert(wg(8) == 11) - 1 assert(wg(10) == 14) + 1 local runner = require "luacov.runner" + + local function f(x) + X return coroutine.yield(x + 1) + 2 + end + + local function g(x) + X return coroutine.yield(x + 3) + 4 + end + + X local wf = coroutine.wrap(f) + X local wg = corowrap(runner.with_luacov(g)) + + 1 assert(wf(3) == 4) + 1 assert(wf(5) == 7) + 1 assert(wg(8) == 11) + 1 assert(wg(10) == 14) ============================================================================== Summary ============================================================================== -9 0 100.00% test.lua ------------------------- -9 0 100.00% +File Hits Missed Coverage +----------------------------- +test.lua 9 0 100.00% +----------------------------- +Total 9 0 100.00% diff --git a/tests/filefilter/expected.out b/tests/filefilter/expected.out index 5b92f85..a22d8ee 100644 --- a/tests/filefilter/expected.out +++ b/tests/filefilter/expected.out @@ -1,20 +1,21 @@ - ============================================================================== test.lua ============================================================================== - 1 require "test2" - 1 require "test3" + 1 require "test2" + 1 require "test3" ============================================================================== test2.lua ============================================================================== - 1 local a = 1 + 1 local a = 1 ============================================================================== Summary ============================================================================== -2 0 100.00% test.lua -1 0 100.00% test2.lua ------------------------- -3 0 100.00% +File Hits Missed Coverage +------------------------------ +test.lua 2 0 100.00% +test2.lua 1 0 100.00% +------------------------------ +Total 3 0 100.00% diff --git a/tests/filefilter/expected2.out b/tests/filefilter/expected2.out index 9e11fc1..3fca0c6 100644 --- a/tests/filefilter/expected2.out +++ b/tests/filefilter/expected2.out @@ -1,13 +1,14 @@ - ============================================================================== test2.lua ============================================================================== - 1 local a = 1 + 1 local a = 1 ============================================================================== Summary ============================================================================== -1 0 100.00% test2.lua ------------------------- -1 0 100.00% +File Hits Missed Coverage +------------------------------ +test2.lua 1 0 100.00% +------------------------------ +Total 1 0 100.00% diff --git a/tests/hook/expected.out b/tests/hook/expected.out index fe99697..b925ece 100644 --- a/tests/hook/expected.out +++ b/tests/hook/expected.out @@ -1,25 +1,26 @@ - ============================================================================== my_hook.lua ============================================================================== - 1 local runner = require "luacov.runner" - 1 return function(_, line) runner.debug_hook(_, line, 3) end + 1 local runner = require "luacov.runner" + 1 return function(_, line) runner.debug_hook(_, line, 3) end ============================================================================== test.lua ============================================================================== - 1 local runner = require "luacov.runner" - 1 local my_hook = require "my_hook" - 1 debug.sethook(my_hook, "line") - 1 local a = 2 - 1 debug.sethook(runner.debug_hook, "line") - 1 local b = 3 + 1 local runner = require "luacov.runner" + 1 local my_hook = require "my_hook" + 1 debug.sethook(my_hook, "line") + 1 local a = 2 + 1 debug.sethook(runner.debug_hook, "line") + 1 local b = 3 ============================================================================== Summary ============================================================================== -2 0 100.00% my_hook.lua -6 0 100.00% test.lua ------------------------- -8 0 100.00% +File Hits Missed Coverage +-------------------------------- +my_hook.lua 2 0 100.00% +test.lua 6 0 100.00% +-------------------------------- +Total 8 0 100.00% diff --git a/tests/nested/expected.out b/tests/nested/expected.out index 28784b2..fb5891e 100644 --- a/tests/nested/expected.out +++ b/tests/nested/expected.out @@ -1,28 +1,29 @@ - ============================================================================== testlib.lua ============================================================================== - 2 local a = 1 - 2 local b = 2 - - 2 local lib = {} - - 2 function lib.f1() - 2 local c = 3 - 2 return 4 - end - - 2 function lib.f2() - 3 local d = 5 - 3 return 6 - end - - 2 return lib + 2 local a = 1 + 2 local b = 2 + + 2 local lib = {} + + 2 function lib.f1() + 2 local c = 3 + 2 return 4 + end + + 2 function lib.f2() + 3 local d = 5 + 3 return 6 + end + + 2 return lib ============================================================================== Summary ============================================================================== -10 0 100.00% testlib.lua ------------------------- -10 0 100.00% +File Hits Missed Coverage +-------------------------------- +testlib.lua 10 0 100.00% +-------------------------------- +Total 10 0 100.00% diff --git a/tests/simple/expected.out b/tests/simple/expected.out index ebb3690..a1c1d6b 100644 --- a/tests/simple/expected.out +++ b/tests/simple/expected.out @@ -1,16 +1,17 @@ - ============================================================================== test.lua ============================================================================== - 1 local a = 1 - 1 local b = 2 - - 1 local c = 3 + 1 local a = 1 + 1 local b = 2 + + 1 local c = 3 ============================================================================== Summary ============================================================================== -3 0 100.00% test.lua ------------------------- -3 0 100.00% +File Hits Missed Coverage +----------------------------- +test.lua 3 0 100.00% +----------------------------- +Total 3 0 100.00% |