mirror of
https://github.com/neovim/neovim.git
synced 2025-11-04 17:54:30 +00:00
runtime/msgpack: Add support for special values
This commit is contained in:
@@ -356,6 +356,8 @@ let s:MSGPACK_STANDARD_TYPES = {
|
|||||||
\type(''): 'binary',
|
\type(''): 'binary',
|
||||||
\type([]): 'array',
|
\type([]): 'array',
|
||||||
\type({}): 'map',
|
\type({}): 'map',
|
||||||
|
\type(v:true): 'boolean',
|
||||||
|
\type(v:null): 'nil',
|
||||||
\}
|
\}
|
||||||
|
|
||||||
""
|
""
|
||||||
@@ -379,7 +381,7 @@ endfunction
|
|||||||
""
|
""
|
||||||
" Dump boolean value.
|
" Dump boolean value.
|
||||||
function s:msgpack_dump_boolean(v) abort
|
function s:msgpack_dump_boolean(v) abort
|
||||||
return a:v._VAL ? 'TRUE' : 'FALSE'
|
return (a:v is v:true || (a:v isnot v:false && a:v._VAL)) ? 'TRUE' : 'FALSE'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
""
|
""
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
|
local meths = helpers.meths
|
||||||
local eq, nvim_eval, nvim_command, exc_exec =
|
local eq, nvim_eval, nvim_command, exc_exec =
|
||||||
helpers.eq, helpers.eval, helpers.command, helpers.exc_exec
|
helpers.eq, helpers.eval, helpers.command, helpers.exc_exec
|
||||||
local ok = helpers.ok
|
local ok = helpers.ok
|
||||||
@@ -409,6 +410,12 @@ describe('In autoload/msgpack.vim', function()
|
|||||||
string_eq('nan', '(1.0/0.0-1.0/0.0)')
|
string_eq('nan', '(1.0/0.0-1.0/0.0)')
|
||||||
string_eq('nan', '-(1.0/0.0-1.0/0.0)')
|
string_eq('nan', '-(1.0/0.0-1.0/0.0)')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('works for special v: values like v:true', function()
|
||||||
|
string_eq('TRUE', 'v:true')
|
||||||
|
string_eq('FALSE', 'v:false')
|
||||||
|
string_eq('NIL', 'v:null')
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('function msgpack#deepcopy', function()
|
describe('function msgpack#deepcopy', function()
|
||||||
@@ -523,6 +530,20 @@ describe('In autoload/msgpack.vim', function()
|
|||||||
eq(2.0, nvim_eval('flt2'))
|
eq(2.0, nvim_eval('flt2'))
|
||||||
eq('abc', nvim_eval('bin2'))
|
eq('abc', nvim_eval('bin2'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('works for special v: values like v:true', function()
|
||||||
|
meths.set_var('true', true)
|
||||||
|
meths.set_var('false', false)
|
||||||
|
nvim_command('let nil = v:null')
|
||||||
|
|
||||||
|
nvim_command('let true2 = msgpack#deepcopy(true)')
|
||||||
|
nvim_command('let false2 = msgpack#deepcopy(false)')
|
||||||
|
nvim_command('let nil2 = msgpack#deepcopy(nil)')
|
||||||
|
|
||||||
|
eq(true, meths.get_var('true'))
|
||||||
|
eq(false, meths.get_var('false'))
|
||||||
|
eq(nil, meths.get_var('nil'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('function msgpack#eval', function()
|
describe('function msgpack#eval', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user