diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-03-29 23:15:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-29 23:15:07 +0200 |
commit | c60e409471c51864883bd0b874980d0a8857f813 (patch) | |
tree | 64444c3f0210461e398654e3d6dd6f00e0091cd9 /test/unit/helpers.lua | |
parent | c35420558bed0bfa9938ecd1facec88f1df392a5 (diff) | |
parent | 46efe14473fa803f84509592cc1e8fca4eb20640 (diff) | |
download | rneovim-c60e409471c51864883bd0b874980d0a8857f813.tar.gz rneovim-c60e409471c51864883bd0b874980d0a8857f813.tar.bz2 rneovim-c60e409471c51864883bd0b874980d0a8857f813.zip |
Merge #5119 from ZyX-I/split-eval
Diffstat (limited to 'test/unit/helpers.lua')
-rw-r--r-- | test/unit/helpers.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 612b337ee7..8aad3acd98 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -314,6 +314,29 @@ local function alloc_log_new() eq(exp, self.log) self:clear() end + function log:clear_tmp_allocs() + local toremove = {} + local allocs = {} + for i, v in ipairs(self.log) do + if v.func == 'malloc' or v.func == 'calloc' then + allocs[tostring(v.ret)] = i + elseif v.func == 'realloc' or v.func == 'free' then + if allocs[tostring(v.args[1])] then + toremove[#toremove + 1] = allocs[tostring(v.args[1])] + if v.func == 'free' then + toremove[#toremove + 1] = i + end + end + if v.func == 'realloc' then + allocs[tostring(v.ret)] = i + end + end + end + table.sort(toremove) + for i = #toremove,1,-1 do + table.remove(self.log, toremove[i]) + end + end function log:restore_original_functions() -- Do nothing: set mocks live in a separate process return |