diff options
author | ZyX <kp-pav@yandex.ru> | 2017-03-12 21:58:57 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-29 10:08:45 +0300 |
commit | bc87d23c28c10c70b4addaf18ae16bcbe0682c8a (patch) | |
tree | cf90454d9e40e6108f44e971d7bb405bd69ba784 /test/unit/helpers.lua | |
parent | b222453c95dbe466b79abd578642fa6038770a55 (diff) | |
download | rneovim-bc87d23c28c10c70b4addaf18ae16bcbe0682c8a.tar.gz rneovim-bc87d23c28c10c70b4addaf18ae16bcbe0682c8a.tar.bz2 rneovim-bc87d23c28c10c70b4addaf18ae16bcbe0682c8a.zip |
unittests: Add tests for dictionary indexing
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 |