diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:18 +0100 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:29 +0100 |
| commit | 04f2f864e270e772c6326cefdf24947f0130e492 (patch) | |
| tree | 46f83f909b888a66c741032ab955afc6eab84292 /test/functional/plugin/shada_spec.lua | |
| parent | 59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff) | |
| download | rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2 rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip | |
refactor: format test/*
Diffstat (limited to 'test/functional/plugin/shada_spec.lua')
| -rw-r--r-- | test/functional/plugin/shada_spec.lua | 3578 |
1 files changed, 2133 insertions, 1445 deletions
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua index 8d37100607..ef3fef1897 100644 --- a/test/functional/plugin/shada_spec.lua +++ b/test/functional/plugin/shada_spec.lua @@ -2,8 +2,15 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local eq, meths, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf = - helpers.eq, helpers.meths, helpers.eval, helpers.command, helpers.nvim, helpers.exc_exec, - helpers.funcs, helpers.feed, helpers.curbuf + helpers.eq, + helpers.meths, + helpers.eval, + helpers.command, + helpers.nvim, + helpers.exc_exec, + helpers.funcs, + helpers.feed, + helpers.curbuf local neq = helpers.neq local read_file = helpers.read_file @@ -13,11 +20,11 @@ local shada_helpers = require('test.functional.shada.helpers') local get_shada_rw = shada_helpers.get_shada_rw local function reset(shada_file) - clear{ args={'-u', 'NORC', '-i', shada_file or 'NONE', }} + clear { args = { '-u', 'NORC', '-i', shada_file or 'NONE' } } end local mpack_eq = function(expected, mpack_result) - local mpack_keys = {'type', 'timestamp', 'length', 'value'} + local mpack_keys = { 'type', 'timestamp', 'length', 'value' } local unpack = mpack.Unpacker() local actual = {} @@ -44,8 +51,7 @@ end local wshada, _, fname = get_shada_rw('Xtest-functional-plugin-shada.shada') -local wshada_tmp, _, fname_tmp = - get_shada_rw('Xtest-functional-plugin-shada.shada.tmp.f') +local wshada_tmp, _, fname_tmp = get_shada_rw('Xtest-functional-plugin-shada.shada.tmp.f') describe('autoload/shada.vim', function() local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0) @@ -89,22 +95,31 @@ describe('autoload/shada.vim', function() it('works', function() eq({}, nvim_eval(mpack2sd('[]'))) - eq({{type=1, timestamp=5, length=1, data=7}}, - nvim_eval(mpack2sd('[1, 5, 1, 7]'))) - eq({{type=1, timestamp=5, length=1, data=7}, - {type=1, timestamp=10, length=1, data=5}}, - nvim_eval(mpack2sd('[1, 5, 1, 7, 1, 10, 1, 5]'))) - eq('zero-uint:Entry 1 has type element which is zero', - exc_exec('call ' .. mpack2sd('[0, 5, 1, 7]'))) - eq('zero-uint:Entry 1 has type element which is zero', - exc_exec('call ' .. mpack2sd(('[%s, 5, 1, 7]'):format( - sp('integer', '[1, 0, 0, 0]'))))) - eq('not-uint:Entry 1 has timestamp element which is not an unsigned integer', - exc_exec('call ' .. mpack2sd('[1, -1, 1, 7]'))) - eq('not-uint:Entry 1 has length element which is not an unsigned integer', - exc_exec('call ' .. mpack2sd('[1, 1, -1, 7]'))) - eq('not-uint:Entry 1 has type element which is not an unsigned integer', - exc_exec('call ' .. mpack2sd('["", 1, -1, 7]'))) + eq({ { type = 1, timestamp = 5, length = 1, data = 7 } }, nvim_eval(mpack2sd('[1, 5, 1, 7]'))) + eq({ + { type = 1, timestamp = 5, length = 1, data = 7 }, + { type = 1, timestamp = 10, length = 1, data = 5 }, + }, nvim_eval(mpack2sd('[1, 5, 1, 7, 1, 10, 1, 5]'))) + eq( + 'zero-uint:Entry 1 has type element which is zero', + exc_exec('call ' .. mpack2sd('[0, 5, 1, 7]')) + ) + eq( + 'zero-uint:Entry 1 has type element which is zero', + exc_exec('call ' .. mpack2sd(('[%s, 5, 1, 7]'):format(sp('integer', '[1, 0, 0, 0]')))) + ) + eq( + 'not-uint:Entry 1 has timestamp element which is not an unsigned integer', + exc_exec('call ' .. mpack2sd('[1, -1, 1, 7]')) + ) + eq( + 'not-uint:Entry 1 has length element which is not an unsigned integer', + exc_exec('call ' .. mpack2sd('[1, 1, -1, 7]')) + ) + eq( + 'not-uint:Entry 1 has type element which is not an unsigned integer', + exc_exec('call ' .. mpack2sd('["", 1, -1, 7]')) + ) end) end) @@ -124,15 +139,18 @@ describe('autoload/shada.vim', function() it('works with unknown items', function() sd2strings_eq({ 'Unknown (0x64) with timestamp ' .. epoch .. ':', - ' = 100' - }, {{type=100, timestamp=0, length=1, data=100}}) - - sd2strings_eq({ - 'Unknown (0x4000001180000006) with timestamp ' .. epoch .. ':', - ' = 100' - }, ('[{"type": %s, "timestamp": 0, "length": 1, "data": 100}]'):format( - sp('integer', '[1, 1, 35, 6]') - )) + ' = 100', + }, { { type = 100, timestamp = 0, length = 1, data = 100 } }) + + sd2strings_eq( + { + 'Unknown (0x4000001180000006) with timestamp ' .. epoch .. ':', + ' = 100', + }, + ('[{"type": %s, "timestamp": 0, "length": 1, "data": 100}]'):format( + sp('integer', '[1, 1, 35, 6]') + ) + ) end) it('works with multiple unknown items', function() @@ -141,8 +159,10 @@ describe('autoload/shada.vim', function() ' = 100', 'Unknown (0x65) with timestamp ' .. epoch .. ':', ' = 500', - }, {{type=100, timestamp=0, length=1, data=100}, - {type=101, timestamp=0, length=1, data=500}}) + }, { + { type = 100, timestamp = 0, length = 1, data = 100 }, + { type = 101, timestamp = 0, length = 1, data = 500 }, + }) end) it('works with header items', function() @@ -150,7 +170,7 @@ describe('autoload/shada.vim', function() 'Header with timestamp ' .. epoch .. ':', ' % Key______ Value', ' + generator "test"', - }, {{type=1, timestamp=0, data={generator='test'}}}) + }, { { type = 1, timestamp = 0, data = { generator = 'test' } } }) sd2strings_eq({ 'Header with timestamp ' .. epoch .. ':', ' % Key Description Value', @@ -158,42 +178,44 @@ describe('autoload/shada.vim', function() ' + b 2', ' + c column 3', ' + d 4', - }, {{type=1, timestamp=0, data={a=1, b=2, c=3, d=4}}}) + }, { { type = 1, timestamp = 0, data = { a = 1, b = 2, c = 3, d = 4 } } }) sd2strings_eq({ 'Header with timestamp ' .. epoch .. ':', ' % Key Value', ' + t "test"', - }, {{type=1, timestamp=0, data={t='test'}}}) + }, { { type = 1, timestamp = 0, data = { t = 'test' } } }) sd2strings_eq({ 'Header with timestamp ' .. epoch .. ':', ' # Unexpected type: array instead of map', ' = [1, 2, 3]', - }, {{type=1, timestamp=0, data={1, 2, 3}}}) + }, { { type = 1, timestamp = 0, data = { 1, 2, 3 } } }) end) it('processes standard keys correctly, even in header', function() - sd2strings_eq({ - 'Header with timestamp ' .. epoch .. ':', - ' % Key Description________ Value', - ' + c column 0', - ' + f file name "/tmp/foo"', - ' + l line number 10', - ' + n name \'@\'', - ' + rc contents ["abc", "def"]', - ' + rt type CHARACTERWISE', - ' + ru is_unnamed FALSE', - ' + rw block width 10', - ' + sb search backward TRUE', - ' + sc smartcase value FALSE', - ' + se place cursor at end TRUE', - ' + sh v:hlsearch value TRUE', - ' + sl has line offset FALSE', - ' + sm magic value TRUE', - ' + so offset value 10', - ' + sp pattern "100"', - ' + ss is :s pattern TRUE', - ' + su is last used FALSE', - }, ([[ [{'type': 1, 'timestamp': 0, 'data': { + sd2strings_eq( + { + 'Header with timestamp ' .. epoch .. ':', + ' % Key Description________ Value', + ' + c column 0', + ' + f file name "/tmp/foo"', + ' + l line number 10', + " + n name '@'", + ' + rc contents ["abc", "def"]', + ' + rt type CHARACTERWISE', + ' + ru is_unnamed FALSE', + ' + rw block width 10', + ' + sb search backward TRUE', + ' + sc smartcase value FALSE', + ' + se place cursor at end TRUE', + ' + sh v:hlsearch value TRUE', + ' + sl has line offset FALSE', + ' + sm magic value TRUE', + ' + so offset value 10', + ' + sp pattern "100"', + ' + ss is :s pattern TRUE', + ' + su is last used FALSE', + }, + ([[ [{'type': 1, 'timestamp': 0, 'data': { 'sm': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 'sc': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 'sl': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, @@ -212,34 +234,37 @@ describe('autoload/shada.vim', function() 'l': 10, 'c': 0, 'f': '/tmp/foo', - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Header with timestamp ' .. epoch .. ':', - ' % Key Description____ Value', - ' # Expected integer', - ' + c column "abc"', - ' # Expected no NUL bytes', - ' + f file name "abc\\0def"', - ' # Value is negative', - ' + l line number -10', - ' # Value is negative', - ' + n name -64', - ' # Expected array value', - ' + rc contents "10"', - ' # Unexpected enum value: expected one of ' - .. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)', - ' + rt type 10', - ' # Expected boolean', - ' + ru is_unnamed 10', - ' # Expected boolean', - ' + sc smartcase value NIL', - ' # Expected boolean', - ' + sm magic value "TRUE"', - ' # Expected integer', - ' + so offset value "TRUE"', - ' # Expected binary string', - ' + sp pattern ="abc"', - }, ([[ [{'type': 1, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Header with timestamp ' .. epoch .. ':', + ' % Key Description____ Value', + ' # Expected integer', + ' + c column "abc"', + ' # Expected no NUL bytes', + ' + f file name "abc\\0def"', + ' # Value is negative', + ' + l line number -10', + ' # Value is negative', + ' + n name -64', + ' # Expected array value', + ' + rc contents "10"', + ' # Unexpected enum value: expected one of ' + .. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)', + ' + rt type 10', + ' # Expected boolean', + ' + ru is_unnamed 10', + ' # Expected boolean', + ' + sc smartcase value NIL', + ' # Expected boolean', + ' + sm magic value "TRUE"', + ' # Expected integer', + ' + so offset value "TRUE"', + ' # Expected binary string', + ' + sp pattern ="abc"', + }, + ([[ [{'type': 1, 'timestamp': 0, 'data': { 'sm': 'TRUE', 'sc': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, 'so': 'TRUE', @@ -251,29 +276,36 @@ describe('autoload/shada.vim', function() 'l': -10, 'c': 'abc', 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]}, - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Header with timestamp ' .. epoch .. ':', - ' % Key Description Value', - ' # Expected no NUL bytes', - ' + f file name "abc\\0def"', - ' # Expected array of binary strings', - ' + rc contents ["abc", ="abc"]', - ' # Expected integer', - ' + rt type "ABC"', - }, ([[ [{'type': 1, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Header with timestamp ' .. epoch .. ':', + ' % Key Description Value', + ' # Expected no NUL bytes', + ' + f file name "abc\\0def"', + ' # Expected array of binary strings', + ' + rc contents ["abc", ="abc"]', + ' # Expected integer', + ' + rt type "ABC"', + }, + ([[ [{'type': 1, 'timestamp': 0, 'data': { 'rt': 'ABC', 'rc': ["abc", {'_TYPE': v:msgpack_types.string, '_VAL': ["abc"]}], 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]}, - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Header with timestamp ' .. epoch .. ':', - ' % Key Description Value', - ' # Expected no NUL bytes', - ' + rc contents ["abc", "a\\nd\\0"]', - }, ([[ [{'type': 1, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Header with timestamp ' .. epoch .. ':', + ' % Key Description Value', + ' # Expected no NUL bytes', + ' + rc contents ["abc", "a\\nd\\0"]', + }, + ([[ [{'type': 1, 'timestamp': 0, 'data': { 'rc': ["abc", {'_TYPE': v:msgpack_types.binary, '_VAL': ["a", "d\n"]}], - }}] ]]):gsub('\n', '')) + }}] ]]):gsub('\n', '') + ) end) it('works with search pattern items', function() @@ -281,59 +313,67 @@ describe('autoload/shada.vim', function() 'Search pattern with timestamp ' .. epoch .. ':', ' # Unexpected type: array instead of map', ' = [1, 2, 3]', - }, {{type=2, timestamp=0, data={1, 2, 3}}}) - sd2strings_eq({ - 'Search pattern with timestamp ' .. epoch .. ':', - ' % Key Description________ Value', - ' + sp pattern "abc"', - ' + sh v:hlsearch value FALSE', - ' + ss is :s pattern FALSE', - ' + sb search backward FALSE', - ' + sm magic value TRUE', - ' + sc smartcase value FALSE', - ' + sl has line offset FALSE', - ' + se place cursor at end FALSE', - ' + so offset value 0', - ' + su is last used TRUE', - }, ([[ [{'type': 2, 'timestamp': 0, 'data': { + }, { { type = 2, timestamp = 0, data = { 1, 2, 3 } } }) + sd2strings_eq( + { + 'Search pattern with timestamp ' .. epoch .. ':', + ' % Key Description________ Value', + ' + sp pattern "abc"', + ' + sh v:hlsearch value FALSE', + ' + ss is :s pattern FALSE', + ' + sb search backward FALSE', + ' + sm magic value TRUE', + ' + sc smartcase value FALSE', + ' + sl has line offset FALSE', + ' + se place cursor at end FALSE', + ' + so offset value 0', + ' + su is last used TRUE', + }, + ([[ [{'type': 2, 'timestamp': 0, 'data': { 'sp': 'abc', - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Search pattern with timestamp ' .. epoch .. ':', - ' % Key Description________ Value', - ' + sp pattern "abc"', - ' + sh v:hlsearch value FALSE', - ' + ss is :s pattern FALSE', - ' + sb search backward FALSE', - ' + sm magic value TRUE', - ' + sc smartcase value FALSE', - ' + sl has line offset FALSE', - ' + se place cursor at end FALSE', - ' + so offset value 0', - ' + su is last used TRUE', - ' + sX NIL', - ' + sY NIL', - ' + sZ NIL', - }, ([[ [{'type': 2, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Search pattern with timestamp ' .. epoch .. ':', + ' % Key Description________ Value', + ' + sp pattern "abc"', + ' + sh v:hlsearch value FALSE', + ' + ss is :s pattern FALSE', + ' + sb search backward FALSE', + ' + sm magic value TRUE', + ' + sc smartcase value FALSE', + ' + sl has line offset FALSE', + ' + se place cursor at end FALSE', + ' + so offset value 0', + ' + su is last used TRUE', + ' + sX NIL', + ' + sY NIL', + ' + sZ NIL', + }, + ([[ [{'type': 2, 'timestamp': 0, 'data': { 'sp': 'abc', 'sZ': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, 'sY': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, 'sX': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Search pattern with timestamp ' .. epoch .. ':', - ' % Key Description________ Value', - ' + sp pattern "abc"', - ' + sh v:hlsearch value FALSE', - ' + ss is :s pattern FALSE', - ' + sb search backward FALSE', - ' + sm magic value TRUE', - ' + sc smartcase value FALSE', - ' + sl has line offset FALSE', - ' + se place cursor at end FALSE', - ' + so offset value 0', - ' + su is last used TRUE', - }, ([[ [{'type': 2, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Search pattern with timestamp ' .. epoch .. ':', + ' % Key Description________ Value', + ' + sp pattern "abc"', + ' + sh v:hlsearch value FALSE', + ' + ss is :s pattern FALSE', + ' + sb search backward FALSE', + ' + sm magic value TRUE', + ' + sc smartcase value FALSE', + ' + sl has line offset FALSE', + ' + se place cursor at end FALSE', + ' + so offset value 0', + ' + su is last used TRUE', + }, + ([[ [{'type': 2, 'timestamp': 0, 'data': { 'sp': 'abc', 'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, @@ -344,36 +384,42 @@ describe('autoload/shada.vim', function() 'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 'so': 0, 'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Search pattern with timestamp ' .. epoch .. ':', - ' % Key Description________ Value', - ' # Required key missing: sp', - ' + sh v:hlsearch value FALSE', - ' + ss is :s pattern FALSE', - ' + sb search backward FALSE', - ' + sm magic value TRUE', - ' + sc smartcase value FALSE', - ' + sl has line offset FALSE', - ' + se place cursor at end FALSE', - ' + so offset value 0', - ' + su is last used TRUE', - }, ([[ [{'type': 2, 'timestamp': 0, 'data': { - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Search pattern with timestamp ' .. epoch .. ':', - ' % Key Description________ Value', - ' + sp pattern ""', - ' + sh v:hlsearch value TRUE', - ' + ss is :s pattern TRUE', - ' + sb search backward TRUE', - ' + sm magic value FALSE', - ' + sc smartcase value TRUE', - ' + sl has line offset TRUE', - ' + se place cursor at end TRUE', - ' + so offset value -10', - ' + su is last used FALSE', - }, ([[ [{'type': 2, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Search pattern with timestamp ' .. epoch .. ':', + ' % Key Description________ Value', + ' # Required key missing: sp', + ' + sh v:hlsearch value FALSE', + ' + ss is :s pattern FALSE', + ' + sb search backward FALSE', + ' + sm magic value TRUE', + ' + sc smartcase value FALSE', + ' + sl has line offset FALSE', + ' + se place cursor at end FALSE', + ' + so offset value 0', + ' + su is last used TRUE', + }, + ([[ [{'type': 2, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Search pattern with timestamp ' .. epoch .. ':', + ' % Key Description________ Value', + ' + sp pattern ""', + ' + sh v:hlsearch value TRUE', + ' + ss is :s pattern TRUE', + ' + sb search backward TRUE', + ' + sm magic value FALSE', + ' + sc smartcase value TRUE', + ' + sl has line offset TRUE', + ' + se place cursor at end TRUE', + ' + so offset value -10', + ' + su is last used FALSE', + }, + ([[ [{'type': 2, 'timestamp': 0, 'data': { 'sp': '', 'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, @@ -384,31 +430,34 @@ describe('autoload/shada.vim', function() 'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 'so': -10, 'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, - }}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Search pattern with timestamp ' .. epoch .. ':', - ' % Key Description________ Value', - ' # Expected binary string', - ' + sp pattern 0', - ' # Expected boolean', - ' + sh v:hlsearch value 0', - ' # Expected boolean', - ' + ss is :s pattern 0', - ' # Expected boolean', - ' + sb search backward 0', - ' # Expected boolean', - ' + sm magic value 0', - ' # Expected boolean', - ' + sc smartcase value 0', - ' # Expected boolean', - ' + sl has line offset 0', - ' # Expected boolean', - ' + se place cursor at end 0', - ' # Expected integer', - ' + so offset value ""', - ' # Expected boolean', - ' + su is last used 0', - }, ([[ [{'type': 2, 'timestamp': 0, 'data': { + }}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Search pattern with timestamp ' .. epoch .. ':', + ' % Key Description________ Value', + ' # Expected binary string', + ' + sp pattern 0', + ' # Expected boolean', + ' + sh v:hlsearch value 0', + ' # Expected boolean', + ' + ss is :s pattern 0', + ' # Expected boolean', + ' + sb search backward 0', + ' # Expected boolean', + ' + sm magic value 0', + ' # Expected boolean', + ' + sc smartcase value 0', + ' # Expected boolean', + ' + sl has line offset 0', + ' # Expected boolean', + ' + se place cursor at end 0', + ' # Expected integer', + ' + so offset value ""', + ' # Expected boolean', + ' + su is last used 0', + }, + ([[ [{'type': 2, 'timestamp': 0, 'data': { 'sp': 0, 'sh': 0, 'ss': 0, @@ -419,7 +468,8 @@ describe('autoload/shada.vim', function() 'se': 0, 'so': '', 'su': 0, - }}] ]]):gsub('\n', '')) + }}] ]]):gsub('\n', '') + ) end) it('works with replacement string items', function() @@ -427,45 +477,60 @@ describe('autoload/shada.vim', function() 'Replacement string with timestamp ' .. epoch .. ':', ' # Unexpected type: map instead of array', ' = {="a": [10]}', - }, {{type=3, timestamp=0, data={a={10}}}}) - sd2strings_eq({ - 'Replacement string with timestamp ' .. epoch .. ':', - ' @ Description__________ Value', - ' # Expected more elements in list' - }, ([[ [{'type': 3, 'timestamp': 0, 'data': [ - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Replacement string with timestamp ' .. epoch .. ':', - ' @ Description__________ Value', - ' # Expected binary string', - ' - :s replacement string 0', - }, ([[ [{'type': 3, 'timestamp': 0, 'data': [ + }, { { type = 3, timestamp = 0, data = { a = { 10 } } } }) + sd2strings_eq( + { + 'Replacement string with timestamp ' .. epoch .. ':', + ' @ Description__________ Value', + ' # Expected more elements in list', + }, + ([[ [{'type': 3, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Replacement string with timestamp ' .. epoch .. ':', + ' @ Description__________ Value', + ' # Expected binary string', + ' - :s replacement string 0', + }, + ([[ [{'type': 3, 'timestamp': 0, 'data': [ 0, - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Replacement string with timestamp ' .. epoch .. ':', - ' @ Description__________ Value', - ' # Expected no NUL bytes', - ' - :s replacement string "abc\\0def"', - }, ([[ [{'type': 3, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Replacement string with timestamp ' .. epoch .. ':', + ' @ Description__________ Value', + ' # Expected no NUL bytes', + ' - :s replacement string "abc\\0def"', + }, + ([[ [{'type': 3, 'timestamp': 0, 'data': [ {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]}, - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Replacement string with timestamp ' .. epoch .. ':', - ' @ Description__________ Value', - ' - :s replacement string "abc\\ndef"', - }, ([[ [{'type': 3, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Replacement string with timestamp ' .. epoch .. ':', + ' @ Description__________ Value', + ' - :s replacement string "abc\\ndef"', + }, + ([[ [{'type': 3, 'timestamp': 0, 'data': [ {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc", "def"]}, - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'Replacement string with timestamp ' .. epoch .. ':', - ' @ Description__________ Value', - ' - :s replacement string "abc\\ndef"', - ' - 0', - }, ([[ [{'type': 3, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'Replacement string with timestamp ' .. epoch .. ':', + ' @ Description__________ Value', + ' - :s replacement string "abc\\ndef"', + ' - 0', + }, + ([[ [{'type': 3, 'timestamp': 0, 'data': [ {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc", "def"]}, 0, - ]}] ]]):gsub('\n', '')) + ]}] ]]):gsub('\n', '') + ) end) it('works with history entry items', function() @@ -473,161 +538,206 @@ describe('autoload/shada.vim', function() 'History entry with timestamp ' .. epoch .. ':', ' # Unexpected type: map instead of array', ' = {="a": [10]}', - }, {{type=4, timestamp=0, data={a={10}}}}) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' # Expected more elements in list' - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' # Expected integer', - ' - history type ""', - ' # Expected more elements in list' - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + }, { { type = 4, timestamp = 0, data = { a = { 10 } } } }) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' # Expected more elements in list', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' # Expected integer', + ' - history type ""', + ' # Expected more elements in list', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ '', - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' .. '2 (EXPR), 3 (INPUT), 4 (DEBUG)', - ' - history type 5', - ' - contents ""', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ' - history type 5', + ' - contents ""', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 5, '' - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' .. '2 (EXPR), 3 (INPUT), 4 (DEBUG)', - ' - history type 5', - ' - contents ""', - ' - 32', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ' - history type 5', + ' - contents ""', + ' - 32', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 5, '', 0x20 - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents ""', - ' - 32', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents ""', + ' - 32', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 0, '', 0x20 - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type SEARCH', - ' - contents ""', - ' - separator \' \'', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type SEARCH', + ' - contents ""', + " - separator ' '", + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 1, '', 0x20 - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type SEARCH', - ' - contents ""', - ' # Expected more elements in list', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type SEARCH', + ' - contents ""', + ' # Expected more elements in list', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 1, '', - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type EXPR', - ' - contents ""', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type EXPR', + ' - contents ""', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 2, '', - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type INPUT', - ' - contents ""', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type INPUT', + ' - contents ""', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 3, '', - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type DEBUG', - ' - contents ""', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type DEBUG', + ' - contents ""', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 4, '', - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type DEBUG', - ' # Expected binary string', - ' - contents 10', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type DEBUG', + ' # Expected binary string', + ' - contents 10', + }, + ([[ [{'type': 4, 'timestamp': 0, 'data': [ 4, 10, - ]}] ]]):gsub('\n', '')) - sd2strings_eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type DEBUG', - ' # Expected no NUL bytes', - ' - contents "abc\\0def"', - }, ([[ [{'type': 4, 'timestamp': 0, 'data': [ + ]}] ]]):gsub('\n', '') + ) + sd2strings_eq( + { + 'History entry with timestamp ' .. epoch .. ':', |