robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , setup =t . describe , t . it , t . setup 5local clear =n . clear 6local api =n . api 7local eq =t . eq 8local pcall_err =t . pcall_err 9local nvim_eval =n . eval 10local nvim_command =n . command 11local ok =t . ok 12local NIL =vim . NIL 13 14describe ( 'autoload/msgpack.vim' , function () 15setup ( function () 16clear { args ={ '-u' , 'NORC' } } 17end ) 18 19local sp =function ( typ , val ) 20return ( '{"_TYPE": v:msgpack_types.%s, "_VAL": %s}' ): format ( typ , val ) 21end 22local mapsp =function ( ... ) 23local val ='' 24for i =1 , ( select ( '#' , ... ) / 2 ) do 25val =( '%s[%s,%s],' ): format ( val , select ( i * 2 - 1 , ... ), select ( i * 2 , ... )) 26end 27return sp ( 'map' , '[' .. val .. ']' ) 28end 29 30local nan =- ( 1.0 / 0.0 - 1.0 / 0.0 ) 31local inf =1.0 / 0.0 32local minus_inf =- ( 1.0 / 0.0 ) 33 34describe ( 'function msgpack#equal' , function () 35local msgpack_eq =function ( expected , a , b ) 36eq ( expected , nvim_eval (( 'msgpack#equal(%s, %s)' ): format ( a , b ))) 37if a ~= b then 38eq ( expected , nvim_eval (( 'msgpack#equal(%s, %s)' ): format ( b , a ))) 39end 40end 41it ( 'compares raw integers correctly' , function () 42msgpack_eq ( 1 , '1' , '1' ) 43msgpack_eq ( 0 , '1' , '0' ) 44end ) 45it ( 'compares integer specials correctly' , function () 46msgpack_eq ( 1 , sp ( 'integer' , '[-1, 1, 0, 0]' ), sp ( 'integer' , '[-1, 1, 0, 0]' )) 47msgpack_eq ( 0 , sp ( 'integer' , '[-1, 1, 0, 0]' ), sp ( 'integer' , '[ 1, 1, 0, 0]' )) 48end ) 49it ( 'compares integer specials with raw integer correctly' , function () 50msgpack_eq ( 1 , sp ( 'integer' , '[-1, 0, 0, 1]' ), '-1' ) 51msgpack_eq ( 0 , sp ( 'integer' , '[-1, 0, 0, 1]' ), '1' ) 52msgpack_eq ( 0 , sp ( 'integer' , '[ 1, 0, 0, 1]' ), '-1' ) 53msgpack_eq ( 1 , sp ( 'integer' , '[ 1, 0, 0, 1]' ), '1' ) 54end ) 55it ( 'compares integer with float correctly' , function () 56msgpack_eq ( 0 , '0' , '0.0' ) 57end ) 58it ( 'compares raw binaries correctly' , function () 59msgpack_eq ( 1 , '"abc\\ndef"' , '"abc\\ndef"' ) 60msgpack_eq ( 0 , '"abc\\ndef"' , '"abc\\nghi"' ) 61end ) 62it ( 'compares string specials correctly' , function () 63msgpack_eq ( 1 , sp ( 'string' , '["abc\\n", "def"]' ), sp ( 'string' , '["abc\\n", "def"]' )) 64msgpack_eq ( 0 , sp ( 'string' , '["abc", "def"]' ), sp ( 'string' , '["abc\\n", "def"]' )) 65msgpack_eq ( 1 , sp ( 'string' , '["abc", "def"]' ), '"abc\\ndef"' ) 66msgpack_eq ( 1 , '"abc\\ndef"' , sp ( 'string' , '["abc", "def"]' )) 67end ) 68it ( 'compares ext specials correctly' , function () 69msgpack_eq ( 1 , sp ( 'ext' , '[1, ["", "ac"]]' ), sp ( 'ext' , '[1, ["", "ac"]]' )) 70msgpack_eq ( 0 , sp ( 'ext' , '[2, ["", "ac"]]' ), sp ( 'ext' , '[1, ["", "ac"]]' )) 71msgpack_eq ( 0 , sp ( 'ext' , '[1, ["", "ac"]]' ), sp ( 'ext' , '[1, ["", "abc"]]' )) 72end ) 73it ( 'compares raw maps correctly' , function () 74msgpack_eq ( 1 , '{"a": 1, "b": 2}' , '{"b": 2, "a": 1}' ) 75msgpack_eq ( 1 , '{}' , '{}' ) 76msgpack_eq ( 0 , '{}' , '{"a": 1}' ) 77msgpack_eq ( 0 , '{"a": 2}' , '{"a": 1}' ) 78msgpack_eq ( 0 , '{"a": 1}' , '{"b": 1}' ) 79msgpack_eq ( 0 , '{"a": 1}' , '{"a": 1, "b": 1}' ) 80msgpack_eq ( 0 , '{"a": 1, "b": 1}' , '{"b": 1}' ) 81end ) 82it ( 'compares map specials correctly' , function () 83msgpack_eq ( 1 , mapsp (), mapsp ()) 84msgpack_eq ( 851 , 86mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' )), 87mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' )) 88) 89msgpack_eq ( 0 , mapsp (), mapsp ( '1' , '1' )) 90msgpack_eq ( 910 , 92mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' )), 93mapsp ( sp ( 'string' , '[""]' ), mapsp ( '1' , '1' )) 94) 95msgpack_eq ( 960 , 97mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' )), 98mapsp ( mapsp ( '2' , '1' ), mapsp ( '1' , '1' )) 99) 100msgpack_eq ( 1010 , 102mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' )), 103mapsp ( mapsp ( '1' , '2' ), mapsp ( '1' , '1' )) 104) 105msgpack_eq ( 1060 , 107mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' )), 108mapsp ( mapsp ( '1' , '1' ), mapsp ( '2' , '1' )) 109) 110msgpack_eq ( 1110 , 112mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' )), 113mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '2' )) 114) 115msgpack_eq ( 1161 , 117mapsp ( mapsp ( '2' , '1' ), mapsp ( '1' , '1' ), mapsp ( '1' , '1' ), mapsp ( '1' , '1' )), 118mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' ), mapsp ( '2' , '1' ), mapsp ( '1' , '1' )) 119) 120end ) 121it ( 'compares map specials with raw maps correctly' , function () 122msgpack_eq ( 1 , mapsp (), '{}' ) 123msgpack_eq ( 1 , mapsp ( sp ( 'string' , '["1"]' ), '1' ), '{"1": 1}' ) 124msgpack_eq ( 1 , mapsp ( sp ( 'string' , '["1"]' ), sp ( 'integer' , '[1, 0, 0, 1]' )), '{"1": 1}' ) 125msgpack_eq ( 0 , mapsp ( sp ( 'integer' , '[1, 0, 0, 1]' ), sp ( 'string' , '["1"]' )), '{1: "1"}' ) 126msgpack_eq ( 1 , mapsp ( '"1"' , sp ( 'integer' , '[1, 0, 0, 1]' )), '{"1": 1}' ) 127msgpack_eq ( 0 , mapsp ( sp ( 'string' , '["1"]' ), '1' , sp ( 'string' , '["2"]' ), '2' ), '{"1": 1}' ) 128msgpack_eq ( 0 , mapsp ( sp ( 'string' , '["1"]' ), '1' ), '{"1": 1, "2": 2}' ) 129end ) 130it ( 'compares raw arrays correctly' , function () 131msgpack_eq ( 1 , '[]' , '[]' ) 132msgpack_eq ( 0 , '[]' , '[1]' ) 133msgpack_eq ( 1 , '[1]' , '[1]' ) 134msgpack_eq ( 1 , '[[[1]]]' , '[[[1]]]' ) 135msgpack_eq ( 0 , '[[[2]]]' , '[[[1]]]' ) 136end ) 137it ( 'compares array specials correctly' , function () 138msgpack_eq ( 1 , sp ( 'array' , '[]' ), sp ( 'array' , '[]' )) 139msgpack_eq ( 0 , sp ( 'array' , '[]' ), sp ( 'array' , '[1]' )) 140msgpack_eq ( 1 , sp ( 'array' , '[1]' ), sp ( 'array' , '[1]' )) 141msgpack_eq ( 1 , sp ( 'array' , '[[[1]]]' ), sp ( 'array' , '[[[1]]]' )) 142msgpack_eq ( 0 , sp ( 'array' , '[[[1]]]' ), sp ( 'array' , '[[[2]]]' )) 143end ) 144it ( 'compares array specials with raw arrays correctly' , function () 145msgpack_eq ( 1 , sp ( 'array' , '[]' ), '[]' ) 146msgpack_eq ( 0 , sp ( 'array' , '[]' ), '[1]' ) 147msgpack_eq ( 1 , sp ( 'array' , '[1]' ), '[1]' ) 148msgpack_eq ( 1 , sp ( 'array' , '[[[1]]]' ), '[[[1]]]' ) 149msgpack_eq ( 0 , sp ( 'array' , '[[[1]]]' ), '[[[2]]]' ) 150end ) 151it ( 'compares raw floats correctly' , function () 152msgpack_eq ( 1 , '0.0' , '0.0' ) 153msgpack_eq ( 1 , '(1.0/0.0-1.0/0.0)' , '(1.0/0.0-1.0/0.0)' ) 154-- both (1.0/0.0-1.0/0.0) and -(1.0/0.0-1.0/0.0) now return 155-- str2float('nan'). ref: @18d1ba3422d 156msgpack_eq ( 1 , '(1.0/0.0-1.0/0.0)' , '-(1.0/0.0-1.0/0.0)' ) 157msgpack_eq ( 1 , '-(1.0/0.0-1.0/0.0)' , '-(1.0/0.0-1.0/0.0)' ) 158msgpack_eq ( 1 , '1.0/0.0' , '1.0/0.0' ) 159msgpack_eq ( 1 , '-(1.0/0.0)' , '-(1.0/0.0)' ) 160msgpack_eq ( 1 , '0.0' , '0.0' ) 161msgpack_eq ( 0 , '0.0' , '1.0' ) 162msgpack_eq ( 0 , '0.0' , '(1.0/0.0-1.0/0.0)' ) 163msgpack_eq ( 0 , '0.0' , '1.0/0.0' ) 164msgpack_eq ( 0 , '0.0' , '-(1.0/0.0)' ) 165msgpack_eq ( 0 , '1.0/0.0' , '-(1.0/0.0)' ) 166msgpack_eq ( 0 , '(1.0/0.0-1.0/0.0)' , '-(1.0/0.0)' ) 167msgpack_eq ( 0 , '(1.0/0.0-1.0/0.0)' , '1.0/0.0' ) 168end ) 169it ( 'compares float specials with raw floats correctly' , function () 170msgpack_eq ( 1 , sp ( 'float' , '0.0' ), '0.0' ) 171msgpack_eq ( 1 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), '(1.0/0.0-1.0/0.0)' ) 172msgpack_eq ( 1 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), '-(1.0/0.0-1.0/0.0)' ) 173msgpack_eq ( 1 , sp ( 'float' , '-(1.0/0.0-1.0/0.0)' ), '(1.0/0.0-1.0/0.0)' ) 174msgpack_eq ( 1 , sp ( 'float' , '-(1.0/0.0-1.0/0.0)' ), '-(1.0/0.0-1.0/0.0)' ) 175msgpack_eq ( 1 , sp ( 'float' , '1.0/0.0' ), '1.0/0.0' ) 176msgpack_eq ( 1 , sp ( 'float' , '-(1.0/0.0)' ), '-(1.0/0.0)' ) 177msgpack_eq ( 1 , sp ( 'float' , '0.0' ), '0.0' ) 178msgpack_eq ( 0 , sp ( 'float' , '0.0' ), '1.0' ) 179msgpack_eq ( 0 , sp ( 'float' , '0.0' ), '(1.0/0.0-1.0/0.0)' ) 180msgpack_eq ( 0 , sp ( 'float' , '0.0' ), '1.0/0.0' ) 181msgpack_eq ( 0 , sp ( 'float' , '0.0' ), '-(1.0/0.0)' ) 182msgpack_eq ( 0 , sp ( 'float' , '1.0/0.0' ), '-(1.0/0.0)' ) 183msgpack_eq ( 0 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), '-(1.0/0.0)' ) 184msgpack_eq ( 0 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), '1.0/0.0' ) 185end ) 186it ( 'compares float specials correctly' , function () 187msgpack_eq ( 1 , sp ( 'float' , '0.0' ), sp ( 'float' , '0.0' )) 188msgpack_eq ( 1 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), sp ( 'float' , '(1.0/0.0-1.0/0.0)' )) 189msgpack_eq ( 1 , sp ( 'float' , '1.0/0.0' ), sp ( 'float' , '1.0/0.0' )) 190msgpack_eq ( 1 , sp ( 'float' , '-(1.0/0.0)' ), sp ( 'float' , '-(1.0/0.0)' )) 191msgpack_eq ( 1 , sp ( 'float' , '0.0' ), sp ( 'float' , '0.0' )) 192msgpack_eq ( 0 , sp ( 'float' , '0.0' ), sp ( 'float' , '1.0' )) 193msgpack_eq ( 0 , sp ( 'float' , '0.0' ), sp ( 'float' , '(1.0/0.0-1.0/0.0)' )) 194msgpack_eq ( 0 , sp ( 'float' , '0.0' ), sp ( 'float' , '1.0/0.0' )) 195msgpack_eq ( 0 , sp ( 'float' , '0.0' ), sp ( 'float' , '-(1.0/0.0)' )) 196msgpack_eq ( 0 , sp ( 'float' , '1.0/0.0' ), sp ( 'float' , '-(1.0/0.0)' )) 197msgpack_eq ( 0 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), sp ( 'float' , '-(1.0/0.0)' )) 198msgpack_eq ( 1 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), sp ( 'float' , '-(1.0/0.0-1.0/0.0)' )) 199msgpack_eq ( 1 , sp ( 'float' , '-(1.0/0.0-1.0/0.0)' ), sp ( 'float' , '-(1.0/0.0-1.0/0.0)' )) 200msgpack_eq ( 0 , sp ( 'float' , '(1.0/0.0-1.0/0.0)' ), sp ( 'float' , '1.0/0.0' )) 201end ) 202it ( 'compares boolean specials correctly' , function () 203msgpack_eq ( 1 , sp ( 'boolean' , '1' ), sp ( 'boolean' , '1' )) 204msgpack_eq ( 0 , sp ( 'boolean' , '1' ), sp ( 'boolean' , '0' )) 205end ) 206it ( 'compares nil specials correctly' , function () 207msgpack_eq ( 1 , sp ( 'nil' , '1' ), sp ( 'nil' , '0' )) 208end ) 209it ( 'compares nil, boolean and integer values with each other correctly' , function () 210msgpack_eq ( 0 , sp ( 'boolean' , '1' ), '1' ) 211msgpack_eq ( 0 , sp ( 'boolean' , '1' ), sp ( 'nil' , '0' )) 212msgpack_eq ( 0 , sp ( 'boolean' , '1' ), sp ( 'nil' , '1' )) 213msgpack_eq ( 0 , sp ( 'boolean' , '0' ), sp ( 'nil' , '0' )) 214msgpack_eq ( 0 , sp ( 'boolean' , '0' ), '0' ) 215msgpack_eq ( 0 , sp ( 'boolean' , '0' ), sp ( 'integer' , '[1, 0, 0, 0]' )) 216msgpack_eq ( 0 , sp ( 'boolean' , '0' ), sp ( 'integer' , '[1, 0, 0, 1]' )) 217msgpack_eq ( 0 , sp ( 'boolean' , '1' ), sp ( 'integer' , '[1, 0, 0, 1]' )) 218msgpack_eq ( 0 , sp ( 'nil' , '0' ), sp ( 'integer' , '[1, 0, 0, 0]' )) 219msgpack_eq ( 0 , sp ( 'nil' , '0' ), '0' ) 220end ) 221end ) 222 223describe ( 'function msgpack#is_int' , function () 224it ( 'works' , function () 225eq ( 1 , nvim_eval ( 'msgpack#is_int(1)' )) 226eq ( 1 , nvim_eval ( 'msgpack#is_int(-1)' )) 227eq ( 1 , nvim_eval (( 'msgpack#is_int(%s)' ): format ( sp ( 'integer' , '[1, 0, 0, 1]' )))) 228eq ( 1 , nvim_eval (( 'msgpack#is_int(%s)' ): format ( sp ( 'integer' , '[-1, 0, 0, 1]' )))) 229eq ( 0 , nvim_eval (( 'msgpack#is_int(%s)' ): format ( sp ( 'float' , '0.0' )))) 230eq ( 0 , nvim_eval (( 'msgpack#is_int(%s)' ): format ( sp ( 'boolean' , '0' )))) 231eq ( 0 , nvim_eval (( 'msgpack#is_int(%s)' ): format ( sp ( 'nil' , '0' )))) 232eq ( 0 , nvim_eval ( 'msgpack#is_int("")' )) 233end ) 234end ) 235 236describe ( 'function msgpack#is_uint' , function () 237it ( 'works' , function () 238eq ( 1 , nvim_eval ( 'msgpack#is_uint(1)' )) 239eq ( 0 , nvim_eval ( 'msgpack#is_uint(-1)' )) 240eq ( 1 , nvim_eval (( 'msgpack#is_uint(%s)' ): format ( sp ( 'integer' , '[1, 0, 0, 1]' )))) 241eq ( 0 , nvim_eval (( 'msgpack#is_uint(%s)' ): format ( sp ( 'integer' , '[-1, 0, 0, 1]' )))) 242eq ( 0 , nvim_eval (( 'msgpack#is_uint(%s)' ): format ( sp ( 'float' , '0.0' )))) 243eq ( 0 , nvim_eval (( 'msgpack#is_uint(%s)' ): format ( sp ( 'boolean' , '0' )))) 244eq ( 0 , nvim_eval (( 'msgpack#is_uint(%s)' ): format ( sp ( 'nil' , '0' )))) 245eq ( 0 , nvim_eval ( 'msgpack#is_uint("")' )) 246end ) 247end ) 248 249describe ( 'function msgpack#strftime' , function () 250it ( 'works' , function () 251local epoch =os . date ( '%Y-%m-%dT%H:%M:%S' , 0 ) 252eq ( epoch , nvim_eval ( 'msgpack#strftime("%Y-%m-%dT%H:%M:%S", 0)' )) 253eq ( 254epoch , 255nvim_eval ( 256( 'msgpack#strftime("%%Y-%%m-%%dT%%H:%%M:%%S", %s)' ): format ( sp ( 'integer' , '[1, 0, 0, 0]' )) 257) 258) 259end ) 260end ) 261 262describe ( 'function msgpack#strptime' , function () 263it ( 'works' , function () 264for _ , v in ipairs ( { 0 , 10 , 100000 , 204 , 1000000000 } ) do 265local time =os . date ( '%Y-%m-%dT%H:%M:%S' , v ) 266eq ( v , nvim_eval ( 'msgpack#strptime("%Y-%m-%dT%H:%M:%S", ' .. '"' .. time .. '")' )) 267end 268end ) 269end ) 270 271describe ( 'function msgpack#type' , function () 272local type_eq =function ( expected , val ) 273eq ( expected , nvim_eval (( 'msgpack#type(%s)' ): format ( val ))) 274end 275 276it ( 'works for special dictionaries' , function () 277type_eq ( 'string' , sp ( 'string' , '[""]' )) 278type_eq ( 'ext' , sp ( 'ext' , '[1, [""]]' )) 279type_eq ( 'array' , sp ( 'array' , '[]' )) 280type_eq ( 'map' , sp ( 'map' , '[]' )) 281type_eq ( 'integer' , sp ( 'integer' , '[1, 0, 0, 0]' )) 282type_eq ( 'float' , sp ( 'float' , '0.0' )) 283type_eq ( 'boolean' , sp ( 'boolean' , '0' )) 284type_eq ( 'nil' , sp ( 'nil' , '0' )) 285end ) 286 287it ( 'works for regular values' , function () 288type_eq ( 'string' , '""' ) 289type_eq ( 'array' , '[]' ) 290type_eq ( 'map' , '{}' ) 291type_eq ( 'integer' , '1' ) 292type_eq ( 'float' , '0.0' ) 293type_eq ( 'float' , '(1.0/0.0)' ) 294type_eq ( 'float' , '-(1.0/0.0)' ) 295type_eq ( 'float' , '(1.0/0.0-1.0/0.0)' ) 296end ) 297end ) 298 299describe ( 'function msgpack#special_type' , function () 300local sp_type_eq =function ( expected , val ) 301eq ( expected , nvim_eval (( 'msgpack#special_type(%s)' ): format ( val ))) 302end 303 304it ( 'works for special dictionaries' , function () 305sp_type_eq ( 'string' , sp ( 'string' , '[""]' )) 306sp_type_eq ( 'ext' , sp ( 'ext' , '[1, [""]]' )) 307sp_type_eq ( 'array' , sp ( 'array' , '[]' )) 308sp_type_eq ( 'map' , sp ( 'map' , '[]' )) 309sp_type_eq ( 'integer' , sp ( 'integer' , '[1, 0, 0, 0]' )) 310sp_type_eq ( 'float' , sp ( 'float' , '0.0' )) 311sp_type_eq ( 'boolean' , sp ( 'boolean' , '0' )) 312sp_type_eq ( 'nil' , sp ( 'nil' , '0' )) 313end ) 314 315it ( 'works for regular values' , function () 316sp_type_eq ( 0 , '""' ) 317sp_type_eq ( 0 , '[]' ) 318sp_type_eq ( 0 , '{}' ) 319sp_type_eq ( 0 , '1' ) 320sp_type_eq ( 0 , '0.0' ) 321sp_type_eq ( 0 , '(1.0/0.0)' ) 322sp_type_eq ( 0 , '-(1.0/0.0)' ) 323sp_type_eq ( 0 , '(1.0/0.0-1.0/0.0)' ) 324end ) 325end ) 326 327describe ( 'function msgpack#string' , function () 328local string_eq =function ( expected , val ) 329eq ( expected , nvim_eval (( 'msgpack#string(%s)' ): format ( val ))) 330end 331 332it ( 'works for special dictionaries' , function () 333string_eq ( '""' , sp ( 'string' , '[""]' )) 334string_eq ( '"\\n"' , sp ( 'string' , '["", ""]' )) 335string_eq ( '"ab\\0c\\nde"' , sp ( 'string' , '["ab\\nc", "de"]' )) 336string_eq ( '+(2)""' , sp ( 'ext' , '[2, [""]]' )) 337string_eq ( '+(2)"\\n"' , sp ( 'ext' , '[2, ["", ""]]' )) 338string_eq ( '+(2)"ab\\0c\\nde"' , sp ( 'ext' , '[2, ["ab\\nc", "de"]]' )) 339string_eq ( '[]' , sp ( 'array' , '[]' )) 340string_eq ( '[[[[{}]]]]' , sp ( 'array' , '[[[[{}]]]]' )) 341string_eq ( '{}' , sp ( 'map' , '[]' )) 342string_eq ( '{2: 10}' , sp ( 'map' , '[[2, 10]]' )) 343string_eq ( 344'{{1: 1}: {1: 1}, {2: 1}: {1: 1}}' , 345mapsp ( mapsp ( '2' , '1' ), mapsp ( '1' , '1' ), mapsp ( '1' , '1' ), mapsp ( '1' , '1' )) 346) 347string_eq ( 348'{{1: 1}: {1: 1}, {2: 1}: {1: 1}}' , 349mapsp ( mapsp ( '1' , '1' ), mapsp ( '1' , '1' ), mapsp ( '2' , '1' ), mapsp ( '1' , '1' )) 350) 351string_eq ( 352'{[1, 2, {{1: 2}: 1}]: [1, 2, {{1: 2}: 1}]}' , 353mapsp ( 354( '[1, 2, %s]' ): format ( mapsp ( mapsp ( '1' , '2' ), '1' )), 355( '[1, 2, %s]' ): format ( mapsp ( mapsp ( '1' , '2' ), '1' )) 356) 357) 358string_eq ( '0x0000000000000000' , sp ( 'integer' , '[1, 0, 0, 0]' )) 359string_eq ( '-0x0000000100000000' , sp ( 'integer' , '[-1, 0, 2, 0]' )) 360string_eq ( '0x123456789abcdef0' , sp ( 'integer' , '[ 1, 0, 610839793, 448585456]' )) 361string_eq ( '-0x123456789abcdef0' , sp ( 'integer' , '[-1, 0, 610839793, 448585456]' )) 362string_eq ( '0xf23456789abcdef0' , sp ( 'integer' , '[ 1, 3, 1684581617, 448585456]' )) 363string_eq ( '-0x723456789abcdef0' , sp ( 'integer' , '[-1, 1, 1684581617, 448585456]' )) 364string_eq ( '0.0' , sp ( 'float' , '0.0' )) 365string_eq ( 'inf' , sp ( 'float' , '(1.0/0.0)' )) 366string_eq ( '-inf' , sp ( 'float' , '-(1.0/0.0)' )) 367string_eq ( 'nan' , sp ( 'float' , '(1.0/0.0-1.0/0.0)' )) 368string_eq ( 'nan' , sp ( 'float' , '-(1.0/0.0-1.0/0.0)' )) 369string_eq ( 'FALSE' , sp ( 'boolean' , '0' )) 370string_eq ( 'TRUE' , sp ( 'boolean' , '1' )) 371string_eq ( 'NIL' , sp ( 'nil' , '0' )) 372end ) 373 374it ( 'works for regular values' , function () 375string_eq ( '""' , '""' ) 376string_eq ( '"\\n"' , '"\\n"' ) 377string_eq ( '[]' , '[]' ) 378string_eq ( '[[[{}]]]' , '[[[{}]]]' ) 379string_eq ( '{}' , '{}' ) 380string_eq ( '{"2": 10}' , '{2: 10}' ) 381string_eq ( '{"2": [{}]}' , '{2: [{}]}' ) 382string_eq ( '1' , '1' ) 383string_eq ( '0.0' , '0.0' ) 384string_eq ( 'inf' , '(1.0/0.0)' ) 385string_eq ( '-inf' , '-(1.0/0.0)' ) 386string_eq ( 'nan' , '(1.0/0.0-1.0/0.0)' ) 387string_eq ( 'nan' , '-(1.0/0.0-1.0/0.0)' ) 388end ) 389 390it ( 'works for special v: values like v:true' , function () 391string_eq ( 'TRUE' , 'v:true' ) 392string_eq ( 'FALSE' , 'v:false' ) 393string_eq ( 'NIL' , 'v:null' ) 394end ) 395end ) 396 397describe ( 'function msgpack#deepcopy' , function () 398it ( 'works for special dictionaries' , function () 399nvim_command ( 'let sparr = ' .. sp ( 'array' , '[[[]]]' )) 400nvim_command ( 'let spmap = ' .. mapsp ( '"abc"' , '[[]]' )) 401nvim_command ( 'let spint = ' .. sp ( 'integer' , '[1, 0, 0, 0]' )) 402nvim_command ( 'let spflt = ' .. sp ( 'float' , '1.0' )) 403nvim_command ( 'let spext = ' .. sp ( 'ext' , '[2, ["abc", "def"]]' )) 404nvim_command ( 'let spstr = ' .. sp ( 'string' , '["abc", "def"]' )) 405nvim_command ( 'let spbln = ' .. sp ( 'boolean' , '0' )) 406nvim_command ( 'let spnil = ' .. sp ( 'nil' , '0' )) 407 408nvim_command ( 'let sparr2 = msgpack#deepcopy(sparr)' ) 409nvim_command ( 'let spmap2 = msgpack#deepcopy(spmap)' ) 410nvim_command ( 'let spint2 = msgpack#deepcopy(spint)' ) 411nvim_command ( 'let spflt2 = msgpack#deepcopy(spflt)' ) 412nvim_command ( 'let spext2 = msgpack#deepcopy(spext)' ) 413nvim_command ( 'let spstr2 = msgpack#deepcopy(spstr)' ) 414nvim_command ( 'let spbln2 = msgpack#deepcopy(spbln)' ) 415nvim_command ( 'let spnil2 = msgpack#deepcopy(spnil)' ) 416 417eq ( 'array' , nvim_eval ( 'msgpack#type(sparr2)' )) 418eq ( 'map' , nvim_eval ( 'msgpack#type(spmap2)' )) 419eq ( 'integer' , nvim_eval ( 'msgpack#type(spint2)' )) 420eq ( 'float' , nvim_eval ( 'msgpack#type(spflt2)' )) 421eq ( 'ext' , nvim_eval ( 'msgpack#type(spext2)' )) 422eq ( 'string' , nvim_eval ( 'msgpack#type(spstr2)' )) 423eq ( 'boolean' , nvim_eval ( 'msgpack#type(spbln2)' )) 424eq ( 'nil' , nvim_eval ( 'msgpack#type(spnil2)' )) 425 426nvim_command ( 'call add(sparr._VAL, 0)' ) 427nvim_command ( 'call add(sparr._VAL[0], 0)' ) 428nvim_command ( 'call add(sparr._VAL[0][0], 0)' ) 429nvim_command ( 'call add(spmap._VAL, [0, 0])' ) 430nvim_command ( 'call add(spmap._VAL[0][1], 0)' ) 431nvim_command ( 'call add(spmap._VAL[0][1][0], 0)' ) 432nvim_command ( 'let spint._VAL[1] = 1' ) 433nvim_command ( 'let spflt._VAL = 0.0' ) 434nvim_command ( 'let spext._VAL[0] = 3' ) 435nvim_command ( 'let spext._VAL[1][0] = "gh"' ) 436nvim_command ( 'let spstr._VAL[0] = "gh"' ) 437nvim_command ( 'let spbln._VAL = 1' ) 438nvim_command ( 'let spnil._VAL = 1' ) 439 440eq ( { _TYPE ={} , _VAL ={ { {} } } } , nvim_eval ( 'sparr2' )) 441eq ( { _TYPE ={} , _VAL ={ { 'abc' , { {} } } } } , nvim_eval ( 'spmap2' )) 442eq ( { _TYPE ={} , _VAL ={ 1 , 0 , 0 , 0 } } , nvim_eval ( 'spint2' )) 443eq ( { _TYPE ={} , _VAL =1.0 } , nvim_eval ( 'spflt2' )) 444eq ( { _TYPE ={} , _VAL ={ 2 , { 'abc' , 'def' } } } , nvim_eval ( 'spext2' )) 445eq ( { _TYPE ={} , _VAL ={ 'abc' , 'def' } } , nvim_eval ( 'spstr2' )) 446eq ( { _TYPE ={} , _VAL =0 } , nvim_eval ( 'spbln2' )) 447eq ( { _TYPE ={} , _VAL =0 } , nvim_eval ( 'spnil2' )) 448 449nvim_command ( 'let sparr._TYPE = []' ) 450nvim_command ( 'let spmap._TYPE = []' ) 451nvim_command ( 'let spint._TYPE = []' ) 452nvim_command ( 'let spflt._TYPE = []' ) 453nvim_command ( 'let spext._TYPE = []' ) 454nvim_command ( 'let spstr._TYPE = []' ) 455nvim_command ( 'let spbln._TYPE = []' ) 456nvim_command ( 'let spnil._TYPE = []' ) 457 458eq ( 'array' , nvim_eval ( 'msgpack#special_type(sparr2)' )) 459eq ( 'map' , nvim_eval ( 'msgpack#special_type(spmap2)' )) 460eq ( 'integer' , nvim_eval ( 'msgpack#special_type(spint2)' )) 461eq ( 'float' , nvim_eval ( 'msgpack#special_type(spflt2)' )) 462eq ( 'ext' , nvim_eval ( 'msgpack#special_type(spext2)' )) 463eq ( 'string' , nvim_eval ( 'msgpack#special_type(spstr2)' )) 464eq ( 'boolean' , nvim_eval ( 'msgpack#special_type(spbln2)' )) 465eq ( 'nil' , nvim_eval ( 'msgpack#special_type(spnil2)' )) 466end ) 467 468it ( 'works for regular values' , function () 469nvim_command ( 'let arr = [[[]]]' ) 470nvim_command ( 'let map = {1: {}}' ) 471nvim_command ( 'let int = 1' ) 472nvim_command ( 'let flt = 2.0' ) 473nvim_command ( 'let bin = "abc"' ) 474 475nvim_command ( 'let arr2 = msgpack#deepcopy(arr)' ) 476nvim_command ( 'let map2 = msgpack#deepcopy(map)' ) 477nvim_command ( 'let int2 = msgpack#deepcopy(int)' ) 478nvim_command ( 'let flt2 = msgpack#deepcopy(flt)' ) 479nvim_command ( 'let bin2 = msgpack#deepcopy(bin)' ) 480 481eq ( 'array' , nvim_eval ( 'msgpack#type(arr2)' )) 482eq ( 'map' , nvim_eval ( 'msgpack#type(map2)' )) 483eq ( 'integer' , nvim_eval ( 'msgpack#type(int2)' )) 484eq ( 'float' , nvim_eval ( 'msgpack#type(flt2)' )) 485eq ( 'string' , nvim_eval ( 'msgpack#type(bin2)' )) 486 487nvim_command ( 'call add(arr, 0)' ) 488nvim_command ( 'call add(arr[0], 0)' ) 489nvim_command ( 'call add(arr[0][0], 0)' ) 490nvim_command ( 'let map.a = 1' ) 491nvim_command ( 'let map.1.a = 1' ) 492nvim_command ( 'let int = 2' ) 493nvim_command ( 'let flt = 3.0' ) 494nvim_command ( 'let bin = ""' ) 495 496eq ( { { {} } } , nvim_eval ( 'arr2' )) 497eq ( { [ '1' ] ={} } , nvim_eval ( 'map2' )) 498eq ( 1 , nvim_eval ( 'int2' )) 499eq ( 2.0 , nvim_eval ( 'flt2' )) 500eq ( 'abc' , nvim_eval ( 'bin2' )) 501end ) 502 503it ( 'works for special v: values like v:true' , function () 504api . nvim_set_var ( 'true' , true ) 505api . nvim_set_var ( 'false' , false ) 506api . nvim_set_var ( 'nil' , NIL ) 507 508nvim_command ( 'let true2 = msgpack#deepcopy(true)' ) 509nvim_command ( 'let false2 = msgpack#deepcopy(false)' ) 510nvim_command ( 'let nil2 = msgpack#deepcopy(nil)' ) 511 512eq ( true , api . nvim_get_var ( 'true' )) 513eq ( false , api . nvim_get_var ( 'false' )) 514eq ( NIL , api . nvim_get_var ( 'nil' )) 515end ) 516end ) 517 518describe ( 'function msgpack#eval' , function () 519local eval_eq =function ( expected_type , expected_val , str , ... ) 520nvim_command ( 521( "let g:__val = msgpack#eval('%s', %s)" ): format ( str : gsub ( "'" , "''" ), select ( 1 , ... ) or '{}' ) 522) 523eq ( expected_type , nvim_eval ( 'msgpack#type(g:__val)' )) 524local expected_val_full =expected_val 525if 526not (( { float =true , integer =true } )[ expected_type ] and type ( expected_val ) ~= 'table' ) 527and expected_type ~= 'array' 528then 529expected_val_full ={ _TYPE ={} , _VAL =expected_val_full } 530end 531if expected_val_full == expected_val_full then 532eq ( expected_val_full , nvim_eval ( 'g:__val' )) 533else -- NaN 534local nvim_nan =tostring ( nvim_eval ( 'g:__val' )) 535-- -NaN is a hardware-specific detail, there's no need to test for it. 536-- Accept ether 'nan' or '-nan' as the response. 537ok ( nvim_nan == 'nan' or nvim_nan == '-nan' ) 538end 539nvim_command ( 'unlet g:__val' ) 540end 541 542it ( 'correctly loads strings' , function () 543eval_eq ( 'string' , { 'abcdef' } , '="abcdef"' ) 544eval_eq ( 'string' , { 'abc' , 'def' } , '="abc\\ndef"' ) 545eval_eq ( 'string' , { 'abc\ndef' } , '="abc\\0def"' ) 546eval_eq ( 'string' , { '\nabc\ndef\n' } , '="\\0abc\\0def\\0"' ) 547eval_eq ( 'string' , { 'abc\n\n\ndef' } , '="abc\\0\\0\\0def"' ) 548eval_eq ( 'string' , { 'abc\n' , '\ndef' } , '="abc\\0\\n\\0def"' ) 549eval_eq ( 'string' , { 'abc' , '' , '' , 'def' } , '="abc\\n\\n\\ndef"' ) 550eval_eq ( 'string' , { 'abc' , '' , '' , 'def' , '' } , '="abc\\n\\n\\ndef\\n"' ) 551eval_eq ( 'string' , { '' , 'abc' , '' , '' , 'def' } , '="\\nabc\\n\\n\\ndef"' ) 552eval_eq ( 'string' , { '' } , '=""' ) 553eval_eq ( 'string' , { '"' } , '="\\""' ) 554eval_eq ( 'string' , { 'py3 print(sys.version_info)' } , '="py3 print(sys.version_info)"' ) 555end ) 556 557it ( 'correctly loads ext values' , function () 558eval_eq ( 'ext' , { 0 , { 'abcdef' } } , '+(0)"abcdef"' ) 559eval_eq ( 'ext' , { 0 , { 'abc' , 'def' } } , '+(0)"abc\\ndef"' ) 560eval_eq ( 'ext' , { 0 , { 'abc\ndef' } } , '+(0)"abc\\0def"' ) 561eval_eq ( 'ext' , { 0 , { '\nabc\ndef\n' } } , '+(0)"\\0abc\\0def\\0"' ) 562eval_eq ( 'ext' , { 0 , { 'abc\n\n\ndef' } } , '+(0)"abc\\0\\0\\0def"' ) 563eval_eq ( 'ext' , { 0 , { 'abc\n' , '\ndef' } } , '+(0)"abc\\0\\n\\0def"' ) 564eval_eq ( 'ext' , { 0 , { 'abc' , '' , '' , 'def' } } , '+(0)"abc\\n\\n\\ndef"' ) 565eval_eq ( 'ext' , { 0 , { 'abc' , '' , '' , 'def' , '' } } , '+(0)"abc\\n\\n\\ndef\\n"' ) 566eval_eq ( 'ext' , { 0 , { '' , 'abc' , '' , '' , 'def' } } , '+(0)"\\nabc\\n\\n\\ndef"' ) 567eval_eq ( 'ext' , { 0 , { '' } } , '+(0)""' ) 568eval_eq ( 'ext' , { 0 , { '"' } } , '+(0)"\\""' ) 569 570eval_eq ( 'ext' , { - 1 , { 'abcdef' } } , '+(-1)"abcdef"' ) 571eval_eq ( 'ext' , { - 1 , { 'abc' , 'def' } } , '+(-1)"abc\\ndef"' ) 572eval_eq ( 'ext' , { - 1 , { 'abc\ndef' } } , '+(-1)"abc\\0def"' ) 573eval_eq ( 'ext' , { - 1 , { '\nabc\ndef\n' } } , '+(-1)"\\0abc\\0def\\0"' ) 574eval_eq ( 'ext' , { - 1 , { 'abc\n\n\ndef' } } , '+(-1)"abc\\0\\0\\0def"' ) 575eval_eq ( 'ext' , { - 1 , { 'abc\n' , '\ndef' } } , '+(-1)"abc\\0\\n\\0def"' ) 576eval_eq ( 'ext' , { - 1 , { 'abc' , '' , '' , 'def' } } , '+(-1)"abc\\n\\n\\ndef"' ) 577eval_eq ( 'ext' , { - 1 , { 'abc' , '' , '' , 'def' , '' } } , '+(-1)"abc\\n\\n\\ndef\\n"' ) 578eval_eq ( 'ext' , { - 1 , { '' , 'abc' , '' , '' , 'def' } } , '+(-1)"\\nabc\\n\\n\\ndef"' ) 579eval_eq ( 'ext' , { - 1 , { '' } } , '+(-1)""' ) 580eval_eq ( 'ext' , { - 1 , { '"' } } , '+(-1)"\\""' ) 581 582eval_eq ( 583'ext' , 584{ 42 , { 'py3 print(sys.version_info)' } } , 585'+(42)"py3 print(sys.version_info)"' 586) 587end ) 588 589it ( 'correctly loads floats' , function () 590eval_eq ( 'float' , inf , 'inf' ) 591eval_eq ( 'float' , minus_inf , '-inf' ) 592eval_eq ( 'float' , nan , 'nan' ) 593eval_eq ( 'float' , 1.0e10 , '1.0e10' ) 594eval_eq ( 'float' , 1.0e10 , '1.0e+10' ) 595eval_eq ( 'float' , - 1.0e10 , '-1.0e+10' ) 596eval_eq ( 'float' , 1.0 , '1.0' ) 597eval_eq ( 'float' , - 1.0 , '-1.0' ) 598eval_eq ( 'float' , 1.0e-10 , '1.0e-10' ) 599eval_eq ( 'float' , - 1.0e-10 , '-1.0e-10' ) 600end ) 601 602it ( 'correctly loads integers' , function () 603eval_eq ( 'integer' , 10 , '10' ) 604eval_eq ( 'integer' , - 10 , '-10' ) 605eval_eq ( 'integer' , { 1 , 0 , 610839793 , 448585456 } , ' 0x123456789ABCDEF0' ) 606eval_eq ( 'integer' , { - 1 , 0 , 610839793 , 448585456 } , '-0x123456789ABCDEF0' ) 607eval_eq ( 'integer' , { 1 , 3 , 1684581617 , 448585456 } , ' 0xF23456789ABCDEF0' ) 608eval_eq ( 'integer' , { - 1 , 1 , 1684581617 , 448585456 } , '-0x723456789ABCDEF0' ) 609eval_eq ( 'integer' , { 1 , 0 , 0 , 0x100 } , '0x100' ) 610eval_eq ( 'integer' , { - 1 , 0 , 0 , 0x100 } , '-0x100' ) 611 612eval_eq ( 'integer' , ( 'a' ): byte (), "'a'" ) 613eval_eq ( 'integer' , 0xAB , "'«'" ) 614eval_eq ( 'integer' , 0 , "'\\0'" ) 615eval_eq ( 'integer' , 10246567 , "'\\10246567'" ) 616end ) 617 618it ( 'correctly loads constants' , function () 619eval_eq ( 'boolean' , 1 , 'TRUE' ) 620eval_eq ( 'boolean' , 0 , 'FALSE' ) 621eval_eq ( 'nil' , 0 , 'NIL' ) 622eval_eq ( 'nil' , 0 , 'NIL' , '{"NIL": 1, "nan": 2, "T": 3}' ) 623eval_eq ( 'float' , nan , 'nan' , '{"NIL": "1", "nan": "2", "T": "3"}' ) 624eval_eq ( 'integer' , 3 , 'T' , '{"NIL": "1", "nan": "2", "T": "3"}' ) 625eval_eq ( 626'integer' , 627{ 1 , 0 , 0 , 0 } , 628'T' , 629( '{"NIL": "1", "nan": "2", "T": \'%s\'}' ): format ( sp ( 'integer' , '[1, 0, 0, 0]' )) 630) 631end ) 632 633it ( 'correctly loads maps' , function () 634eval_eq ( 'map' , {} , '{}' ) 635eval_eq ( 636'map' , 637{ { { _TYPE ={} , _VAL ={ { 1 , 2 } } } , { _TYPE ={} , _VAL ={ { 3 , 4 } } } } } , 638'{{1: 2}: {3: 4}}' 639) 640eval_eq ( 641'map' , 642{ { { _TYPE ={} , _VAL ={ { 1 , 2 } } } , { _TYPE ={} , _VAL ={ { 3 , 4 } } } } , { 1 , 2 } } , 643'{{1: 2}: {3: 4}, 1: 2}' 644) 645 646eval_eq ( 'map' , { 647{ 648{ 649_TYPE ={} , 650_VAL ={ 651{ { _TYPE ={} , _VAL ={ 'py3 print(sys.version_info)' } } , 2 } , 652} , 653} , 654{ _TYPE ={} , _VAL ={ { 3 , 4 } } } , 655} , 656{ 1 , 2 } , 657} , '{{"py3 print(sys.version_info)": 2}: {3: 4}, 1: 2}' ) 658end ) 659 660it ( 'correctly loads arrays' , function () 661eval_eq ( 'array' , {} , '[]' ) 662eval_eq ( 'array' , { 1 } , '[1]' ) 663eval_eq ( 'array' , { { _TYPE ={} , _VAL =1 } } , '[TRUE]' ) 664eval_eq ( 665'array' , 666{ { { _TYPE ={} , _VAL ={ { 1 , 2 } } } } , { _TYPE ={} , _VAL ={ { 3 , 4 } } } } , 667'[[{1: 2}], {3: 4}]' 668) 669 670eval_eq ( 671'array' , 672{ { _TYPE ={} , _VAL ={ 'py3 print(sys.version_info)' } } } , 673'["py3 print(sys.version_info)"]' 674) 675end ) 676 677it ( 'errors out when needed' , function () 678t . matches ( 679'empty:Parsed string is empty' , 680pcall_err ( nvim_command , 'call msgpack#eval("", {})' ) 681) 682t . matches ( 683'unknown:Invalid non%-space character: %^' , 684pcall_err ( nvim_command , 'call msgpack#eval("^", {})' ) 685) 686t . matches ( 687"char%-invalid:Invalid integer character literal format: ''" , 688pcall_err ( nvim_command , 'call msgpack#eval("\'\'", {})' ) 689) 690t . matches ( 691"char%-invalid:Invalid integer character literal format: 'ab'" , 692pcall_err ( nvim_command , 'call msgpack#eval("\'ab\'", {})' ) 693) 694t . matches ( 695"char%-invalid:Invalid integer character literal format: '" , 696pcall_err ( nvim_command , 'call msgpack#eval("\'", {})' ) 697) 698t . matches ( 699'"%-invalid:Invalid string: "' , 700pcall_err ( nvim_command , 'call msgpack#eval("\\"", {})' ) 701) 702t . matches ( 703'"%-invalid:Invalid string: ="' , 704pcall_err ( nvim_command , 'call msgpack#eval("=\\"", {})' ) 705) 706t . matches ( 707'"%-invalid:Invalid string: %+%(0%)"' , 708pcall_err ( nvim_command , 'call msgpack#eval("+(0)\\"", {})' ) 709) 710t . matches ( 711'0%.%-nodigits:Decimal dot must be followed by digit%(s%): %.e1' , 712pcall_err ( nvim_command , 'call msgpack#eval("0.e1", {})' ) 713) 714t . matches ( 715'0x%-long:Must have at most 16 hex digits: FEDCBA98765432100' , 716pcall_err ( nvim_command , 'call msgpack#eval("0xFEDCBA98765432100", {})' ) 717) 718t . matches ( 719'0x%-empty:Must have number after 0x: ' , 720pcall_err ( nvim_command , 'call msgpack#eval("0x", {})' ) 721) 722t . matches ( 723'name%-unknown:Unknown name FOO: FOO' , 724pcall_err ( nvim_command , 'call msgpack#eval("FOO", {})' ) 725) 726 727t . matches ( 728'name%-unknown:Unknown name py3: py3 print%(sys%.version_info%)' , 729pcall_err ( nvim_command , 'call msgpack#eval("py3 print(sys.version_info)", {})' ) 730) 731t . matches ( 732'name%-unknown:Unknown name o: o' , 733pcall_err ( nvim_command , 'call msgpack#eval("-info", {})' ) 734) 735end ) 736end ) 737end ) 738 739describe ( 'autoload/msgpack.vim in an eastern timezone' , function () 740setup ( function () 741clear ( { 742-- msgpack#strptime() prefers a Python implementation and only falls back to the 743-- Vimscript one, which is the one under test, when no provider answers. 744args ={ '-u' , 'NORC' , '--cmd' , 'let g:loaded_python3_provider = 0' } , 745-- POSIX TZ signs are inverted: GMT-14 is UTC+14, the easternmost offset. 746env ={ TZ ='GMT-14' } , 747} ) 748end ) 749 750describe ( 'function msgpack#strptime' , function () 751it ( 'works east of UTC+12 #7625' , function () 752eq ( 0 , nvim_eval ( 'has("python3")' )) 753for _ , v in ipairs ( { 0 , 10 , 100000 , 204 , 1000000000 } ) do 754local time =nvim_eval (( 'strftime("%%Y-%%m-%%dT%%H:%%M:%%S", %d)' ): format ( v )) 755eq ( v , nvim_eval (( 'msgpack#strptime("%%Y-%%m-%%dT%%H:%%M:%%S", "%s")' ): format ( time ))) 756end 757end ) 758end ) 759end )