aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/shada_spec.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-06-25 15:33:47 +0200
committerbfredl <bjorn.linse@gmail.com>2024-06-27 11:04:04 +0200
commitbda63d5b97dfb333de6f4bd757dbb978906062a2 (patch)
tree65b2460064f42b39e33bf7bc7507f973b907dd37 /test/functional/plugin/shada_spec.lua
parent9e436251de0329b1479365ff162d87ef18d6d14c (diff)
downloadrneovim-bda63d5b97dfb333de6f4bd757dbb978906062a2.tar.gz
rneovim-bda63d5b97dfb333de6f4bd757dbb978906062a2.tar.bz2
rneovim-bda63d5b97dfb333de6f4bd757dbb978906062a2.zip
refactor(typval)!: remove distinction of binary and nonbinary strings
This is a breaking change which will make refactor of typval and shada code a lot easier. In particular, code that would use or check for v:msgpack_types.binary in the wild would be broken. This appears to be rarely used in existing plugins. Also some cases where v:msgpack_type.string would be used to represent a binary string of "string" type, we use a BLOB instead, which is vimscripts native type for binary blobs, and already was used for BIN formats when necessary. msgpackdump(msgpackparse(data)) no longer preserves the distinction of BIN and STR strings. This is very common behavior for language-specific msgpack bindings. Nvim uses msgpack as a tool to serialize its data. Nvim is not a tool to bit-perfectly manipulate arbitrary msgpack data out in the wild. The changed tests should indicate how behavior changes in various edge cases.
Diffstat (limited to 'test/functional/plugin/shada_spec.lua')
-rw-r--r--test/functional/plugin/shada_spec.lua77
1 files changed, 37 insertions, 40 deletions
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index 1c2bcbd497..c9d49f7d01 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -68,7 +68,7 @@ describe('autoload/shada.vim', function()
endfor
return ret
elseif type(a:val) == type('')
- return {'_TYPE': v:msgpack_types.binary, '_VAL': split(a:val, "\n", 1)}
+ return {'_TYPE': v:msgpack_types.string, '_VAL': split(a:val, "\n", 1)}
else
return a:val
endif
@@ -253,8 +253,7 @@ describe('autoload/shada.vim', function()
' + sm magic value "TRUE"',
' # Expected integer',
' + so offset value "TRUE"',
- ' # Expected binary string',
- ' + sp pattern ="abc"',
+ ' + sp pattern "abc"',
},
([[ [{'type': 1, 'timestamp': 0, 'data': {
'sm': 'TRUE',
@@ -267,7 +266,7 @@ describe('autoload/shada.vim', function()
'n': -0x40,
'l': -10,
'c': 'abc',
- 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]},
+ 'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]},
}}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -276,15 +275,14 @@ describe('autoload/shada.vim', function()
' % Key Description Value',
' # Expected no NUL bytes',
' + f file name "abc\\0def"',
- ' # Expected array of binary strings',
- ' + rc contents ["abc", ="abc"]',
+ ' + 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"]},
+ 'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]},
}}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -295,7 +293,7 @@ describe('autoload/shada.vim', function()
' + rc contents ["abc", "a\\nd\\0"]',
},
([[ [{'type': 1, 'timestamp': 0, 'data': {
- 'rc': ["abc", {'_TYPE': v:msgpack_types.binary, '_VAL': ["a", "d\n"]}],
+ 'rc': ["abc", {'_TYPE': v:msgpack_types.string, '_VAL': ["a", "d\n"]}],
}}] ]]):gsub('\n', '')
)
end)
@@ -468,7 +466,7 @@ describe('autoload/shada.vim', function()
sd2strings_eq({
'Replacement string with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
}, { { type = 3, timestamp = 0, data = { a = { 10 } } } })
sd2strings_eq(
{
@@ -498,7 +496,7 @@ describe('autoload/shada.vim', function()
' - :s replacement string "abc\\0def"',
},
([[ [{'type': 3, 'timestamp': 0, 'data': [
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]},
]}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -508,7 +506,7 @@ describe('autoload/shada.vim', function()
' - :s replacement string "abc\\ndef"',
},
([[ [{'type': 3, 'timestamp': 0, 'data': [
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc", "def"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["abc", "def"]},
]}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -519,7 +517,7 @@ describe('autoload/shada.vim', function()
' - 0',
},
([[ [{'type': 3, 'timestamp': 0, 'data': [
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc", "def"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["abc", "def"]},
0,
]}] ]]):gsub('\n', '')
)
@@ -529,7 +527,7 @@ describe('autoload/shada.vim', function()
sd2strings_eq({
'History entry with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
}, { { type = 4, timestamp = 0, data = { a = { 10 } } } })
sd2strings_eq(
{
@@ -682,7 +680,7 @@ describe('autoload/shada.vim', function()
},
([[ [{'type': 4, 'timestamp': 0, 'data': [
4,
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]},
]}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -909,7 +907,7 @@ describe('autoload/shada.vim', function()
sd2strings_eq({
'Variable with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
}, { { type = 6, timestamp = 0, data = { a = { 10 } } } })
sd2strings_eq(
{
@@ -941,7 +939,7 @@ describe('autoload/shada.vim', function()
' # Expected more elements in list',
},
([[ [{'type': 6, 'timestamp': 0, 'data': [
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]},
]}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -952,7 +950,7 @@ describe('autoload/shada.vim', function()
' # Expected more elements in list',
},
([[ [{'type': 6, 'timestamp': 0, 'data': [
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["foo"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["foo"]},
]}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -963,7 +961,7 @@ describe('autoload/shada.vim', function()
' - value NIL',
},
([[ [{'type': 6, 'timestamp': 0, 'data': [
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["foo"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["foo"]},
{'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]},
]}] ]]):gsub('\n', '')
)
@@ -976,7 +974,7 @@ describe('autoload/shada.vim', function()
' - NIL',
},
([[ [{'type': 6, 'timestamp': 0, 'data': [
- {'_TYPE': v:msgpack_types.binary, '_VAL': ["foo"]},
+ {'_TYPE': v:msgpack_types.string, '_VAL': ["foo"]},
{'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]},
{'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]},
]}] ]]):gsub('\n', '')
@@ -1041,7 +1039,7 @@ describe('autoload/shada.vim', function()
},
([[ [{'type': 7, 'timestamp': 0, 'data': {
'n': -10,
- 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ 'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]},
}}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -1174,7 +1172,7 @@ describe('autoload/shada.vim', function()
},
([[ [{'type': 8, 'timestamp': 0, 'data': {
'n': -10,
- 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ 'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]},
}}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -1237,7 +1235,7 @@ describe('autoload/shada.vim', function()
sd2strings_eq({
'Buffer list with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
}, { { type = 9, timestamp = 0, data = { a = { 10 } } } })
sd2strings_eq({
'Buffer list with timestamp ' .. epoch .. ':',
@@ -1247,7 +1245,7 @@ describe('autoload/shada.vim', function()
sd2strings_eq({
'Buffer list with timestamp ' .. epoch .. ':',
' # Expected array of maps',
- ' = [{="a": 10}, []]',
+ ' = [{"a": 10}, []]',
}, { { type = 9, timestamp = 0, data = { { a = 10 }, {} } } })
sd2strings_eq({
'Buffer list with timestamp ' .. epoch .. ':',
@@ -1322,7 +1320,7 @@ describe('autoload/shada.vim', function()
},
([[ [{'type': 9, 'timestamp': 0, 'data': [
{'f': 10},
- {'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]}},
+ {'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]}},
]}] ]]):gsub('\n', '')
)
end)
@@ -1385,7 +1383,7 @@ describe('autoload/shada.vim', function()
},
([[ [{'type': 10, 'timestamp': 0, 'data': {
'n': -10,
- 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ 'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]},
}}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -1504,7 +1502,7 @@ describe('autoload/shada.vim', function()
},
([[ [{'type': 11, 'timestamp': 0, 'data': {
'n': -10,
- 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ 'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]},
}}] ]]):gsub('\n', '')
)
sd2strings_eq(
@@ -1616,7 +1614,7 @@ describe('autoload/shada.vim', function()
timestamp = 0,
data = {
c = 'abc',
- f = { '!binary', { 'abc\ndef' } },
+ f = { '!string', { 'abc\ndef' } },
l = -10,
n = -64,
rc = '10',
@@ -1711,7 +1709,7 @@ describe('autoload/shada.vim', function()
timestamp = 0,
data = {
c = 'abc',
- f = { '!binary', { 'abc\ndef' } },
+ f = { '!string', { 'abc\ndef' } },
l = -10,
n = -64,
rc = '10',
@@ -1892,7 +1890,7 @@ describe('autoload/shada.vim', function()
} } }, {
'Replacement string with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
})
strings2sd_eq({ { type = 3, timestamp = 0, data = {} } }, {
'Replacement string with timestamp ' .. epoch .. ':',
@@ -1934,7 +1932,7 @@ describe('autoload/shada.vim', function()
} } }, {
'History entry with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
})
strings2sd_eq({ { type = 4, timestamp = 0, data = {} } }, {
'History entry with timestamp ' .. epoch .. ':',
@@ -2184,7 +2182,7 @@ describe('autoload/shada.vim', function()
} } }, {
'Variable with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
})
strings2sd_eq({ { type = 6, timestamp = 0, data = {} } }, {
'Variable with timestamp ' .. epoch .. ':',
@@ -2315,7 +2313,7 @@ describe('autoload/shada.vim', function()
} } }, {
'Buffer list with timestamp ' .. epoch .. ':',
' # Unexpected type: map instead of array',
- ' = {="a": [10]}',
+ ' = {"a": [10]}',
})
strings2sd_eq(
{ { type = 9, timestamp = 0, data = {
@@ -2325,7 +2323,7 @@ describe('autoload/shada.vim', function()
{
'Buffer list with timestamp ' .. epoch .. ':',
' # Expected array of maps',
- ' = [{="a": 10}, []]',
+ ' = [{"a": 10}, []]',
}
)
strings2sd_eq({ { type = 9, timestamp = 0, data = {
@@ -2421,7 +2419,7 @@ describe('autoload/shada.vim', function()
timestamp = 0,
data = {
{ f = 10 },
- { f = { '!binary', { '\n' } } },
+ { f = { '!string', { '\n' } } },
},
},
}, {
@@ -2955,7 +2953,7 @@ describe('ftplugin/shada.vim', function()
' - :s replacement string "abc\\ndef"',
' Buffer list with timestamp ' .. epoch .. ':',
' # Expected array of maps',
- '= [{="a": 10}, []]',
+ '= [{"a": 10}, []]',
' Buffer list with timestamp ' .. epoch .. ':',
' % Key Description Value',
' # Expected binary string',
@@ -2992,7 +2990,7 @@ describe('ftplugin/shada.vim', function()
' - :s replacement string "abc\\ndef"',
'Buffer list with timestamp ' .. epoch .. ':',
' # Expected array of maps',
- ' = [{="a": 10}, []]',
+ ' = [{"a": 10}, []]',
'Buffer list with timestamp ' .. epoch .. ':',
' % Key Description Value',
' # Expected binary string',
@@ -3083,7 +3081,7 @@ describe('syntax/shada.vim', function()
' - :s replacement string DEBUG',
'Buffer list with timestamp ' .. epoch .. ':',
' # Expected array of maps',
- ' = [{="a": +(10)"ac\\0df\\ngi\\"tt\\.", TRUE: FALSE}, [NIL, +(-10)""]]',
+ ' = [{"a": +(10)"ac\\0df\\ngi\\"tt\\.", TRUE: FALSE}, [NIL, +(-10)""]]',
'Buffer list with timestamp ' .. epoch .. ':',
' % Key Description Value',
'',
@@ -3119,8 +3117,8 @@ describe('syntax/shada.vim', function()
{1: -} {4::s replacement string} {1:DEBUG} |
{1:Buffer list} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: |
{4: # Expected array of maps} |
- = {1:[{="}{3:a}{1:":} {1:+(}{5:10}{1:)"}{3:ac}{6:\0}{3:df}{6:\n}{3:gi}{6:\"}{3:tt\.}{1:",} {1:TRUE:} {1:FALSE},} {1:[NIL,} {1:+(}{5:-}|
- {5:10}{1:)""]]} |
+ = {1:[{"}{3:a}{1:":} {1:+(}{5:10}{1:)"}{3:ac}{6:\0}{3:df}{6:\n}{3:gi}{6:\"}{3:tt\.}{1:",} {1:TRUE:} {1:FALSE},} {1:[NIL,} {1:+(}{5:-1}|
+ {5:0}{1:)""]]} |
{1:Buffer list} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: |
{2: % Key Description Value} |
|
@@ -3464,7 +3462,6 @@ describe('syntax/shada.vim', function()
{ { 'ShaDaEntryRawMsgpack' }, ' = ' },
{ { 'ShaDaMsgpackArray', 'ShaDaMsgpackArrayBraces' }, '[' },
{ { 'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackMapBraces' }, '{' },
- { { 'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackString' }, '=' },
{
{
'ShaDaMsgpackArray',