robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4local t_shada =require ( 'test.functional.shada.testutil' ) 5 6local describe , it , before_each , setup , teardown , finally = 7t . describe , t . it , t . before_each , t . setup , t . teardown , t . finally 8local clear =n . clear 9local eq , api , nvim_eval , nvim_command , fn , nvim_feed =t . eq , n . api , n . eval , n . command , n . fn , n . feed 10local neq =t . neq 11local pcall_err =t . pcall_err 12local read_file =t . read_file 13 14local get_shada_rw =t_shada . get_shada_rw 15 16local function reset ( shada_file ) 17clear { args ={ '-u' , 'NORC' , '-i' , shada_file or 'NONE' } } 18end 19 20local mpack_eq =function ( expected , mpack_result ) 21local mpack_keys ={ 'type' , 'timestamp' , 'length' , 'value' } 22 23local unpack =vim . mpack . Unpacker () 24local actual ={} 25local cur , val 26local i =0 27local off =1 28while off <= # mpack_result do 29val , off =unpack ( mpack_result , off ) 30if i % 4 == 0 then 31cur ={} 32actual [ # actual + 1 ] =cur 33end 34local key =mpack_keys [( i % 4 ) + 1 ] 35if key ~= 'length' then 36if key == 'timestamp' and math . abs ( val - os . time ()) < 2 then 37val ='current' 38end 39cur [ key ] =val 40end 41i =i + 1 42end 43eq ( expected , actual ) 44end 45 46local wshada , _ , fname =get_shada_rw ( 'Xtest-functional-plugin-shada.shada' ) 47 48local wshada_tmp , _ , fname_tmp =get_shada_rw ( 'Xtest-functional-plugin-shada.shada.tmp.f' ) 49 50describe ( 'autoload/shada.vim' , function () 51local epoch =os . date ( '%Y-%m-%dT%H:%M:%S' , 0 ) 52setup ( function () 53reset () 54nvim_command ( [[ 55function ModifyVal(val) 56if type(a:val) == type([]) 57if len(a:val) == 2 && type(a:val[0]) == type('') && a:val[0][0] is# '!' && has_key(v:msgpack_types, a:val[0][1:]) 58return {'_TYPE': v:msgpack_types[ a:val[0][1:] ], '_VAL': a:val[1]} 59else 60return map(copy(a:val), 'ModifyVal(v:val)') 61endif 62elseif type(a:val) == type({}) 63let keys = sort(keys(a:val)) 64let ret = {'_TYPE': v:msgpack_types.map, '_VAL': []} 65for key in keys 66let k = {'_TYPE': v:msgpack_types.string, '_VAL': split(key, "\n", 1)} 67let v = ModifyVal(a:val[key]) 68call add(ret._VAL, [k, v]) 69unlet v 70endfor 71return ret 72elseif type(a:val) == type('') 73return {'_TYPE': v:msgpack_types.string, '_VAL': split(a:val, "\n", 1)} 74else 75return a:val 76endif 77endfunction 78]] ) 79end ) 80 81local sp =function ( typ , val ) 82return ( '{"_TYPE": v:msgpack_types.%s, "_VAL": %s}' ): format ( typ , val ) 83end 84 85describe ( 'function shada#mpack_to_sd' , function () 86local mpack2sd =function ( arg ) 87return ( 'shada#mpack_to_sd(%s)' ): format ( arg ) 88end 89 90it ( 'works' , function () 91eq ( {} , nvim_eval ( mpack2sd ( '[]' ))) 92eq ( { { type =1 , timestamp =5 , length =1 , data =7 } } , nvim_eval ( mpack2sd ( '[1, 5, 1, 7]' ))) 93eq ( { 94{ type =1 , timestamp =5 , length =1 , data =7 } , 95{ type =1 , timestamp =10 , length =1 , data =5 } , 96} , nvim_eval ( mpack2sd ( '[1, 5, 1, 7, 1, 10, 1, 5]' ))) 97t . matches ( 98'zero%-uint:Entry 1 has type element which is zero' , 99pcall_err ( nvim_command , 'call ' .. mpack2sd ( '[0, 5, 1, 7]' )) 100) 101t . matches ( 102'zero%-uint:Entry 1 has type element which is zero' , 103pcall_err ( 104nvim_command , 105'call ' .. mpack2sd (( '[%s, 5, 1, 7]' ): format ( sp ( 'integer' , '[1, 0, 0, 0]' ))) 106) 107) 108t . matches ( 109'not%-uint:Entry 1 has timestamp element which is not an unsigned integer' , 110pcall_err ( nvim_command , 'call ' .. mpack2sd ( '[1, -1, 1, 7]' )) 111) 112t . matches ( 113'not%-uint:Entry 1 has length element which is not an unsigned integer' , 114pcall_err ( nvim_command , 'call ' .. mpack2sd ( '[1, 1, -1, 7]' )) 115) 116t . matches ( 117'not%-uint:Entry 1 has type element which is not an unsigned integer' , 118pcall_err ( nvim_command , 'call ' .. mpack2sd ( '["", 1, -1, 7]' )) 119) 120end ) 121end ) 122 123describe ( 'function shada#sd_to_strings' , function () 124local sd2strings_eq =function ( expected , arg ) 125if type ( arg ) == 'table' then 126eq ( expected , fn [ 'shada#sd_to_strings' ]( arg )) 127else 128eq ( expected , nvim_eval (( 'shada#sd_to_strings(%s)' ): format ( arg ))) 129end 130end 131 132it ( 'works with empty input' , function () 133sd2strings_eq ( {} , '[]' ) 134end ) 135 136it ( 'works with unknown items' , function () 137sd2strings_eq ( { 138'Unknown (0x64) with timestamp ' .. epoch .. ':' , 139' = 100' , 140} , { { type =100 , timestamp =0 , length =1 , data =100 } } ) 141 142sd2strings_eq ( 143{ 144'Unknown (0x4000001180000006) with timestamp ' .. epoch .. ':' , 145' = 100' , 146} , 147( '[{"type": %s, "timestamp": 0, "length": 1, "data": 100}]' ): format ( 148sp ( 'integer' , '[1, 1, 35, 6]' ) 149) 150) 151end ) 152 153it ( 'works with multiple unknown items' , function () 154sd2strings_eq ( { 155'Unknown (0x64) with timestamp ' .. epoch .. ':' , 156' = 100' , 157'Unknown (0x65) with timestamp ' .. epoch .. ':' , 158' = 500' , 159} , { 160{ type =100 , timestamp =0 , length =1 , data =100 } , 161{ type =101 , timestamp =0 , length =1 , data =500 } , 162} ) 163end ) 164 165it ( 'works with header items' , function () 166sd2strings_eq ( { 167'Header with timestamp ' .. epoch .. ':' , 168' % Key______ Value' , 169' + generator "test"' , 170} , { { type =1 , timestamp =0 , data ={ generator ='test' } } } ) 171sd2strings_eq ( { 172'Header with timestamp ' .. epoch .. ':' , 173' % Key Description Value' , 174' + a 1' , 175' + b 2' , 176' + c column 3' , 177' + d 4' , 178} , { { type =1 , timestamp =0 , data ={ a =1 , b =2 , c =3 , d =4 } } } ) 179sd2strings_eq ( { 180'Header with timestamp ' .. epoch .. ':' , 181' % Key Value' , 182' + t "test"' , 183} , { { type =1 , timestamp =0 , data ={ t ='test' } } } ) 184sd2strings_eq ( { 185'Header with timestamp ' .. epoch .. ':' , 186' # Unexpected type: array instead of map' , 187' = [1, 2, 3]' , 188} , { { type =1 , timestamp =0 , data ={ 1 , 2 , 3 } } } ) 189end ) 190 191it ( 'processes standard keys correctly, even in header' , function () 192sd2strings_eq ( 193{ 194'Header with timestamp ' .. epoch .. ':' , 195' % Key Description________ Value' , 196' + c column 0' , 197' + f file name "/tmp/foo"' , 198' + l line number 10' , 199" + n name '@'" , 200' + rc contents ["abc", "def"]' , 201' + rt type CHARACTERWISE' , 202' + ru is_unnamed FALSE' , 203' + rw block width 10' , 204' + sb search backward TRUE' , 205' + sc smartcase value FALSE' , 206' + se place cursor at end TRUE' , 207' + sh v:hlsearch value TRUE' , 208' + sl has line offset FALSE' , 209' + sm magic value TRUE' , 210' + so offset value 10' , 211' + sp pattern "100"' , 212' + ss is :s pattern TRUE' , 213' + su is last used FALSE' , 214} , 215( [[ [{'type': 1, 'timestamp': 0, 'data': { 216'sm': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 217'sc': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 218'sl': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 219'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 220'sb': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 221'so': 10, 222'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 223'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 224'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 225'sp': '100', 226'rt': 0, 227'rw': 10, 228'rc': ['abc', 'def'], 229'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 230'n': 0x40, 231'l': 10, 232'c': 0, 233'f': '/tmp/foo', 234}}] ]] ): gsub ( '\n' , '' ) 235) 236sd2strings_eq ( 237{ 238'Header with timestamp ' .. epoch .. ':' , 239' % Key Description____ Value' , 240' # Expected integer' , 241' + c column "abc"' , 242' # Expected no NUL bytes' , 243' + f file name "abc\\0def"' , 244' # Value is negative' , 245' + l line number -10' , 246' # Value is negative' , 247' + n name -64' , 248' # Expected array value' , 249' + rc contents "10"' , 250' # Unexpected enum value: expected one of ' 251.. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)' , 252' + rt type 10' , 253' # Expected boolean' , 254' + ru is_unnamed 10' , 255' # Expected boolean' , 256' + sc smartcase value NIL' , 257' # Expected boolean' , 258' + sm magic value "TRUE"' , 259' # Expected integer' , 260' + so offset value "TRUE"' , 261' + sp pattern "abc"' , 262} , 263( [[ [{'type': 1, 'timestamp': 0, 'data': { 264'sm': 'TRUE', 265'sc': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, 266'so': 'TRUE', 267'sp': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc"]}, 268'rt': 10, 269'rc': '10', 270'ru': 10, 271'n': -0x40, 272'l': -10, 273'c': 'abc', 274'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]}, 275}}] ]] ): gsub ( '\n' , '' ) 276) 277sd2strings_eq ( 278{ 279'Header with timestamp ' .. epoch .. ':' , 280' % Key Description Value' , 281' # Expected no NUL bytes' , 282' + f file name "abc\\0def"' , 283' + rc contents ["abc", "abc"]' , 284' # Expected integer' , 285' + rt type "ABC"' , 286} , 287( [[ [{'type': 1, 'timestamp': 0, 'data': { 288'rt': 'ABC', 289'rc': ["abc", {'_TYPE': v:msgpack_types.string, '_VAL': ["abc"]}], 290'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]}, 291}}] ]] ): gsub ( '\n' , '' ) 292) 293sd2strings_eq ( 294{ 295'Header with timestamp ' .. epoch .. ':' , 296' % Key Description Value' , 297' # Expected no NUL bytes' , 298' + rc contents ["abc", "a\\nd\\0"]' , 299} , 300( [[ [{'type': 1, 'timestamp': 0, 'data': { 301'rc': ["abc", {'_TYPE': v:msgpack_types.string, '_VAL': ["a", "d\n"]}], 302}}] ]] ): gsub ( '\n' , '' ) 303) 304end ) 305 306it ( 'works with search pattern items' , function () 307sd2strings_eq ( { 308'Search pattern with timestamp ' .. epoch .. ':' , 309' # Unexpected type: array instead of map' , 310' = [1, 2, 3]' , 311} , { { type =2 , timestamp =0 , data ={ 1 , 2 , 3 } } } ) 312sd2strings_eq ( 313{ 314'Search pattern with timestamp ' .. epoch .. ':' , 315' % Key Description________ Value' , 316' + sp pattern "abc"' , 317' + sh v:hlsearch value FALSE' , 318' + ss is :s pattern FALSE' , 319' + sb search backward FALSE' , 320' + sm magic value TRUE' , 321' + sc smartcase value FALSE' , 322' + sl has line offset FALSE' , 323' + se place cursor at end FALSE' , 324' + so offset value 0' , 325' + su is last used TRUE' , 326} , 327( [[ [{'type': 2, 'timestamp': 0, 'data': { 328'sp': 'abc', 329}}] ]] ): gsub ( '\n' , '' ) 330) 331sd2strings_eq ( 332{ 333'Search pattern with timestamp ' .. epoch .. ':' , 334' % Key Description________ Value' , 335' + sp pattern "abc"' , 336' + sh v:hlsearch value FALSE' , 337' + ss is :s pattern FALSE' , 338' + sb search backward FALSE' , 339' + sm magic value TRUE' , 340' + sc smartcase value FALSE' , 341' + sl has line offset FALSE' , 342' + se place cursor at end FALSE' , 343' + so offset value 0' , 344' + su is last used TRUE' , 345' + sX NIL' , 346' + sY NIL' , 347' + sZ NIL' , 348} , 349( [[ [{'type': 2, 'timestamp': 0, 'data': { 350'sp': 'abc', 351'sZ': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, 352'sY': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, 353'sX': {'_TYPE': v:msgpack_types.nil, '_VAL': 0}, 354}}] ]] ): gsub ( '\n' , '' ) 355) 356sd2strings_eq ( 357{ 358'Search pattern with timestamp ' .. epoch .. ':' , 359' % Key Description________ Value' , 360' + sp pattern "abc"' , 361' + sh v:hlsearch value FALSE' , 362' + ss is :s pattern FALSE' , 363' + sb search backward FALSE' , 364' + sm magic value TRUE' , 365' + sc smartcase value FALSE' , 366' + sl has line offset FALSE' , 367' + se place cursor at end FALSE' , 368' + so offset value 0' , 369' + su is last used TRUE' , 370} , 371( [[ [{'type': 2, 'timestamp': 0, 'data': { 372'sp': 'abc', 373'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 374'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 375'sb': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 376'sm': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 377'sc': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 378'sl': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 379'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 380'so': 0, 381'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 382}}] ]] ): gsub ( '\n' , '' ) 383) 384sd2strings_eq ( 385{ 386'Search pattern with timestamp ' .. epoch .. ':' , 387' % Key Description________ Value' , 388' # Required key missing: sp' , 389' + sh v:hlsearch value FALSE' , 390' + ss is :s pattern FALSE' , 391' + sb search backward FALSE' , 392' + sm magic value TRUE' , 393' + sc smartcase value FALSE' , 394' + sl has line offset FALSE' , 395' + se place cursor at end FALSE' , 396' + so offset value 0' , 397' + su is last used TRUE' , 398} , 399( [[ [{'type': 2, 'timestamp': 0, 'data': { 400}}] ]] ): gsub ( '\n' , '' ) 401) 402sd2strings_eq ( 403{ 404'Search pattern with timestamp ' .. epoch .. ':' , 405' % Key Description________ Value' , 406' + sp pattern ""' , 407' + sh v:hlsearch value TRUE' , 408' + ss is :s pattern TRUE' , 409' + sb search backward TRUE' , 410' + sm magic value FALSE' , 411' + sc smartcase value TRUE' , 412' + sl has line offset TRUE' , 413' + se place cursor at end TRUE' , 414' + so offset value -10' , 415' + su is last used FALSE' , 416} , 417( [[ [{'type': 2, 'timestamp': 0, 'data': { 418'sp': '', 419'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 420'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 421'sb': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 422'sm': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 423'sc': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 424'sl': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 425'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 426'so': -10, 427'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 428}}] ]] ): gsub ( '\n' , '' ) 429) 430sd2strings_eq ( 431{ 432'Search pattern with timestamp ' .. epoch .. ':' , 433' % Key Description________ Value' , 434' # Expected binary string' , 435' + sp pattern 0' , 436' # Expected boolean' , 437' + sh v:hlsearch value 0' , 438' # Expected boolean' , 439' + ss is :s pattern 0' , 440' # Expected boolean' , 441' + sb search backward 0' , 442' # Expected boolean' , 443' + sm magic value 0' , 444' # Expected boolean' , 445' + sc smartcase value 0' , 446' # Expected boolean' , 447' + sl has line offset 0' , 448' # Expected boolean' , 449' + se place cursor at end 0' , 450' # Expected integer' , 451' + so offset value ""' , 452' # Expected boolean' , 453' + su is last used 0' , 454} , 455( [[ [{'type': 2, 'timestamp': 0, 'data': { 456'sp': 0, 457'sh': 0, 458'ss': 0, 459'sb': 0, 460'sm': 0, 461'sc': 0, 462'sl': 0, 463'se': 0, 464'so': '', 465'su': 0, 466}}] ]] ): gsub ( '\n' , '' ) 467) 468end ) 469 470it ( 'works with replacement string items' , function () 471sd2strings_eq ( { 472'Replacement string with timestamp ' .. epoch .. ':' , 473' # Unexpected type: map instead of array' , 474' = {"a": [10]}' , 475} , { { type =3 , timestamp =0 , data ={ a ={ 10 } } } } ) 476sd2strings_eq ( 477{ 478'Replacement string with timestamp ' .. epoch .. ':' , 479' @ Description__________ Value' , 480' # Expected more elements in list' , 481} , 482( [[ [{'type': 3, 'timestamp': 0, 'data': [ 483]}] ]] ): gsub ( '\n' , '' ) 484) 485sd2strings_eq ( 486{ 487'Replacement string with timestamp ' .. epoch .. ':' , 488' @ Description__________ Value' , 489' # Expected binary string' , 490' - :s replacement string 0' , 491} , 492( [[ [{'type': 3, 'timestamp': 0, 'data': [ 4930, 494]}] ]] ): gsub ( '\n' , '' ) 495) 496sd2strings_eq ( 497{ 498'Replacement string with timestamp ' .. epoch .. ':' , 499' @ Description__________ Value' , 500' # Expected no NUL bytes' , 501' - :s replacement string "abc\\0def"' , 502} , 503( [[ [{'type': 3, 'timestamp': 0, 'data': [ 504{'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]}, 505]}] ]] ): gsub ( '\n' , '' ) 506) 507sd2strings_eq ( 508{ 509'Replacement string with timestamp ' .. epoch .. ':' , 510' @ Description__________ Value' , 511' - :s replacement string "abc\\ndef"' , 512} , 513( [[ [{'type': 3, 'timestamp': 0, 'data': [ 514{'_TYPE': v:msgpack_types.string, '_VAL': ["abc", "def"]}, 515]}] ]] ): gsub ( '\n' , '' ) 516) 517sd2strings_eq ( 518{ 519'Replacement string with timestamp ' .. epoch .. ':' , 520' @ Description__________ Value' , 521' - :s replacement string "abc\\ndef"' , 522' - 0' , 523} , 524( [[ [{'type': 3, 'timestamp': 0, 'data': [ 525{'_TYPE': v:msgpack_types.string, '_VAL': ["abc", "def"]}, 5260, 527]}] ]] ): gsub ( '\n' , '' ) 528) 529end ) 530 531it ( 'works with history entry items' , function () 532sd2strings_eq ( { 533'History entry with timestamp ' .. epoch .. ':' , 534' # Unexpected type: map instead of array' , 535' = {"a": [10]}' , 536} , { { type =4 , timestamp =0 , data ={ a ={ 10 } } } } ) 537sd2strings_eq ( 538{ 539'History entry with timestamp ' .. epoch .. ':' , 540' @ Description_ Value' , 541' # Expected more elements in list' , 542} , 543( [[ [{'type': 4, 'timestamp': 0, 'data': [ 544]}] ]] ): gsub ( '\n' , '' ) 545) 546sd2strings_eq ( 547{ 548'History entry with timestamp ' .. epoch .. ':' , 549' @ Description_ Value' , 550' # Expected integer' , 551' - history type ""' , 552' # Expected more elements in list' , 553} , 554( [[ [{'type': 4, 'timestamp': 0, 'data': [ 555'', 556]}] ]] ): gsub ( '\n' , '' ) 557) 558sd2strings_eq ( 559{ 560'History entry with timestamp ' .. epoch .. ':' , 561' @ Description_ Value' , 562' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' 563.. '2 (EXPR), 3 (INPUT), 4 (DEBUG)' , 564' - history type 5' , 565' - contents ""' , 566} , 567( [[ [{'type': 4, 'timestamp': 0, 'data': [ 5685, 569'' 570]}] ]] ): gsub ( '\n' , '' ) 571) 572sd2strings_eq ( 573{ 574'History entry with timestamp ' .. epoch .. ':' , 575' @ Description_ Value' , 576' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' 577.. '2 (EXPR), 3 (INPUT), 4 (DEBUG)' , 578' - history type 5' , 579' - contents ""' , 580' - 32' , 581} , 582( [[ [{'type': 4, 'timestamp': 0, 'data': [ 5835, 584'', 5850x20 586]}] ]] ): gsub ( '\n' , '' ) 587) 588sd2strings_eq ( 589{ 590'History entry with timestamp ' .. epoch .. ':' , 591' @ Description_ Value' , 592' - history type CMD' , 593' - contents ""' , 594' - 32' , 595} , 596( [[ [{'type': 4, 'timestamp': 0, 'data': [ 5970, 598'', 5990x20 600]}] ]] ): gsub ( '\n' , '' ) 601) 602sd2strings_eq ( 603{ 604'History entry with timestamp ' .. epoch .. ':' , 605' @ Description_ Value' , 606' - history type SEARCH' , 607' - contents ""' , 608" - separator ' '" , 609} , 610( [[ [{'type': 4, 'timestamp': 0, 'data': [ 6111, 612'', 6130x20 614]}] ]] ): gsub ( '\n' , '' ) 615) 616sd2strings_eq ( 617{ 618'History entry with timestamp ' .. epoch .. ':' , 619' @ Description_ Value' , 620' - history type SEARCH' , 621' - contents ""' , 622' # Expected more elements in list' , 623} , 624( [[ [{'type': 4, 'timestamp': 0, 'data': [ 6251, 626'', 627]}] ]] ): gsub ( '\n' , '' ) 628) 629sd2strings_eq ( 630{ 631'History entry with timestamp ' .. epoch .. ':' , 632' @ Description_ Value' , 633' - history type EXPR' , 634' - contents ""' , 635} , 636( [[ [{'type': 4, 'timestamp': 0, 'data': [ 6372, 638'', 639]}] ]] ): gsub ( '\n' , '' ) 640) 641sd2strings_eq ( 642{ 643'History entry with timestamp ' .. epoch .. ':' , 644' @ Description_ Value' , 645' - history type INPUT' , 646' - contents ""' , 647} , 648( [[ [{'type': 4, 'timestamp': 0, 'data': [ 6493, 650'', 651]}] ]] ): gsub ( '\n' , '' ) 652) 653sd2strings_eq ( 654{ 655'History entry with timestamp ' .. epoch .. ':' , 656' @ Description_ Value' , 657' - history type DEBUG' , 658' - contents ""' , 659} , 660( [[ [{'type': 4, 'timestamp': 0, 'data': [ 6614, 662'', 663]}] ]] ): gsub ( '\n' , '' ) 664) 665sd2strings_eq ( 666{ 667'History entry with timestamp ' .. epoch .. ':' , 668' @ Description_ Value' , 669' - history type DEBUG' , 670' # Expected binary string' , 671' - contents 10' , 672} , 673( [[ [{'type': 4, 'timestamp': 0, 'data': [ 6744, 67510, 676]}] ]] ): gsub ( '\n' , '' ) 677) 678sd2strings_eq ( 679{ 680'History entry with timestamp ' .. epoch .. ':' , 681' @ Description_ Value' , 682' - history type DEBUG' , 683' # Expected no NUL bytes' , 684' - contents "abc\\0def"' , 685} , 686( [[ [{'type': 4, 'timestamp': 0, 'data': [ 6874, 688{'_TYPE': v:msgpack_types.string, '_VAL': ["abc\ndef"]}, 689]}] ]] ): gsub ( '\n' , '' ) 690) 691sd2strings_eq ( 692{ 693'History entry with timestamp ' .. epoch .. ':' , 694' @ Description_ Value' , 695' - history type SEARCH' , 696' - contents "abc"' , 697' # Expected integer' , 698' - separator ""' , 699} , 700( [[ [{'type': 4, 'timestamp': 0, 'data': [ 7011, 702'abc', 703'', 704]}] ]] ): gsub ( '\n' , '' ) 705) 706sd2strings_eq ( 707{ 708'History entry with timestamp ' .. epoch .. ':' , 709' @ Description_ Value' , 710' - history type SEARCH' , 711' - contents "abc"' , 712' # Value is negative' , 713' - separator -1' , 714} , 715( [[ [{'type': 4, 'timestamp': 0, 'data': [ 7161, 717'abc', 718-1, 719]}] ]] ): gsub ( '\n' , '' ) 720) 721-- Regression: NUL separator must be properly supported 722sd2strings_eq ( 723{ 724'History entry with timestamp ' .. epoch .. ':' , 725' @ Description_ Value' , 726' - history type SEARCH' , 727' - contents ""' , 728" - separator '\\0'" , 729} , 730( [[ [{'type': 4, 'timestamp': 0, 'data': [ 7311, 732'', 7330x0 734]}] ]] ): gsub ( '\n' , '' ) 735) 736end ) 737 738it ( 'works with register items' , function () 739sd2strings_eq ( { 740'Register with timestamp ' .. epoch .. ':' , 741' # Unexpected type: array instead of map' , 742' = [1, 2, 3]' , 743} , { { type =5 , timestamp =0 , data ={ 1 , 2 , 3 } } } ) 744sd2strings_eq ( 745{ 746'Register with timestamp ' .. epoch .. ':' , 747' % Key Description Value' , 748' # Required key missing: n' , 749' # Required key missing: rc' , 750' + rw block width 0' , 751' + rt type CHARACTERWISE' , 752' + ru is_unnamed FALSE' , 753} , 754( [[ [{'type': 5, 'timestamp': 0, 'data': { 755}}] ]] ): gsub ( '\n' , '' ) 756) 757sd2strings_eq ( 758{ 759'Register with timestamp ' .. epoch .. ':' , 760' % Key Description Value' , 761" + n name ' '" , 762' # Required key missing: rc' , 763' + rw block width 0' , 764' + rt type CHARACTERWISE' , 765' + ru is_unnamed FALSE' , 766} , 767( [[ [{'type': 5, 'timestamp': 0, 'data': { 768'n': 0x20, 769}}] ]] ): gsub ( '\n' , '' ) 770) 771sd2strings_eq ( 772{ 773'Register with timestamp ' .. epoch .. ':' , 774' % Key Description Value' , 775" + n name ' '" , 776' + rc contents ["abc", "def"]' , 777' + rw block width 0' , 778' + rt type CHARACTERWISE' , 779' + ru is_unnamed FALSE' , 780} , 781( [[ [{'type': 5, 'timestamp': 0, 'data': { 782'n': 0x20, 783'rc': ["abc", "def"], 784'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}, 785}}] ]] ): gsub ( '\n' , '' ) 786) 787sd2strings_eq ( 788{ 789'Register with timestamp ' .. epoch .. ':' , 790' % Key Description Value' , 791" + n name ' '" , 792' + rc contents @' , 793' | - "abcdefghijklmnopqrstuvwxyz"' , 794' | - "abcdefghijklmnopqrstuvwxyz"' , 795' + rw block width 0' , 796' + rt type CHARACTERWISE' , 797' + ru is_unnamed TRUE' , 798} , 799( [[ [{'type': 5, 'timestamp': 0, 'data': { 800'n': 0x20, 801'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 802'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}, 803}}] ]] ): gsub ( '\n' , '' ) 804) 805sd2strings_eq ( 806{ 807'Register with timestamp ' .. epoch .. ':' , 808' % Key Description Value' , 809" + n name ' '" , 810' + rc contents @' , 811' | - "abcdefghijklmnopqrstuvwxyz"' , 812' | - "abcdefghijklmnopqrstuvwxyz"' , 813' + rw block width 0' , 814' + rt type CHARACTERWISE' , 815' + ru is_unnamed FALSE' , 816} , 817( [[ [{'type': 5, 'timestamp': 0, 'data': { 818'n': 0x20, 819'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 820'rw': 0, 821'rt': 0, 822}}] ]] ): gsub ( '\n' , '' ) 823) 824sd2strings_eq ( 825{ 826'Register with timestamp ' .. epoch .. ':' , 827' % Key Description Value' , 828" + n name ' '" , 829' + rc contents @' , 830' | - "abcdefghijklmnopqrstuvwxyz"' , 831' | - "abcdefghijklmnopqrstuvwxyz"' , 832' + rw block width 5' , 833' + rt type LINEWISE' , 834' + ru is_unnamed FALSE' , 835} , 836( [[ [{'type': 5, 'timestamp': 0, 'data': { 837'n': 0x20, 838'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 839'rw': 5, 840'rt': 1, 841}}] ]] ): gsub ( '\n' , '' ) 842) 843sd2strings_eq ( 844{ 845'Register with timestamp ' .. epoch .. ':' , 846' % Key Description Value' , 847" + n name ' '" , 848' + rc contents @' , 849' | - "abcdefghijklmnopqrstuvwxyz"' , 850' | - "abcdefghijklmnopqrstuvwxyz"' , 851' # Expected integer' , 852' + rw block width ""' , 853' + rt type BLOCKWISE' , 854' # Expected boolean' , 855' + ru is_unnamed ""' , 856} , 857( [[ [{'type': 5, 'timestamp': 0, 'data': { 858'n': 0x20, 859'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 860'rw': "", 861'rt': 2, 862'ru': "" 863}}] ]] ): gsub ( '\n' , '' ) 864) 865sd2strings_eq ( 866{ 867'Register with timestamp ' .. epoch .. ':' , 868' % Key Description Value' , 869" + n name ' '" , 870' # Expected array value' , 871' + rc contents 0' , 872' # Value is negative' , 873' + rw block width -1' , 874' # Unexpected enum value: expected one of 0 (CHARACTERWISE), ' 875.. '1 (LINEWISE), 2 (BLOCKWISE)' , 876' + rt type 10' , 877' # Expected boolean' , 878' + ru is_unnamed ["abc", "def"]' , 879} , 880( [[ [{'type': 5, 'timestamp': 0, 'data': { 881'n': 0x20, 882'rc': 0, 883'rw': -1, 884'rt': 10, 885'ru': ['abc', 'def'], 886}}] ]] ): gsub ( '\n' , '' ) 887) 888sd2strings_eq ( 889{ 890'Register with timestamp ' .. epoch .. ':' , 891' % Key Description Value' , 892" + n name ' '" , 893' + rc contents @' , 894' | - "abcdefghijklmnopqrstuvwxyz"' , 895' | - "abcdefghijklmnopqrstuvwxyz"' , 896' + rw block width 5' , 897' + rt type LINEWISE' , 898' # Expected boolean' , 899' + ru is_unnamed 0' , 900} , 901( [[ [{'type': 5, 'timestamp': 0, 'data': { 902'n': 0x20, 903'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'], 904'rw': 5, 905'rt': 1, 906'ru': 0, 907}}] ]] ): gsub ( '\n' , '' ) 908) 909end ) 910 911it ( 'works with variable items' , function () 912sd2strings_eq ( { 913'Variable with timestamp ' .. epoch .. ':' , 914' # Unexpected type: map instead of array' , 915' = {"a": [10]}' , 916} , { { type =6 , timestamp =0 , data ={ a ={ 10 } } } } ) 917sd2strings_eq ( 918{ 919'Variable with timestamp ' .. epoch .. ':' , 920' @ Description Value' , 921' # Expected more elements in list' , 922} , 923( [[ [{'type': 6, 'timestamp': 0, 'data': [ 924]}] ]] ): gsub ( '\n' , '' ) 925) 926sd2strings_eq ( 927{ 928'Variable with timestamp ' .. epoch .. ':' , 929' @ Description Value' , 930' # Expected binary string' , 931' - name 1' , 932' # Expected more elements in list' , 933} , 934( [[ [{'type': 6, 'timestamp': 0, 'data': [ 9351 936]}] ]] ): gsub ( '\n' , '' ) 937) 938sd2strings_eq ( 939{ 940'Variable with timestamp ' .. epoch .. ':' , 941' @ Description Value' , 942' # Expected no NUL bytes' , 943' - name "\\0"' , 944' # Expected more elements in list' , 945} , 946( [[ [{'type': 6, 'timestamp': 0, 'data': [ 947{'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]}, 948]}] ]] ): gsub ( '\n' , '' ) 949) 950sd2strings_eq ( 951{ 952'Variable with timestamp ' .. epoch .. ':' , 953' @ Description Value' , 954' - name "foo"' , 955' # Expected more elements in list' , 956} , 957( [[ [{'type': 6, 'timestamp': 0, 'data': [ 958{'_TYPE': v:msgpack_types.string, '_VAL': ["foo"]}, 959]}] ]] ): gsub ( '\n' , '' ) 960) 961sd2strings_eq ( 962{ 963'Variable with timestamp ' .. epoch .. ':' , 964' @ Description Value' , 965' - name "foo"' , 966' - value NIL' , 967} , 968( [[ [{'type': 6, 'timestamp': 0, 'data': [ 969{'_TYPE': v:msgpack_types.string, '_VAL': ["foo"]}, 970{'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]}, 971]}] ]] ): gsub ( '\n' , '' ) 972) 973sd2strings_eq ( 974{ 975'Variable with timestamp ' .. epoch .. ':' , 976' @ Description Value' , 977' - name "foo"' , 978' - value NIL' , 979' - NIL' , 980} , 981( [[ [{'type': 6, 'timestamp': 0, 'data': [ 982{'_TYPE': v:msgpack_types.string, '_VAL': ["foo"]}, 983{'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]}, 984{'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]}, 985]}] ]] ): gsub ( '\n' , '' ) 986) 987end ) 988 989it ( 'works with global mark items' , function () 990sd2strings_eq ( { 991'Global mark with timestamp ' .. epoch .. ':' , 992' # Unexpected type: array instead of map' , 993' = [1, 2, 3]' , 994} , { { type =7 , timestamp =0 , data ={ 1 , 2 , 3 } } } ) 995sd2strings_eq ( 996{ 997'Global mark with timestamp ' .. epoch .. ':' , 998' % Key Description Value' , 999' # Required key missing: n' , 1000' # Required key missing: f' , 1001' + l line number 1' , 1002' + c column 0' , 1003} , 1004( [[ [{'type': 7, 'timestamp': 0, 'data': { 1005}}] ]] ): gsub ( '\n' , '' ) 1006) 1007sd2strings_eq ( 1008{ 1009'Global mark with timestamp ' .. epoch .. ':' , 1010' % Key Description Value' , 1011' # Expected integer' , 1012' + n name "foo"' , 1013' # Required key missing: f' , 1014' + l line number 1' , 1015' + c column 0' , 1016} , 1017( [[ [{'type': 7, 'timestamp': 0, 'data': { 1018'n': 'foo', 1019}}] ]] ): gsub ( '\n' , '' ) 1020) 1021sd2strings_eq ( 1022{ 1023'Global mark with timestamp ' .. epoch .. ':' , 1024' % Key Description Value' , 1025' # Required key missing: n' , 1026' + f file name "foo"' , 1027' + l line number 1' , 1028' + c column 0' , 1029} , 1030( [[ [{'type': 7, 'timestamp': 0, 'data': { 1031'f': 'foo', 1032}}] ]] ): gsub ( '\n' , '' ) 1033) 1034sd2strings_eq ( 1035{ 1036'Global mark with timestamp ' .. epoch .. ':' , 1037' % Key Description Value' , 1038' # Value is negative' , 1039' + n name -10' , 1040' # Expected no NUL bytes' , 1041' + f file name "\\0"' , 1042' + l line number 1' , 1043' + c column 0' , 1044} , 1045( [[ [{'type': 7, 'timestamp': 0, 'data': { 1046'n': -10, 1047'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]}, 1048}}] ]] ): gsub ( '\n' , '' ) 1049) 1050sd2strings_eq ( 1051{ 1052'Global mark with timestamp ' .. epoch .. ':' , 1053' % Key Description Value' , 1054" + n name '\\20'" , 1055' + f file name "foo"' , 1056' # Value is negative' , 1057' + l line number -10' , 1058' # Value is negative' , 1059' + c column -10' , 1060} , 1061( [[ [{'type': 7, 'timestamp': 0, 'data': { 1062'n': 20, 1063'f': 'foo', 1064'l': -10, 1065'c': -10, 1066}}] ]] ): gsub ( '\n' , '' ) 1067) 1068sd2strings_eq ( 1069{ 1070'Global mark with timestamp ' .. epoch .. ':' , 1071' % Key Description Value' , 1072' + n name 128' , 1073' + f file name "foo"' , 1074' + l line number 1' , 1075' + c column 0' , 1076} , 1077( [[ [{'type': 7, 'timestamp': 0, 'data': { 1078'n': 128, 1079'f': 'foo', 1080}}] ]] ): gsub ( '\n' , '' ) 1081) 1082sd2strings_eq ( 1083{ 1084'Global mark with timestamp ' .. epoch .. ':' , 1085' % Key Description Value' , 1086" + n name '\\20'" , 1087' + f file name "foo"' , 1088' # Expected integer' , 1089' + l line number "FOO"' , 1090' # Expected integer' , 1091' + c column "foo"' , 1092' + mX 10' , 1093} , 1094( [[ [{'type': 7, 'timestamp': 0, 'data': { 1095'n': 20, 1096'f': 'foo', 1097'l': 'FOO', 1098'c': 'foo', 1099'mX': 10, 1100}}] ]] ): gsub ( '\n' , '' ) 1101) 1102sd2strings_eq ( 1103{ 1104'Global mark with timestamp ' .. epoch .. ':' , 1105' % Key________ Description Value' , 1106" + n name 'A'" , 1107' + f file name "foo"' , 1108' + l line number 2' , 1109' + c column 200' , 1110' + mX 10' , 1111' + mYYYYYYYYYY 10' , 1112} , 1113( [[ [{'type': 7, 'timestamp': 0, 'data': { 1114'n': char2nr('A'), 1115'f': 'foo', 1116'l': 2, 1117'c': 200, 1118'mX': 10, 1119'mYYYYYYYYYY': 10, 1120}}] ]] ): gsub ( '\n' , '' ) 1121) 1122end ) 1123 1124it ( 'works with jump items' , function () 1125sd2strings_eq ( { 1126'Jump with timestamp ' .. epoch .. ':' , 1127' # Unexpected type: array instead of map' , 1128' = [1, 2, 3]' , 1129} , { { type =8 , timestamp =0 , data ={ 1 , 2 , 3 } } } ) 1130sd2strings_eq ( 1131{ 1132'Jump with timestamp ' .. epoch .. ':' , 1133' % Key Description Value' , 1134' # Required key missing: f' , 1135' + l line number 1' , 1136' + c column 0' , 1137} , 1138( [[ [{'type': 8, 'timestamp': 0, 'data': { 1139}}] ]] ): gsub ( '\n' , '' ) 1140) 1141sd2strings_eq ( 1142{ 1143'Jump with timestamp ' .. epoch .. ':' , 1144' % Key Description Value' , 1145' # Required key missing: f' , 1146' + l line number 1' , 1147' + c column 0' , 1148' # Expected integer' , 1149' + n name "foo"' , 1150} , 1151( [[ [{'type': 8, 'timestamp': 0, 'data': { 1152'n': 'foo', 1153}}] ]] ): gsub ( '\n' , '' ) 1154) 1155sd2strings_eq ( 1156{ 1157'Jump with timestamp ' .. epoch .. ':' , 1158' % Key Description Value' , 1159' + f file name "foo"' , 1160' + l line number 1' , 1161' + c column 0' , 1162} , 1163( [[ [{'type': 8, 'timestamp': 0, 'data': { 1164'f': 'foo', 1165}}] ]] ): gsub ( '\n' , '' ) 1166) 1167sd2strings_eq ( 1168{ 1169'Jump with timestamp ' .. epoch .. ':' , 1170' % Key Description Value' , 1171' # Expected no NUL bytes' , 1172' + f file name "\\0"' , 1173' + l line number 1' , 1174' + c column 0' , 1175' # Value is negative' , 1176' + n name -10' , 1177} , 1178( [[ [{'type': 8, 'timestamp': 0, 'data': { 1179'n': -10, 1180'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]}, 1181}}] ]] ): gsub ( '\n' , '' ) 1182) 1183sd2strings_eq ( 1184{ 1185'Jump with timestamp ' .. epoch .. ':' , 1186' % Key Description Value' , 1187' + f file name "foo"' , 1188' # Value is negative' , 1189' + l line number -10' , 1190' # Value is negative' , 1191' + c column -10' , 1192} , 1193( [[ [{'type': 8, 'timestamp': 0, 'data': { 1194'f': 'foo', 1195'l': -10, 1196'c': -10, 1197}}] ]] ): gsub ( '\n' , '' ) 1198) 1199sd2strings_eq ( 1200{ 1201'Jump with timestamp ' .. epoch .. ':' , 1202' % Key Description Value' , 1203' + f file name "foo"' , 1204' # Expected integer' , 1205' + l line number "FOO"' , 1206' # Expected integer' , 1207' + c column "foo"' , 1208' + mX 10' , 1209} , 1210( [[ [{'type': 8, 'timestamp': 0, 'data': { 1211'f': 'foo', 1212'l': 'FOO', 1213'c': 'foo', 1214'mX': 10, 1215}}] ]] ): gsub ( '\n' , '' ) 1216) 1217sd2strings_eq ( 1218{ 1219'Jump with timestamp ' .. epoch .. ':' , 1220' % Key________ Description Value' , 1221' + f file name "foo"' , 1222' + l line number 2' , 1223' + c column 200' , 1224' + mX 10' , 1225' + mYYYYYYYYYY 10' , 1226" + n name ' '" , 1227} , 1228( [[ [{'type': 8, 'timestamp': 0, 'data': { 1229'n': 0x20, 1230'f': 'foo', 1231'l': 2, 1232'c': 200, 1233'mX': 10, 1234'mYYYYYYYYYY': 10, 1235}}] ]] ): gsub ( '\n' , '' ) 1236) 1237end ) 1238 1239it ( 'works with buffer list items' , function () 1240sd2strings_eq ( { 1241'Buffer list with timestamp ' .. epoch .. ':' , 1242' # Unexpected type: map instead of array' , 1243' = {"a": [10]}' , 1244} , { { type =9 , timestamp =0 , data ={ a ={ 10 } } } } ) 1245sd2strings_eq ( { 1246'Buffer list with timestamp ' .. epoch .. ':' , 1247' # Expected array of maps' , 1248' = [[], []]' , 1249} , { { type =9 , timestamp =0 , data ={ {} , {} } } } ) 1250sd2strings_eq ( { 1251'Buffer list with timestamp ' .. epoch .. ':' , 1252' # Expected array of maps' , 1253' = [{"a": 10}, []]' , 1254} , { { type =9 , timestamp =0 , data ={ { a =10 } , {} } } } ) 1255sd2strings_eq ( { 1256'Buffer list with timestamp ' .. epoch .. ':' , 1257' % Key Description Value' , 1258' # Required key missing: f' , 1259' + l line number 1' , 1260' + c column 0' , 1261' + a 10' , 1262} , { { type =9 , timestamp =0 , data ={ { a =10 } } } } ) 1263sd2strings_eq ( { 1264'Buffer list with timestamp ' .. epoch .. ':' , 1265' % Key Description Value' , 1266' # Required key missing: f' , 1267' # Expected integer' , 1268' + l line number "10"' , 1269' # Expected integer' , 1270' + c column "10"' , 1271' + a 10' , 1272} , { { type =9 , timestamp =0 , data ={ { l ='10' , c ='10' , a =10 } } } } ) 1273sd2strings_eq ( { 1274'Buffer list with timestamp ' .. epoch .. ':' , 1275' % Key Description Value' , 1276' # Required key missing: f' , 1277' + l line number 10' , 1278' + c column 10' , 1279' + a 10' , 1280} , { { type =9 , timestamp =0 , data ={ { l =10 , c =10 , a =10 } } } } ) 1281sd2strings_eq ( { 1282'Buffer list with timestamp ' .. epoch .. ':' , 1283' % Key Description Value' , 1284' # Required key missing: f' , 1285' # Value is negative' , 1286' + l line number -10' , 1287' # Value is negative' , 1288' + c column -10' , 1289} , { { type =9 , timestamp =0 , data ={ { l =- 10 , c =- 10 } } } } ) 1290sd2strings_eq ( { 1291'Buffer list with timestamp ' .. epoch .. ':' , 1292' % Key Description Value' , 1293' + f file name "abc"' , 1294' + l line number 1' , 1295' + c column 0' , 1296} , { { type =9 , timestamp =0 , data ={ { f ='abc' } } } } ) 1297sd2strings_eq ( { 1298'Buffer list with timestamp ' .. epoch .. ':' , 1299' % Key Description Value' , 1300' # Expected binary string' , 1301' + f file name 10' , 1302' + l line number 1' , 1303' + c column 0' , 1304'' , 1305' % Key Description Value' , 1306' # Expected binary string' , 1307' + f file name 20' , 1308' + l line number 1' , 1309' + c column 0' , 1310} , { { type =9 , timestamp =0 , data ={ { f =10 } , { f =20 } } } } ) 1311sd2strings_eq ( 1312{ 1313'Buffer list with timestamp ' .. epoch .. ':' , 1314' % Key Description Value' , 1315' # Expected binary string' , 1316' + f file name 10' , 1317' + l line number 1' , 1318' + c column 0' , 1319'' , 1320' % Key Description Value' , 1321' # Expected no NUL bytes' , 1322' + f file name "\\0"' , 1323' + l line number 1' , 1324' + c column 0' , 1325} , 1326( [[ [{'type': 9, 'timestamp': 0, 'data': [ 1327{'f': 10}, 1328{'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]}}, 1329]}] ]] ): gsub ( '\n' , '' ) 1330) 1331end ) 1332 1333it ( 'works with local mark items' , function () 1334sd2strings_eq ( { 1335'Local mark with timestamp ' .. epoch .. ':' , 1336' # Unexpected type: array instead of map' , 1337' = [1, 2, 3]' , 1338} , { { type =10 , timestamp =0 , data ={ 1 , 2 , 3 } } } ) 1339sd2strings_eq ( 1340{ 1341'Local mark with timestamp ' .. epoch .. ':' , 1342' % Key Description Value' , 1343' # Required key missing: f' , 1344" + n name '\"'" , 1345' + l line number 1' , 1346' + c column 0' , 1347} , 1348( [[ [{'type': 10, 'timestamp': 0, 'data': { 1349}}] ]] ): gsub ( '\n' , '' ) 1350) 1351sd2strings_eq ( 1352{ 1353'Local mark with timestamp ' .. epoch .. ':' , 1354' % Key Description Value' , 1355' # Required key missing: f' , 1356' # Expected integer' , 1357' + n name "foo"' , 1358' + l line number 1' , 1359' + c column 0' , 1360} , 1361( [[ [{'type': 10, 'timestamp': 0, 'data': { 1362'n': 'foo', 1363}}] ]] ): gsub ( '\n' , '' ) 1364) 1365sd2strings_eq ( 1366{ 1367'Local mark with timestamp ' .. epoch .. ':' , 1368' % Key Description Value' , 1369' + f file name "foo"' , 1370" + n name '\"'" , 1371' + l line number 1' , 1372' + c column 0' , 1373} , 1374( [[ [{'type': 10, 'timestamp': 0, 'data': { 1375'f': 'foo', 1376}}] ]] ): gsub ( '\n' , '' ) 1377) 1378sd2strings_eq ( 1379{ 1380'Local mark with timestamp ' .. epoch .. ':' , 1381' % Key Description Value' , 1382' # Expected no NUL bytes' , 1383' + f file name "\\0"' , 1384' # Value is negative' , 1385' + n name -10' , 1386' + l line number 1' , 1387' + c column 0' , 1388} , 1389( [[ [{'type': 10, 'timestamp': 0, 'data': { 1390'n': -10, 1391'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]}, 1392}}] ]] ): gsub ( '\n' , '' ) 1393) 1394sd2strings_eq ( 1395{ 1396'Local mark with timestamp ' .. epoch .. ':' , 1397' % Key Description Value' , 1398' + f file name "foo"' , 1399" + n name '\\20'" , 1400' # Value is negative' , 1401' + l line number -10' , 1402' # Value is negative' , 1403' + c column -10' , 1404} , 1405( [[ [{'type': 10, 'timestamp': 0, 'data': { 1406'n': 20, 1407'f': 'foo', 1408'l': -10, 1409'c': -10, 1410}}] ]] ): gsub ( '\n' , '' ) 1411) 1412sd2strings_eq ( 1413{ 1414'Local mark with timestamp ' .. epoch .. ':' , 1415' % Key Description Value' , 1416' + f file name "foo"' , 1417" + n name '\\20'" , 1418' # Expected integer' , 1419' + l line number "FOO"' , 1420' # Expected integer' , 1421' + c column "foo"' , 1422' + mX 10' , 1423} , 1424( [[ [{'type': 10, 'timestamp': 0, 'data': { 1425'n': 20, 1426'f': 'foo', 1427'l': 'FOO', 1428'c': 'foo', 1429'mX': 10, 1430}}] ]] ): gsub ( '\n' , '' ) 1431) 1432sd2strings_eq ( 1433{ 1434'Local mark with timestamp ' .. epoch .. ':' , 1435' % Key________ Description Value' , 1436' + f file name "foo"' , 1437" + n name 'a'" , 1438' + l line number 2' , 1439' + c column 200' , 1440' + mX 10' , 1441' + mYYYYYYYYYY 10' , 1442} , 1443( [[ [{'type': 10, 'timestamp': 0, 'data': { 1444'n': char2nr('a'), 1445'f': 'foo', 1446'l': 2, 1447'c': 200, 1448'mX': 10, 1449'mYYYYYYYYYY': 10, 1450}}] ]] ): gsub ( '\n' , '' ) 1451) 1452end ) 1453 1454it ( 'works with change items' , function () 1455sd2strings_eq ( { 1456'Change with timestamp ' .. epoch .. ':' , 1457' # Unexpected type: array instead of map' , 1458' = [1, 2, 3]' , 1459} , { { type =11 , timestamp =0 , data ={ 1 , 2 , 3 } } } ) 1460sd2strings_eq ( 1461{ 1462'Change with timestamp ' .. epoch .. ':' , 1463' % Key Description Value' , 1464' # Required key missing: f' , 1465' + l line number 1' , 1466' + c column 0' , 1467} , 1468( [[ [{'type': 11, 'timestamp': 0, 'data': { 1469}}] ]] ): gsub ( '\n' , '' ) 1470) 1471sd2strings_eq ( 1472{ 1473'Change with timestamp ' .. epoch .. ':' , 1474' % Key Description Value' , 1475' # Required key missing: f' , 1476' + l line number 1' , 1477' + c column 0' , 1478' # Expected integer' , 1479' + n name "foo"' , 1480} , 1481( [[ [{'type': 11, 'timestamp': 0, 'data': { 1482'n': 'foo', 1483}}] ]] ): gsub ( '\n' , '' ) 1484) 1485sd2strings_eq ( 1486{ 1487'Change with timestamp ' .. epoch .. ':' , 1488' % Key Description Value' , 1489' + f file name "foo"' , 1490' + l line number 1' , 1491' + c column 0' , 1492} , 1493( [[ [{'type': 11, 'timestamp': 0, 'data': { 1494'f': 'foo', 1495}}] ]] ): gsub ( '\n' , '' ) 1496) 1497sd2strings_eq ( 1498{ 1499'Change with timestamp ' .. epoch .. ':' , 1500' % Key Description Value' , 1501' # Expected no NUL bytes' , 1502' + f file name "\\0"' , 1503' + l line number 1' , 1504' + c column 0' , 1505' # Value is negative' , 1506' + n name -10' , 1507} , 1508( [[ [{'type': 11, 'timestamp': 0, 'data': { 1509'n': -10, 1510'f': {'_TYPE': v:msgpack_types.string, '_VAL': ["\n"]}, 1511}}] ]] ): gsub ( '\n' , '' ) 1512) 1513sd2strings_eq ( 1514{ 1515'Change with timestamp ' .. epoch .. ':' , 1516' % Key Description Value' , 1517' + f file name "foo"' , 1518' # Value is negative' , 1519' + l line number -10' , 1520' # Value is negative' , 1521' + c column -10' , 1522} , 1523( [[ [{'type': 11, 'timestamp': 0, 'data': { 1524'f': 'foo', 1525'l': -10, 1526'c': -10, 1527}}] ]] ): gsub ( '\n' , '' ) 1528) 1529sd2strings_eq ( 1530{ 1531'Change with timestamp ' .. epoch .. ':' , 1532' % Key Description Value' , 1533' + f file name "foo"' , 1534' # Expected integer' , 1535' + l line number "FOO"' , 1536' # Expected integer' , 1537' + c column "foo"' , 1538' + mX 10' , 1539} , 1540( [[ [{'type': 11, 'timestamp': 0, 'data': { 1541'f': 'foo', 1542'l': 'FOO', 1543'c': 'foo', 1544'mX': 10, 1545}}] ]] ): gsub ( '\n' , '' ) 1546) 1547sd2strings_eq ( 1548{ 1549'Change with timestamp ' .. epoch .. ':' , 1550' % Key________ Description Value' , 1551' + f file name "foo"' , 1552' + l line number 2' , 1553' + c column 200' , 1554' + mX 10' , 1555' + mYYYYYYYYYY 10' , 1556" + n name ' '" , 1557} , 1558( [[ [{'type': 11, 'timestamp': 0, 'data': { 1559'n': 0x20, 1560'f': 'foo', 1561'l': 2, 1562'c': 200, 1563'mX': 10, 1564'mYYYYYYYYYY': 10, 1565}}] ]] ): gsub ( '\n' , '' ) 1566) 1567end ) 1568end ) 1569 1570describe ( 'function shada#get_strings' , function () 1571it ( 'works' , function () 1572eq ( { 1573'Header with timestamp ' .. epoch .. ':' , 1574' % Key Value' , 1575} , nvim_eval ( 'shada#get_strings(msgpackdump([1, 0, 0, {}]))' )) 1576end ) 1577end ) 1578 1579describe ( 'function shada#strings_to_sd' , function () 1580local strings2sd_eq =function ( expected , input ) 1581api . nvim_set_var ( '__input' , input ) 1582nvim_command ( 1583'let g:__actual = map(shada#strings_to_sd(g:__input), ' 1584.. '"filter(v:val, \\"v:key[0] isnot# \'_\' ' 1585.. '&& v:key isnot# \'length\'\\")")' 1586) 1587-- print() 1588if type ( expected ) == 'table' then 1589api . nvim_set_var ( '__expected' , expected ) 1590nvim_command ( 'let g:__expected = ModifyVal(g:__expected)' ) 1591expected ='g:__expected' 1592-- print(nvim_eval('msgpack#string(g:__expected)')) 1593end 1594-- print(nvim_eval('msgpack#string(g:__actual)')) 1595eq ( 1 , nvim_eval (( 'msgpack#equal(%s, g:__actual)' ): format ( expected ))) 1596if type ( expected ) == 'table' then 1597nvim_command ( 'unlet g:__expected' ) 1598end 1599nvim_command ( 'unlet g:__input' ) 1600nvim_command ( 'unlet g:__actual' ) 1601end 1602 1603it ( 'works with multiple items' , function () 1604strings2sd_eq ( { 1605{ 1606type =11 , 1607timestamp =0 , 1608data ={ 1609f ='foo' , 1610l =2 , 1611c =200 , 1612mX =10 , 1613mYYYYYYYYYY =10 , 1614n =( ' ' ): byte (), 1615} , 1616} , 1617{ 1618type =1 , 1619timestamp =0 , 1620data ={ 1621c ='abc' , 1622f ={ '!string' , { 'abc\ndef' } } , 1623l =- 10 , 1624n =- 64 , 1625rc ='10' , 1626rt =10 , 1627sc ={ '!nil' , 0 } , 1628sm ='TRUE' , 1629so ='TRUE' , 1630sp ={ '!string' , { 'abc' } } , 1631} , 1632} , 1633} , { 1634'Change with timestamp ' .. epoch .. ':' , 1635' % Key________ Description Value' , 1636' + f file name "foo"' , 1637' + l line number 2' , 1638' + c column 200' , 1639' + mX 10' , 1640' + mYYYYYYYYYY 10' , 1641" + n name ' '" , 1642'Header with timestamp ' .. epoch .. ':' , 1643' % Key Description____ Value' , 1644' # Expected integer' , 1645' + c column "abc"' , 1646' # Expected no NUL bytes' , 1647' + f file name "abc\\0def"' , 1648' # Value is negative' , 1649' + l line number -10' , 1650' # Value is negative' , 1651' + n name -64' , 1652' # Expected array value' , 1653' + rc contents "10"' , 1654' # Unexpected enum value: expected one of ' 1655.. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)' , 1656' + rt type 10' , 1657' # Expected boolean' , 1658' + sc smartcase value NIL' , 1659' # Expected boolean' , 1660' + sm magic value "TRUE"' , 1661' # Expected integer' , 1662' + so offset value "TRUE"' , 1663' # Expected binary string' , 1664' + sp pattern ="abc"' , 1665} ) 1666end ) 1667 1668it ( 'works with empty list' , function () 1669strings2sd_eq ( {} , {} ) 1670end ) 1671 1672it ( 'works with header items' , function () 1673strings2sd_eq ( { { type =1 , timestamp =0 , data ={ 1674generator ='test' , 1675} } } , { 1676'Header with timestamp ' .. epoch .. ':' , 1677' % Key______ Value' , 1678' + generator "test"' , 1679} ) 1680strings2sd_eq ( 1681{ { type =1 , timestamp =0 , data ={ 16821 , 16832 , 16843 , 1685} } } , 1686{ 1687'Header with timestamp ' .. epoch .. ':' , 1688' # Unexpected type: array instead of map' , 1689' = [1, 2, 3]' , 1690} 1691) 1692strings2sd_eq ( { 1693{ 1694type =1 , 1695timestamp =0 , 1696data ={ 1697a =1 , 1698b =2 , 1699c =3 , 1700d =4 , 1701} , 1702} , 1703} , { 1704'Header with timestamp ' .. epoch .. ':' , 1705' % Key Description Value' , 1706' + a 1' , 1707' + b 2' , 1708' + c column 3' , 1709' + d 4' , 1710} ) 1711strings2sd_eq ( { 1712{ 1713type =1 , 1714timestamp =0 , 1715data ={ 1716c ='abc' , 1717f ={ '!string' , { 'abc\ndef' } } , 1718l =- 10 , 1719n =- 64 , 1720rc ='10' , 1721rt =10 , 1722sc ={ '!nil' , 0 } , 1723sm ='TRUE' , 1724so ='TRUE' , 1725sp ={ '!string' , { 'abc' } } , 1726} , 1727} , 1728} , { 1729'Header with timestamp ' .. epoch .. ':' , 1730' % Key Description____ Value' , 1731' # Expected integer' , 1732' + c column "abc"' , 1733' # Expected no NUL bytes' , 1734' + f file name "abc\\0def"' , 1735' # Value is negative' , 1736' + l line number -10' , 1737' # Value is negative' , 1738' + n name -64' , 1739' # Expected array value' , 1740' + rc contents "10"' , 1741' # Unexpected enum value: expected one of ' 1742.. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)' , 1743' + rt type 10' , 1744' # Expected boolean' , 1745' + sc smartcase value NIL' , 1746' # Expected boolean' , 1747' + sm magic value "TRUE"' , 1748' # Expected integer' , 1749' + so offset value "TRUE"' , 1750' # Expected binary string' , 1751' + sp pattern ="abc"' , 1752} ) 1753end ) 1754 1755it ( 'works with search pattern items' , function () 1756strings2sd_eq ( 1757{ { type =2 , timestamp =0 , data ={ 17581 , 17592 , 17603 , 1761} } } , 1762{ 1763'Search pattern with timestamp ' .. epoch .. ':' , 1764' # Unexpected type: array instead of map' , 1765' = [1, 2, 3]' , 1766} 1767) 1768strings2sd_eq ( { { type =2 , timestamp =0 , data ={ 1769sp ='abc' , 1770} } } , { 1771'Search pattern with timestamp ' .. epoch .. ':' , 1772' % Key Description________ Value' , 1773' + sp pattern "abc"' , 1774' + sh v:hlsearch value FALSE' , 1775' + ss is :s pattern FALSE' , 1776' + sm magic value TRUE' , 1777' + sc smartcase value FALSE' , 1778' + sl has line offset FALSE' , 1779' + se place cursor at end FALSE' , 1780' + so offset value 0' , 1781' + su is last used TRUE' , 1782} ) 1783strings2sd_eq ( { 1784{ 1785type =2 , 1786timestamp =0 , 1787data ={ 1788sp ='abc' , 1789sX ={ '!nil' , 0 } , 1790sY ={ '!nil' , 0 } , 1791sZ ={ '!nil' , 0 } , 1792} , 1793} , 1794} , { 1795'Search pattern with timestamp ' .. epoch .. ':' , 1796' % Key Description________ Value' , 1797' + sp pattern "abc"' , 1798' + sh v:hlsearch value FALSE' , 1799' + ss is :s pattern FALSE' , 1800' + sm magic value TRUE' , 1801' + sc smartcase value FALSE' , 1802' + sl has line offset FALSE' , 1803' + se place cursor at end FALSE' , 1804' + so offset value 0' , 1805' + su is last used TRUE' , 1806' + sX NIL' , 1807' + sY NIL' , 1808' + sZ NIL' , 1809} ) 1810strings2sd_eq ( { { type =2 , timestamp =0 , data ={ '!map' , {} } } } , { 1811'Search pattern with timestamp ' .. epoch .. ':' , 1812' % Key Description________ Value' , 1813' # Required key missing: sp' , 1814' + sh v:hlsearch value FALSE' , 1815' + ss is :s pattern FALSE' , 1816' + sm magic value TRUE' , 1817' + sc smartcase value FALSE' , 1818' + sl has line offset FALSE' , 1819' + se place cursor at end FALSE' , 1820' + so offset value 0' , 1821' + su is last used TRUE' , 1822} ) 1823strings2sd_eq ( { 1824{ 1825type =2 , 1826timestamp =0 , 1827data ={ 1828sp ='' , 1829sh ={ '!boolean' , 1 } , 1830ss ={ '!boolean' , 1 } , 1831sc ={ '!boolean' , 1 } , 1832sl ={ '!boolean' , 1 } , 1833se ={ '!boolean' , 1 } , 1834sm ={ '!boolean' , 0 } , 1835su ={ '!boolean' , 0 } , 1836so =- 10 , 1837} , 1838} , 1839} , { 1840'Search pattern with timestamp ' .. epoch .. ':' , 1841' % Key Description________ Value' , 1842' + sp pattern ""' , 1843' + sh v:hlsearch value TRUE' , 1844' + ss is :s pattern TRUE' , 1845' + sm magic value FALSE' , 1846' + sc smartcase value TRUE' , 1847' + sl has line offset TRUE' , 1848' + se place cursor at end TRUE' , 1849' + so offset value -10' , 1850' + su is last used FALSE' , 1851} ) 1852strings2sd_eq ( { 1853{ 1854type =2 , 1855timestamp =0 , 1856data ={ 1857sp =0 , 1858sh =0 , 1859ss =0 , 1860sc =0 , 1861sl =0 , 1862se =0 , 1863sm =0 , 1864su =0 , 1865so ='' , 1866} , 1867} , 1868} , { 1869'Search pattern with timestamp ' .. epoch .. ':' , 1870' % Key Description________ Value' , 1871' # Expected binary string' , 1872' + sp pattern 0' , 1873' # Expected boolean' , 1874' + sh v:hlsearch value 0' , 1875' # Expected boolean' , 1876' + ss is :s pattern 0' , 1877' # Expected boolean' , 1878' + sm magic value 0' , 1879' # Expected boolean' , 1880' + sc smartcase value 0' , 1881' # Expected boolean' , 1882' + sl has line offset 0' , 1883' # Expected boolean' , 1884' + se place cursor at end 0' , 1885' # Expected integer' , 1886' + so offset value ""' , 1887' # Expected boolean' , 1888' + su is last used 0' , 1889} ) 1890end ) 1891 1892it ( 'works with replacement string items' , function () 1893strings2sd_eq ( { { type =3 , timestamp =0 , data ={ 1894a ={ 10 } , 1895} } } , { 1896'Replacement string with timestamp ' .. epoch .. ':' , 1897' # Unexpected type: map instead of array' , 1898' = {"a": [10]}' , 1899} ) 1900strings2sd_eq ( { { type =3 , timestamp =0 , data ={} } } , { 1901'Replacement string with timestamp ' .. epoch .. ':' , 1902' @ Description__________ Value' , 1903' # Expected more elements in list' , 1904} ) 1905strings2sd_eq ( { { type =3 , timestamp =0 , data ={ 19060 , 1907} } } , { 1908'Replacement string with timestamp ' .. epoch .. ':' , 1909' @ Description__________ Value' , 1910' # Expected binary string' , 1911' - :s replacement string 0' , 1912} ) 1913strings2sd_eq ( 1914{ { type =3 , timestamp =0 , data ={ 1915'abc\ndef' , 19160 , 1917} } } , 1918{ 1919'Replacement string with timestamp ' .. epoch .. ':' , 1920' @ Description__________ Value' , 1921' - :s replacement string "abc\\ndef"' , 1922' - 0' , 1923} 1924) 1925strings2sd_eq ( { { type =3 , timestamp =0 , data ={ 1926'abc\ndef' , 1927} } } , { 1928'Replacement string with timestamp ' .. epoch .. ':' , 1929' @ Description__________ Value' , 1930' - :s replacement string "abc\\ndef"' , 1931} ) 1932end ) 1933 1934it ( 'works with history entry items' , function () 1935strings2sd_eq ( { { type =4 , timestamp =0 , data ={ 1936a ={ 10 } , 1937} } } , { 1938'History entry with timestamp ' .. epoch .. ':' , 1939' # Unexpected type: map instead of array' , 1940' = {"a": [10]}' , 1941} ) 1942strings2sd_eq ( { { type =4 , timestamp =0 , data ={} } } , { 1943'History entry with timestamp ' .. epoch .. ':' , 1944' @ Description_ Value' , 1945' # Expected more elements in list' , 1946} ) 1947strings2sd_eq ( { { type =4 , timestamp =0 , data ={ 1948'' , 1949} } } , { 1950'History entry with timestamp ' .. epoch .. ':' , 1951' @ Description_ Value' , 1952' # Expected integer' , 1953' - history type ""' , 1954' # Expected more elements in list' , 1955} ) 1956strings2sd_eq ( { { type =4 , timestamp =0 , data ={ 19575 , 1958'' , 1959} } } , { 1960'History entry with timestamp ' .. epoch .. ':' , 1961' @ Description_ Value' , 1962' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' 1963.. '2 (EXPR), 3 (INPUT), 4 (DEBUG)' , 1964' - history type 5' , 1965' - contents ""' , 1966} ) 1967strings2sd_eq ( 1968{ { type =4 , timestamp =0 , data ={ 19695 , 1970'' , 197132 , 1972} } } , 1973{ 1974'History entry with timestamp ' .. epoch .. ':' , 1975' @ Description_ Value' , 1976' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), ' 1977.. '2 (EXPR), 3 (INPUT), 4 (DEBUG)' , 1978' - history type 5' , 1979' - contents ""' , 1980' - 32' , 1981} 1982) 1983strings2sd_eq ( 1984{ { type =4 , timestamp =0 , data ={ 19850 , 1986'' , 198732 , 1988} } } , 1989{ 1990'History entry with timestamp ' .. epoch .. ':' , 1991' @ Description_ Value' , 1992' - history type CMD' , 1993' - contents ""' , 1994' - 32' , 1995} 1996) 1997strings2sd_eq ( 1998{ { type =4 , timestamp =0 , data ={ 19991 , 2000'' , 200132 , 2002} } } , 2003{ 2004'History entry with timestamp ' .. epoch .. ':' , 2005' @ Description_ Value' , 2006' - history type SEARCH' , 2007' - contents ""' , 2008" - separator ' '" , 2009} 2010) 2011strings2sd_eq ( { { type =4 , timestamp =0 , data ={ 20121 , 2013'' , 2014} } } , { 2015'History entry with timestamp ' .. epoch .. ':' , 2016' @ Description_ Value' , 2017' - history type SEARCH' , 2018' - contents ""' , 2019' # Expected more elements in list' , 2020} ) 2021strings2sd_eq ( { { type =4 , timestamp =0 , data ={ 20222 , 2023'' , 2024} } } , { 2025'History entry with timestamp ' .. epoch .. ':' , 2026' @ Description_ Value' , 2027' - history type EXPR' , 2028' - contents ""' , 2029} ) 2030strings2sd_eq ( { { type =4 , timestamp =0 , data ={ 20313 , 2032'' , 2033} } } , { 2034'History entry with timestamp ' .. epoch .. ':' , 2035' @ Description_ Value' , 2036' - history type INPUT' , 2037' - contents ""' , 2038} ) 2039strings2sd_eq ( { { type =4 , timestamp =0 , data ={ 20404 , 2041'' , 2042} } } , { 2043'History entry with timestamp ' .. epoch .. ':' , 2044' @ Description_ Value' , 2045' - history type DEBUG' , 2046' - contents ""' , 2047} ) 2048end ) 2049 2050it ( 'works with register items' , function () 2051strings2sd_eq ( 2052{ { type =5 , timestamp =0 , data ={ 20531 , 20542 , 20553 , 2056} } } , 2057{ 2058'Register with timestamp ' .. epoch .. ':' , 2059' # Unexpected type: array instead of map' , 2060' = [1, 2, 3]' , 2061} 2062) 2063strings2sd_eq ( { { type =5 , timestamp =0 , data ={ '!map' , {} } } } , { 2064'Register with timestamp ' .. epoch .. ':' , 2065' % Key Description Value' , 2066' # Required key missing: n' , 2067' # Required key missing: rc' , 2068' + rw block width 0' , 2069' + rt type CHARACTERWISE' , 2070} ) 2071strings2sd_eq ( { { type =5 , timestamp =0 , data ={ 2072n =( ' ' ): byte (), 2073} } } , { 2074'Register with timestamp ' .. epoch .. ':' , 2075' % Key Description Value' , 2076" + n name ' '" , 2077' # Required key missing: rc' , 2078' + rw block width 0' , 2079' + rt type CHARACTERWISE' , 2080} ) 2081strings2sd_eq ( { 2082{ 2083type =5 , 2084timestamp =0 , 2085data ={ 2086n =( ' ' ): byte (), 2087rc ={ 'abc' , 'def' } , 2088} , 2089} , 2090} , { 2091'Register with timestamp ' .. epoch .. ':' , 2092' % Key Description Value' , 2093" + n name ' '" , 2094' + rc contents ["abc", "def"]' , 2095' + rw block width 0' , 2096' + rt type CHARACTERWISE' , 2097} ) 2098strings2sd_eq ( { 2099{ 2100type =5 , 2101timestamp =0 , 2102data ={ 2103n =( ' ' ): byte (), 2104rc ={ 'abcdefghijklmnopqrstuvwxyz' , 'abcdefghijklmnopqrstuvwxyz' } , 2105} , 2106} , 2107} , { 2108'Register with timestamp ' .. epoch .. ':' , 2109' % Key Description Value' , 2110" + n name ' '" , 2111' + rc contents @' , 2112' | - "abcdefghijklmnopqrstuvwxyz"' , 2113' | - "abcdefghijklmnopqrstuvwxyz"' , 2114' + rw block width 0' , 2115' + rt type CHARACTERWISE' , 2116} ) 2117strings2sd_eq ( { 2118{ 2119type =5 , 2120timestamp =0 , 2121data ={ 2122n =( ' ' ): byte (), 2123rc ={ 'abcdefghijklmnopqrstuvwxyz' , 'abcdefghijklmnopqrstuvwxyz' } , 2124rw =5 , 2125rt =1 , 2126} , 2127} , 2128} , { 2129'Register with timestamp ' .. epoch .. ':' , 2130' % Key Description Value' , 2131" + n name ' '" , 2132' + rc contents @' , 2133' | - "abcdefghijklmnopqrstuvwxyz"' , 2134' | - "abcdefghijklmnopqrstuvwxyz"' , 2135' + rw block width 5' , 2136' + rt type LINEWISE' , 2137} ) 2138strings2sd_eq ( { 2139{ 2140type =5 , 2141timestamp =0 , 2142data ={ 2143n =( ' ' ): byte (), 2144rc ={ 'abcdefghijklmnopqrstuvwxyz' , 'abcdefghijklmnopqrstuvwxyz' } , 2145rw =5 , 2146rt =2 , 2147} , 2148} , 2149} , { 2150'Register with timestamp ' .. epoch .. ':' , 2151' % Key Description Value' , 2152" + n name ' '" , 2153' + rc contents @' , 2154' | - "abcdefghijklmnopqrstuvwxyz"' , 2155' | - "abcdefghijklmnopqrstuvwxyz"' , 2156' + rw block width 5' , 2157' + rt type BLOCKWISE' , 2158} ) 2159strings2sd_eq ( { 2160{ 2161type =5 , 2162timestamp =0 , 2163data ={ 2164n =( ' ' ): byte (), 2165rc =0 , 2166rw =- 1 , 2167rt =10 , 2168} , 2169} , 2170} , { 2171'Register with timestamp ' .. epoch .. ':' , 2172' % Key Description Value' , 2173" + n name ' '" , 2174' # Expected array value' , 2175' + rc contents 0' , 2176' # Value is negative' , 2177' + rw block width -1' , 2178' # Unexpected enum value: expected one of 0 (CHARACTERWISE), ' 2179.. '1 (LINEWISE), 2 (BLOCKWISE)' , 2180' + rt type 10' , 2181} ) 2182end ) 2183 2184it ( 'works with variable items' , function () 2185strings2sd_eq ( { { type =6 , timestamp =0 , data ={ 2186a ={ 10 } , 2187} } } , { 2188'Variable with timestamp ' .. epoch .. ':' , 2189' # Unexpected type: map instead of array' , 2190' = {"a": [10]}' , 2191} ) 2192strings2sd_eq ( { { type =6 , timestamp =0 , data ={} } } , { 2193'Variable with timestamp ' .. epoch .. ':' , 2194' @ Description Value' , 2195' # Expected more elements in list' , 2196} ) 2197strings2sd_eq ( { { type =6 , timestamp =0 , data ={ 2198'foo' , 2199} } } , { 2200'Variable with timestamp ' .. epoch .. ':' , 2201' @ Description Value' , 2202' - name "foo"' , 2203' # Expected more elements in list' , 2204} ) 2205strings2sd_eq ( { 2206{ 2207type =6 , 2208timestamp =0 , 2209data ={ 2210'foo' , 2211{ '!nil' , 0 } , 2212} , 2213} , 2214} , { 2215'Variable with timestamp ' .. epoch .. ':' , 2216' @ Description Value' , 2217' - name "foo"' , 2218' - value NIL' , 2219} ) 2220strings2sd_eq ( { 2221{ 2222type =6 , 2223timestamp =0 , 2224data ={ 2225'foo' , 2226{ '!nil' , 0 } , 2227{ '!nil' , 0 } , 2228} , 2229} , 2230} , { 2231'Variable with timestamp ' .. epoch .. ':' , 2232' @ Description Value' , 2233' - name "foo"' , 2234' - value NIL' , 2235' - NIL' , 2236} ) 2237end ) 2238 2239it ( 'works with global mark items' , function () 2240strings2sd_eq ( 2241{ { type =7 , timestamp =0 , data ={ 22421 , 22432 , 22443 , 2245} } } , 2246{ 2247'Global mark with timestamp ' .. epoch .. ':' , 2248' # Unexpected type: array instead of map' , 2249' = [1, 2, 3]' , 2250} 2251) 2252strings2sd_eq ( { 2253{ 2254type =7 , 2255timestamp =0 , 2256data ={ 2257n =( 'A' ): byte (), 2258f ='foo' , 2259l =2 , 2260c =200 , 2261mX =10 , 2262mYYYYYYYYYY =10 , 2263} , 2264} , 2265} , { 2266'Global mark with timestamp ' .. epoch .. ':' , 2267' % Key________ Description Value' , 2268" + n name 'A'" , 2269' + f file name "foo"' , 2270' + l line number 2' , 2271' + c column 200' , 2272' + mX 10' , 2273' + mYYYYYYYYYY 10' , 2274} ) 2275end ) 2276 2277it ( 'works with jump items' , function () 2278strings2sd_eq ( 2279{ { type =8 , timestamp =0 , data ={ 22801 , 22812 , 22823 , 2283} } } , 2284{ 2285'Jump with timestamp ' .. epoch .. ':' , 2286' # Unexpected type: array instead of map' , 2287' = [1, 2, 3]' , 2288} 2289) 2290strings2sd_eq ( { 2291{ 2292type =8 , 2293timestamp =0 , 2294data ={ 2295n =( 'A' ): byte (), 2296f ='foo' , 2297l =2 , 2298c =200 , 2299mX =10 , 2300mYYYYYYYYYY =10 , 2301} , 2302} , 2303} , { 2304'Jump with timestamp ' .. epoch .. ':' , 2305' % Key________ Description Value' , 2306" + n name 'A'" , 2307' + f file name "foo"' , 2308' + l line number 2' , 2309' + c column 200' , 2310' + mX 10' , 2311' + mYYYYYYYYYY 10' , 2312} ) 2313end ) 2314 2315it ( 'works with buffer list items' , function () 2316strings2sd_eq ( { { type =9 , timestamp =0 , data ={ 2317a ={ 10 } , 2318} } } , { 2319'Buffer list with timestamp ' .. epoch .. ':' , 2320' # Unexpected type: map instead of array' , 2321' = {"a": [10]}' , 2322} ) 2323strings2sd_eq ( 2324{ { type =9 , timestamp =0 , data ={ 2325{ a =10 } , 2326{} , 2327} } } , 2328{ 2329'Buffer list with timestamp ' .. epoch .. ':' , 2330' # Expected array of maps' , 2331' = [{"a": 10}, []]' , 2332} 2333) 2334strings2sd_eq ( { { type =9 , timestamp =0 , data ={ 2335{ a =10 } , 2336} } } , { 2337'Buffer list with timestamp ' .. epoch .. ':' , 2338' % Key Description Value' , 2339' # Required key missing: f' , 2340' + l line number 1' , 2341' + c column 0' , 2342' + a 10' , 2343} ) 2344strings2sd_eq ( { 2345{ 2346type =9 , 2347timestamp =0 , 2348data ={ 2349{ l ='10' , c ='10' , a =10 } , 2350} , 2351} , 2352} , { 2353'Buffer list with timestamp ' .. epoch .. ':' , 2354' % Key Description Value' , 2355' # Required key missing: f' , 2356' # Expected integer' , 2357' + l line number "10"' , 2358' # Expected integer' , 2359' + c column "10"' , 2360' + a 10' , 2361} ) 2362strings2sd_eq ( 2363{ { type =9 , timestamp =0 , data ={ 2364{ l =10 , c =10 , a =10 } , 2365} } } , 2366{ 2367'Buffer list with timestamp ' .. epoch .. ':' , 2368' % Key Description Value' , 2369' # Required key missing: f' , 2370' + l line number 10' , 2371' + c column 10' , 2372' + a 10' , 2373} 2374) 2375strings2sd_eq ( 2376{ { type =9 , timestamp =0 , data ={ 2377{ l =- 10 , c =- 10 } , 2378} } } , 2379{ 2380'Buffer list with timestamp ' .. epoch .. ':' , 2381' % Key Description Value' , 2382' # Required key missing: f' , 2383' # Value is negative' , 2384' + l line number -10' , 2385' # Value is negative' , 2386' + c column -10' , 2387} 2388) 2389strings2sd_eq ( { { type =9 , timestamp =0 , data ={ 2390{ f ='abc' } , 2391} } } , { 2392'Buffer list with timestamp ' .. epoch .. ':' , 2393' % Key Description Value' , 2394' + f file name "abc"' , 2395' + l line number 1' , 2396' + c column 0' , 2397} ) 2398strings2sd_eq ( { 2399{ 2400type =9 , 2401timestamp =0 , 2402data ={ 2403{ f =10 } , 2404{ f =20 } , 2405} , 2406} , 2407} , { 2408'Buffer list with timestamp ' .. epoch .. ':' , 2409' % Key Description Value' , 2410' # Expected binary string' , 2411" + f file name '\\10'" , 2412' + l line number 1' , 2413' + c column 0' , 2414'' , 2415' % Key Description Value' , 2416' # Expected binary string' , 2417" + f file name '\\20'" , 2418' + l line number 1' , 2419' + c column 0' , 2420} ) 2421strings2sd_eq ( { 2422{ 2423type =9 , 2424timestamp =0 , 2425data ={ 2426{ f =10 } , 2427{ f ={ '!string' , { '\n' } } } , 2428} , 2429} , 2430} , { 2431'Buffer list with timestamp ' .. epoch .. ':' , 2432' % Key Description Value' , 2433' # Expected binary string' , 2434" + f file name '\\10'" , 2435' + l line number 1' , 2436' + c column 0' , 2437'' , 2438' % Key Description Value' , 2439' # Expected no NUL bytes' , 2440' + f file name "\\0"' , 2441' + l line number 1' , 2442' + c column 0' , 2443} ) 2444end ) 2445 2446it ( 'works with local mark items' , function () 2447strings2sd_eq ( 2448{ { type =10 , timestamp =0 , data ={ 24491 , 24502 , 24513 , 2452} } } , 2453{ 2454'Local mark with timestamp ' .. epoch .. ':' , 2455' # Unexpected type: array instead of map' , 2456' = [1, 2, 3]' , 2457} 2458) 2459strings2sd_eq ( { 2460{ 2461type =10 , 2462timestamp =0 , 2463data ={ 2464n =( 'A' ): byte (), 2465f ='foo' , 2466l =2 , 2467c =200 , 2468mX =10 , 2469mYYYYYYYYYY =10 , 2470} , 2471} , 2472} , { 2473'Local mark with timestamp ' .. epoch .. ':' , 2474' % Key________ Description Value' , 2475" + n name 'A'" , 2476' + f file name "foo"' , 2477' + l line number 2' , 2478' + c column 200' , 2479' + mX 10' , 2480' + mYYYYYYYYYY 10' , 2481} ) 2482end ) 2483 2484it ( 'works with change items' , function () 2485strings2sd_eq ( 2486{ { type =11 , timestamp =0 , data ={ 24871 , 24882 , 24893 , 2490} } } , 2491{ 2492'Change with timestamp ' .. epoch .. ':' , 2493' # Unexpected type: array instead of map' , 2494' = [1, 2, 3]' , 2495} 2496) 2497strings2sd_eq ( { 2498{ 2499type =11 , 2500timestamp =0 , 2501data ={ 2502n =( 'A' ): byte (), 2503f ='foo' , 2504l =2 , 2505c =200 , 2506mX =10 , 2507mYYYYYYYYYY =10 , 2508} , 2509} , 2510} , { 2511'Change with timestamp ' .. epoch .. ':' , 2512' % Key________ Description Value' , 2513" + n name 'A'" , 2514' + f file name "foo"' , 2515' + l line number 2' , 2516' + c column 200' , 2517' + mX 10' , 2518' + mYYYYYYYYYY 10' , 2519} ) 2520end ) 2521end ) 2522 2523describe ( 'function shada#get_binstrings' , function () 2524local getbstrings_eq =function ( expected , input ) 2525local result =fn [ 'shada#get_binstrings' ]( input ) 2526for i , s in ipairs ( result ) do 2527result [ i ] =s : gsub ( '\n' , '\0' ) 2528end 2529local mpack_result =table . concat ( result , '\n' ) 2530return mpack_eq ( expected , mpack_result ) 2531end 2532 2533it ( 'works' , function () 2534local version =api . nvim_get_vvar ( 'version' ) 2535getbstrings_eq ( { 2536{ 2537timestamp ='current' , 2538type =1 , 2539value ={ 2540generator ='shada.vim' , 2541version =version , 2542} , 2543} , 2544} , {} ) 2545getbstrings_eq ( { 2546{ 2547timestamp ='current' , 2548type =1 , 2549value ={ 2550generator ='shada.vim' , 2551version =version , 2552} , 2553} , 2554{ timestamp =0 , type =1 , value ={ generator ='test' } } , 2555} , { 2556'Header with timestamp ' .. epoch .. ':' , 2557' % Key______ Value' , 2558' + generator "test"' , 2559} ) 2560api . nvim_set_var ( 'shada#add_own_header' , 1 ) 2561getbstrings_eq ( { 2562{ 2563timestamp ='current' , 2564type =1 , 2565value ={ 2566generator ='shada.vim' , 2567version =version , 2568} , 2569} , 2570} , {} ) 2571getbstrings_eq ( { 2572{ 2573timestamp ='current' , 2574type =1 , 2575value ={ 2576generator ='shada.vim' , 2577version =version , 2578} , 2579} , 2580{ timestamp =0 , type =1 , value ={ generator ='test' } } , 2581} , { 2582'Header with timestamp ' .. epoch .. ':' , 2583' % Key______ Value' , 2584' + generator "test"' , 2585} ) 2586api . nvim_set_var ( 'shada#add_own_header' , 0 ) 2587getbstrings_eq ( {} , {} ) 2588getbstrings_eq ( { { timestamp =0 , type =1 , value ={ generator ='test' } } } , { 2589'Header with timestamp ' .. epoch .. ':' , 2590' % Key______ Value' , 2591' + generator "test"' , 2592} ) 2593api . nvim_set_var ( 'shada#keep_old_header' , 0 ) 2594getbstrings_eq ( {} , { 2595'Header with timestamp ' .. epoch .. ':' , 2596' % Key______ Value' , 2597' + generator "test"' , 2598} ) 2599getbstrings_eq ( { 2600{ type =3 , timestamp =0 , value ={ 'abc\ndef' } } , 2601{ type =3 , timestamp =0 , value ={ 'abc\ndef' } } , 2602{ type =3 , timestamp =0 , value ={ 'abc\ndef' } } , 2603} , { 2604'Replacement string with timestamp ' .. epoch .. ':' , 2605' @ Description__________ Value' , 2606' - :s replacement string "abc\\ndef"' , 2607'Replacement string with timestamp ' .. epoch .. ':' , 2608' @ Description__________ Value' , 2609' - :s replacement string "abc\\ndef"' , 2610'Replacement string with timestamp ' .. epoch .. ':' , 2611' @ Description__________ Value' , 2612' - :s replacement string "abc\\ndef"' , 2613} ) 2614end ) 2615end ) 2616end ) 2617 2618describe ( 'plugin/shada.vim' , function () 2619local epoch =os . date ( '%Y-%m-%dT%H:%M:%S' , 0 ) 2620local eol =t . is_os ( 'win' ) and '\r\n' or '\n' 2621before_each ( function () 2622-- Note: reset() is called explicitly in each test. 2623os . remove ( fname ) 2624os . remove ( fname .. '.tst' ) 2625os . remove ( fname_tmp ) 2626end ) 2627 2628teardown ( function () 2629os . remove ( fname ) 2630os . remove ( fname .. '.tst' ) 2631os . remove ( fname_tmp ) 2632end ) 2633 2634local shada_eq =function ( expected , fname_ ) 2635local mpack_result =read_file ( fname_ ) 2636mpack_eq ( expected , mpack_result ) 2637end 2638 2639it ( 'event BufReadCmd' , function () 2640reset () 2641wshada ( '\004\000\009\147\000\196\002ab\196\001a' ) 2642wshada_tmp ( '\004\000\009\147\000\196\002ab\196\001b' ) 2643 2644local bufread_commands =api . nvim_get_autocmds ( { group ='nvim.shada' , event ='BufReadCmd' } ) 2645eq ( 2 , # bufread_commands --[[, vim.inspect(bufread_commands) ]] ) 2646 2647-- Need to set nohidden so that the buffer containing 'fname' is not unloaded 2648-- after loading 'fname_tmp', otherwise the '++opt not supported' test below 2649-- won't work since the BufReadCmd autocmd won't be triggered. 2650nvim_command ( 'set nohidden' ) 2651 2652nvim_command ( 'edit ' .. fname ) 2653eq ( { 2654'History entry with timestamp ' .. epoch .. ':' , 2655' @ Description_ Value' , 2656' - history type CMD' , 2657' - contents "ab"' , 2658' - "a"' , 2659} , nvim_eval ( 'getline(1, "$")' )) 2660eq ( false , api . nvim_get_option_value ( 'modified' , {} )) 2661eq ( 'shada' , api . nvim_get_option_value ( 'filetype' , {} )) 2662nvim_command ( 'edit ' .. fname_tmp ) 2663eq ( { 2664'History entry with timestamp ' .. epoch .. ':' , 2665' @ Description_ Value' , 2666' - history type CMD' , 2667' - contents "ab"' , 2668' - "b"' , 2669} , nvim_eval ( 'getline(1, "$")' )) 2670eq ( false , api . nvim_get_option_value ( 'modified' , {} )) 2671eq ( 'shada' , api . nvim_get_option_value ( 'filetype' , {} )) 2672t . matches ( 2673'++opt not supported' , 2674t . pcall_err ( function () 2675nvim_command ( 'edit ++enc=latin1 ' .. fname ) 2676end ) 2677) 2678neq ( { 2679'History entry with timestamp ' .. epoch .. ':' , 2680' @ Description_ Value' , 2681' - history type CMD' , 2682' - contents "ab"' , 2683' - "a"' , 2684} , nvim_eval ( 'getline(1, "$")' )) 2685neq ( true , api . nvim_get_option_value ( 'modified' , {} )) 2686end ) 2687 2688it ( 'event FileReadCmd' , function () 2689reset () 2690wshada ( '\004\000\009\147\000\196\002ab\196\001a' ) 2691wshada_tmp ( '\004\000\009\147\000\196\002ab\196\001b' ) 2692nvim_command ( '$read ' .. fname ) 2693eq ( { 2694'' , 2695'History entry with timestamp ' .. epoch .. ':' , 2696' @ Description_ Value' , 2697' - history type CMD' , 2698' - contents "ab"' , 2699' - "a"' , 2700} , nvim_eval ( 'getline(1, "$")' )) 2701eq ( true , api . nvim_get_option_value ( 'modified' , {} )) 2702neq ( 'shada' , api . nvim_get_option_value ( 'filetype' , {} )) 2703nvim_command ( '1,$read ' .. fname_tmp ) 2704eq ( { 2705'' , 2706'History entry with timestamp ' .. epoch .. ':' , 2707' @ Description_ Value' , 2708' - history type CMD' , 2709' - contents "ab"' , 2710' - "a"' , 2711'History entry with timestamp ' .. epoch .. ':' , 2712' @ Description_ Value' , 2713' - history type CMD' , 2714' - contents "ab"' , 2715' - "b"' , 2716} , nvim_eval ( 'getline(1, "$")' )) 2717eq ( true , api . nvim_get_option_value ( 'modified' , {} )) 2718neq ( 'shada' , api . nvim_get_option_value ( 'filetype' , {} )) 2719api . nvim_set_option_value ( 'modified' , false , {} ) 2720t . matches ( 2721'++opt not supported' , 2722t . pcall_err ( function () 2723nvim_command ( '$read ++enc=latin1 ' .. fname ) 2724end ) 2725) 2726eq ( { 2727'' , 2728'History entry with timestamp ' .. epoch .. ':' , 2729' @ Description_ Value' , 2730' - history type CMD' , 2731' - contents "ab"' , 2732' - "a"' , 2733'History entry with timestamp ' .. epoch .. ':' , 2734' @ Description_ Value' , 2735' - history type CMD' , 2736' - contents "ab"' , 2737' - "b"' , 2738} , nvim_eval ( 'getline(1, "$")' )) 2739neq ( true , api . nvim_get_option_value ( 'modified' , {} )) 2740end ) 2741 2742it ( 'event BufWriteCmd' , function () 2743reset () 2744api . nvim_set_var ( 'shada#add_own_header' , 0 ) 2745api . nvim_buf_set_lines ( 0 , 0 , 1 , true , { 2746'Jump with timestamp ' .. epoch .. ':' , 2747' % Key________ Description Value' , 2748" + n name 'A'" , 2749' + f file name ["foo"]' , 2750' + l line number 2' , 2751' + c column -200' , 2752'Jump with timestamp ' .. epoch .. ':' , 2753' % Key________ Description Value' , 2754" + n name 'A'" , 2755' + f file name ["foo"]' , 2756' + l line number 2' , 2757' + c column -200' , 2758} ) 2759 2760nvim_command ( 'set cpoptions-=+' ) 2761nvim_command ( 'w ' .. fname ) 2762eq ( false , api . nvim_get_option_value ( 'modified' , {} )) 2763 2764api . nvim_set_option_value ( 'modified' , true , {} ) 2765nvim_command ( 'w ' .. fname .. '.tst' ) 2766eq ( true , api . nvim_get_option_value ( 'modified' , {} )) 2767 2768nvim_command ( 'set cpoptions+=+' ) 2769nvim_command ( 'w ' .. fname_tmp ) 2770eq ( false , api . nvim_get_option_value ( 'modified' , {} )) 2771 2772api . nvim_set_option_value ( 'modified' , true , {} ) 2773nvim_command ( 'w ' .. fname ) 2774eq ( false , api . nvim_get_option_value ( 'modified' , {} )) 2775 2776t . matches ( 2777'++opt not supported' , 2778t . pcall_err ( function () 2779nvim_command ( 'w! ++enc=latin1 ' .. fname ) 2780end ) 2781) 2782eq ( table . concat ( { 2783'Jump with timestamp ' .. epoch .. ':' , 2784' % Key________ Description Value' , 2785" + n name 'A'" , 2786' + f file name ["foo"]' , 2787' + l line number 2' , 2788' + c column -200' , 2789'Jump with timestamp ' .. epoch .. ':' , 2790' % Key________ Description Value' , 2791" + n name 'A'" , 2792' + f file name ["foo"]' , 2793' + l line number 2' , 2794' + c column -200' , 2795} , eol ) .. eol , read_file ( fname .. '.tst' )) 2796shada_eq ( { 2797{ 2798timestamp =0 , 2799type =8 , 2800value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2801} , 2802{ 2803timestamp =0 , 2804type =8 , 2805value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2806} , 2807} , fname ) 2808shada_eq ( { 2809{ 2810timestamp =0 , 2811type =8 , 2812value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2813} , 2814{ 2815timestamp =0 , 2816type =8 , 2817value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2818} , 2819} , fname_tmp ) 2820end ) 2821 2822it ( 'event FileWriteCmd' , function () 2823reset () 2824api . nvim_set_var ( 'shada#add_own_header' , 0 ) 2825api . nvim_buf_set_lines ( 0 , 0 , 1 , true , { 2826'Jump with timestamp ' .. epoch .. ':' , 2827' % Key________ Description Value' , 2828" + n name 'A'" , 2829' + f file name ["foo"]' , 2830' + l line number 2' , 2831' + c column -200' , 2832'Jump with timestamp ' .. epoch .. ':' , 2833' % Key________ Description Value' , 2834" + n name 'A'" , 2835' + f file name ["foo"]' , 2836' + l line number 2' , 2837' + c column -200' , 2838} ) 2839nvim_command ( '1,3w ' .. fname .. '.tst' ) 2840nvim_command ( '1,3w ' .. fname ) 2841nvim_command ( '1,3w ' .. fname_tmp ) 2842t . matches ( 2843'++opt not supported' , 2844t . pcall_err ( function () 2845nvim_command ( '1,3w! ++enc=latin1 ' .. fname ) 2846end ) 2847) 2848eq ( table . concat ( { 2849'Jump with timestamp ' .. epoch .. ':' , 2850' % Key________ Description Value' , 2851" + n name 'A'" , 2852} , eol ) .. eol , read_file ( fname .. '.tst' )) 2853shada_eq ( 2854{ { 2855timestamp =0 , 2856type =8 , 2857value ={ n =( 'A' ): byte () } , 2858} } , 2859fname 2860) 2861shada_eq ( 2862{ { 2863timestamp =0 , 2864type =8 , 2865value ={ n =( 'A' ): byte () } , 2866} } , 2867fname_tmp 2868) 2869end ) 2870 2871it ( 'event FileAppendCmd' , function () 2872reset () 2873api . nvim_set_var ( 'shada#add_own_header' , 0 ) 2874api . nvim_buf_set_lines ( 0 , 0 , 1 , true , { 2875'Jump with timestamp ' .. epoch .. ':' , 2876' % Key________ Description Value' , 2877" + n name 'A'" , 2878' + f file name ["foo"]' , 2879' + l line number 2' , 2880' + c column -200' , 2881'Jump with timestamp ' .. epoch .. ':' , 2882' % Key________ Description Value' , 2883" + n name 'A'" , 2884' + f file name ["foo"]' , 2885' + l line number 2' , 2886' + c column -200' , 2887} ) 2888fn . writefile ( { '' } , fname .. '.tst' , 'b' ) 2889fn . writefile ( { '' } , fname , 'b' ) 2890fn . writefile ( { '' } , fname_tmp , 'b' ) 2891nvim_command ( '1,3w >> ' .. fname .. '.tst' ) 2892nvim_command ( '1,3w >> ' .. fname ) 2893nvim_command ( '1,3w >> ' .. fname_tmp ) 2894nvim_command ( 'w >> ' .. fname .. '.tst' ) 2895nvim_command ( 'w >> ' .. fname ) 2896nvim_command ( 'w >> ' .. fname_tmp ) 2897t . matches ( 2898'++opt not supported' , 2899t . pcall_err ( function () 2900nvim_command ( '1,3w! ++enc=latin1 >> ' .. fname ) 2901end ) 2902) 2903eq ( table . concat ( { 2904'Jump with timestamp ' .. epoch .. ':' , 2905' % Key________ Description Value' , 2906" + n name 'A'" , 2907'Jump with timestamp ' .. epoch .. ':' , 2908' % Key________ Description Value' , 2909" + n name 'A'" , 2910' + f file name ["foo"]' , 2911' + l line number 2' , 2912' + c column -200' , 2913'Jump with timestamp ' .. epoch .. ':' , 2914' % Key________ Description Value' , 2915" + n name 'A'" , 2916' + f file name ["foo"]' , 2917' + l line number 2' , 2918' + c column -200' , 2919} , eol ) .. eol , read_file ( fname .. '.tst' )) 2920shada_eq ( { 2921{ 2922timestamp =0 , 2923type =8 , 2924value ={ n =( 'A' ): byte () } , 2925} , 2926{ 2927timestamp =0 , 2928type =8 , 2929value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2930} , 2931{ 2932timestamp =0 , 2933type =8 , 2934value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2935} , 2936} , fname ) 2937shada_eq ( { 2938{ 2939timestamp =0 , 2940type =8 , 2941value ={ n =( 'A' ): byte () } , 2942} , 2943{ 2944timestamp =0 , 2945type =8 , 2946value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2947} , 2948{ 2949timestamp =0 , 2950type =8 , 2951value ={ c =- 200 , f ={ 'foo' } , l =2 , n =( 'A' ): byte () } , 2952} , 2953} , fname_tmp ) 2954end ) 2955 2956it ( 'event SourceCmd' , function () 2957reset ( fname ) 2958finally ( function () 2959nvim_command ( 'set shadafile=NONE' ) -- Avoid writing shada file on exit 2960end ) 2961wshada ( '\004\000\006\146\000\196\002ab' ) 2962wshada_tmp ( '\004\001\006\146\000\196\002bc' ) 2963nvim_command ( 'source ' .. fname ) 2964nvim_command ( 'source ' .. fname_tmp ) 2965eq ( 'bc' , fn . histget ( ':' , - 1 )) 2966eq ( 'ab' , fn . histget ( ':' , - 2 )) 2967end ) 2968end ) 2969 2970describe ( 'ftplugin/shada.vim' , function () 2971local epoch =os . date ( '%Y-%m-%dT%H:%M:%S' , 0 ) 2972before_each ( reset ) 2973 2974it ( 'sets indentexpr correctly' , function () 2975nvim_command ( 'filetype plugin indent on' ) 2976nvim_command ( 'setlocal filetype=shada' ) 2977fn . setline ( 1 , { 2978'Jump with timestamp ' .. epoch .. ':' , 2979'% Key________ Description Value' , 2980"+ n name 'A'" , 2981'+ f file name "foo"' , 2982'+ l line number 2' , 2983'+ c column 200' , 2984'+ mX 10' , 2985'+ mYYYYYYYYYY 10' , 2986'Register with timestamp ' .. epoch .. ':' , 2987'% Key Description Value' , 2988"+ n name ' '" , 2989'+ rc contents @' , 2990'| - "abcdefghijklmnopqrstuvwxyz"' , 2991'| - "abcdefghijklmnopqrstuvwxyz"' , 2992'+ rw block width 0' , 2993'+ rt type CHARACTERWISE' , 2994'Replacement string with timestamp ' .. epoch .. ':' , 2995' @ Description__________ Value' , 2996' - :s replacement string "abc\\ndef"' , 2997' Buffer list with timestamp ' .. epoch .. ':' , 2998' # Expected array of maps' , 2999'= [{"a": 10}, []]' , 3000' Buffer list with timestamp ' .. epoch .. ':' , 3001' % Key Description Value' , 3002' # Expected binary string' , 3003'+ f file name 10' , 3004' + l line number 1' , 3005' + c column 0' , 3006'' , 3007' % Key Description Value' , 3008' # Expected binary string' , 3009' + f file name 20' , 3010'+ l line number 1' , 3011' + c column 0' , 3012} ) 3013nvim_command ( 'normal! gg=G' ) 3014eq ( { 3015'Jump with timestamp ' .. epoch .. ':' , 3016' % Key________ Description Value' , 3017" + n name 'A'" , 3018' + f file name "foo"' , 3019' + l line number 2' , 3020' + c column 200' , 3021' + mX 10' , 3022' + mYYYYYYYYYY 10' , 3023'Register with timestamp ' .. epoch .. ':' , 3024' % Key Description Value' , 3025" + n name ' '" , 3026' + rc contents @' , 3027' | - "abcdefghijklmnopqrstuvwxyz"' , 3028' | - "abcdefghijklmnopqrstuvwxyz"' , 3029' + rw block width 0' , 3030' + rt type CHARACTERWISE' , 3031'Replacement string with timestamp ' .. epoch .. ':' , 3032' @ Description__________ Value' , 3033' - :s replacement string "abc\\ndef"' , 3034'Buffer list with timestamp ' .. epoch .. ':' , 3035' # Expected array of maps' , 3036' = [{"a": 10}, []]' , 3037'Buffer list with timestamp ' .. epoch .. ':' , 3038' % Key Description Value' , 3039' # Expected binary string' , 3040' + f file name 10' , 3041' + l line number 1' , 3042' + c column 0' , 3043'' , 3044' % Key Description Value' , 3045' # Expected binary string' , 3046' + f file name 20' , 3047' + l line number 1' , 3048' + c column 0' , 3049} , fn . getline ( 1 , fn . line ( '$' ))) 3050end ) 3051 3052it ( 'sets options correctly' , function () 3053nvim_command ( 'filetype plugin indent on' ) 3054nvim_command ( 'setlocal filetype=shada' ) 3055eq ( true , api . nvim_get_option_value ( 'expandtab' , {} )) 3056eq ( 2 , api . nvim_get_option_value ( 'tabstop' , {} )) 3057eq ( 2 , api . nvim_get_option_value ( 'softtabstop' , {} )) 3058eq ( 2 , api . nvim_get_option_value ( 'shiftwidth' , {} )) 3059end ) 3060 3061it ( 'sets indentkeys correctly' , function () 3062nvim_command ( 'filetype plugin indent on' ) 3063nvim_command ( 'setlocal filetype=shada' ) 3064fn . setline ( 1 , ' Replacement with timestamp ' .. epoch ) 3065nvim_feed ( 'ggA:\027' ) 3066eq ( 'Replacement with timestamp ' .. epoch .. ':' , api . nvim_buf_get_lines ( 0 , 0 , 1 , true )[ 1 ]) 3067nvim_feed ( 'o-\027' ) 3068eq ( { ' -' } , api . nvim_buf_get_lines ( 0 , 1 , 2 , true )) 3069nvim_feed ( 'ggO+\027' ) 3070eq ( { '+' } , api . nvim_buf_get_lines ( 0 , 0 , 1 , true )) 3071nvim_feed ( 'GO*\027' ) 3072eq ( { ' *' } , api . nvim_buf_get_lines ( 0 , 2 , 3 , true )) 3073nvim_feed ( 'ggO /\027' ) 3074eq ( { ' /' } , api . nvim_buf_get_lines ( 0 , 0 , 1 , true )) 3075nvim_feed ( 'ggOx\027' ) 3076eq ( { 'x' } , api . nvim_buf_get_lines ( 0 , 0 , 1 , true )) 3077end ) 3078end ) 3079 3080describe ( 'syntax/shada.vim' , function () 3081local epoch =os . date ( '!%Y-%m-%dT%H:%M:%S' , 0 ) 3082before_each ( reset ) 3083 3084it ( 'works' , function () 3085nvim_command ( 'syntax on' ) 3086nvim_command ( 'setlocal syntax=shada' ) 3087nvim_command ( 'set laststatus&' ) 3088local screen =Screen . new ( 60 , 37 ) 3089screen : set_default_attr_ids { 3090[ 1 ] ={ bold =true , foreground =Screen . colors . Brown } , 3091[ 2 ] ={ foreground =tonumber ( '0x6a0dad' ) } , 3092[ 3 ] ={ foreground =Screen . colors . Fuchsia } , 3093[ 4 ] ={ foreground =Screen . colors . Blue1 } , 3094[ 5 ] ={ bold =true , foreground =Screen . colors . SeaGreen4 } , 3095[ 6 ] ={ foreground =Screen . colors . SlateBlue } , 3096[ 7 ] ={ bold =true , reverse =true } , 3097[ 8 ] ={ bold =true , foreground =Screen . colors . Blue } , 3098} 3099 3100api . nvim_buf_set_lines ( 0 , 0 , 1 , true , { 3101'Header with timestamp ' .. epoch .. ':' , 3102' % Key Value' , 3103' + t "test"' , 3104'Jump with timestamp ' .. epoch .. ':' , 3105' % Key________ Description Value' , 3106" + n name 'A'" , 3107' + f file name ["foo"]' , 3108' + l line number 2' , 3109' + c column -200' , 3110'Register with timestamp ' .. epoch .. ':' , 3111' % Key Description Value' , 3112' + rc contents @' , 3113' | - {"abcdefghijklmnopqrstuvwxyz": 1.0}' , 3114' + rt type CHARACTERWISE' , 3115' + rt type LINEWISE' , 3116' + rt type BLOCKWISE' , 3117'Replacement string with timestamp ' .. epoch .. ':' , 3118' @ Description__________ Value' , 3119' - :s replacement string CMD' , 3120' - :s replacement string SEARCH' , 3121' - :s replacement string EXPR' , 3122' - :s replacement string INPUT' , 3123' - :s replacement string DEBUG' , 3124'Buffer list with timestamp ' .. epoch .. ':' , 3125' # Expected array of maps' , 3126' = [{"a": +(10)"ac\\0df\\ngi\\"tt\\.", TRUE: FALSE}, [NIL, +(-10)""]]' , 3127'Buffer list with timestamp ' .. epoch .. ':' , 3128' % Key Description Value' , 3129'' , 3130' % Key Description Value' , 3131'Header with timestamp ' .. epoch .. ':' , 3132' % Key Description________ Value' , 3133' + se place cursor at end TRUE' , 3134} ) 3135screen : expect { 3136grid =[=[ 3137{1:^Header} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: | 3138{2: % Key Value} | 3139{1: +} {3:t } {1:"}{3:test}{1:"} | 3140{1:Jump} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: | 3141{2: % Key________ Description Value} | 3142{1: +} {3:n } {4:name } {3:'A'} | 3143{1: +} {3:f } {4:file name } {1:["}{3:foo}{1:"]} | 3144{1: +} {3:l } {4:line number} {3:2} | 3145{1: +} {3:c } {4:column } {3:-200} | 3146{1:Register} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: | 3147{2: % Key Description Value} | 3148{1: +} {3:rc } {4:contents } {1:@} | 3149{1: | -} {1:{"}{3:abcdefghijklmnopqrstuvwxyz}{1:":} {3:1.0}{1:}} | 3150{1: +} {3:rt } {4:type } {1:CHARACTERWISE} | 3151{1: +} {3:rt } {4:type } {1:LINEWISE} | 3152{1: +} {3:rt } {4:type } {1:BLOCKWISE} | 3153{1:Replacement string} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: | 3154{2: @ Description__________ Value} | 3155{1: -} {4::s replacement string} {1:CMD} | 3156{1: -} {4::s replacement string} {1:SEARCH} | 3157{1: -} {4::s replacement string} {1:EXPR} | 3158{1: -} {4::s replacement string} {1:INPUT} | 3159{1: -} {4::s replacement string} {1:DEBUG} | 3160{1:Buffer list} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: | 3161{4: # Expected array of maps} | 3162= {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}| 3163{5:0}{1:)""]]} | 3164{1:Buffer list} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: | 3165{2: % Key Description Value} | 3166| 3167{2: % Key Description Value} | 3168{1:Header} with timestamp 1970{1:-}01{1:-}01{1:T}00{1::}00{1::}00: | 3169{2: % Key Description________ Value} | 3170{1: +} {3:se } {4:place cursor at end} {1:TRUE} | 3171{8:~ }| 3172{7:[No Name] [+] }| 3173| 3174]=] , 3175} 3176 3177nvim_command ( [[ 3178function GetSyntax() 3179let lines = [] 3180for l in range(1, line('$')) 3181let columns = [] 3182let line = getline(l) 3183for c in range(1, col([l, '$']) - 1) 3184let synstack = map(synstack(l, c), 'synIDattr(v:val, "name")') 3185if !empty(columns) && columns[-1][0] ==# synstack 3186let columns[-1][1] .= line[c - 1] 3187else 3188call add(columns, [ synstack, line[c - 1] ]) 3189endif 3190endfor 3191call add(lines, columns) 3192endfor 3193return lines 3194endfunction 3195]] ) 3196local hname =function ( s ) 3197return { { 'ShaDaEntryHeader' , 'ShaDaEntryName' } , s } 3198end 3199local h =function ( s ) 3200return { { 'ShaDaEntryHeader' } , s } 3201end 3202local htsnum =function ( s ) 3203return { 3204{ 'ShaDaEntryHeader' , 'ShaDaEntryTimestamp' , 'ShaDaEntryTimestampNumber' } , 3205s , 3206} 3207end 3208local synhtssep =function ( s ) 3209return { { 'ShaDaEntryHeader' , 'ShaDaEntryTimestamp' } , s } 3210end 3211local synepoch ={ 3212year =htsnum ( os . date ( '!%Y' , 0 )), 3213month =htsnum ( os . date ( '!%m' , 0 )), 3214day =htsnum ( os . date ( '!%d' , 0 )), 3215hour =htsnum ( os . date ( '!%H' , 0 )), 3216minute =htsnum ( os . date ( '!%M' , 0 )), 3217second =htsnum ( os . date ( '!%S' , 0 )), 3218} 3219local msh =function ( s ) 3220return { 3221{ 'ShaDaEntryMapShort' , 'ShaDaEntryMapHeader' } , 3222s , 3223} 3224end 3225local mlh =function ( s ) 3226return { { 'ShaDaEntryMapLong' , 'ShaDaEntryMapHeader' } , s } 3227end 3228local ah =function ( s ) 3229return { { 'ShaDaEntryArray' , 'ShaDaEntryArrayHeader' } , s } 3230end 3231-- luacheck: ignore 3232local mses =function ( s ) 3233return { 3234{ 3235'ShaDaEntryMapShort' , 3236'ShaDaEntryMapShortEntryStart' , 3237} , 3238s , 3239} 3240end 3241local mles =function ( s ) 3242return { 3243{ 'ShaDaEntryMapLong' , 'ShaDaEntryMapLongEntryStart' } , 3244s , 3245} 3246end 3247local act =fn . GetSyntax () 3248local ms =function ( syn ) 3249return { 3250{ 'ShaDaEntryMap' .. syn , 'ShaDaEntryMap' .. syn .. 'EntryStart' } , 3251' + ' , 3252} 3253end 3254local as =function () 3255return { { 'ShaDaEntryArray' , 'ShaDaEntryArrayEntryStart' } , ' - ' } 3256end 3257local ad =function ( s ) 3258return { 3259{ 'ShaDaEntryArray' , 'ShaDaEntryArrayDescription' } , 3260s , 3261} 3262end 3263local mbas =function ( syn ) 3264return { 3265{ 'ShaDaEntryMap' .. syn , 'ShaDaEntryMapBinArrayStart' } , 3266' | - ' , 3267} 3268end 3269local msk =function ( s ) 3270return { 3271{ 'ShaDaEntryMapShort' , 'ShaDaEntryMapShortKey' } , 3272s , 3273} 3274end 3275local mlk =function ( s ) 3276return { 3277{ 'ShaDaEntryMapLong' , 'ShaDaEntryMapLongKey' } , 3278s , 3279} 3280end 3281local mld =function ( s ) 3282return { 3283{ 'ShaDaEntryMapLong' , 'ShaDaEntryMapLongDescription' } , 3284s , 3285} 3286end 3287local c =function ( s ) 3288return { { 'ShaDaComment' } , s } 3289end 3290local exp ={ 3291{ 3292hname ( 'Header' ), 3293h ( ' with timestamp ' ), 3294synepoch . year , 3295synhtssep ( '-' ), 3296synepoch . month , 3297synhtssep ( '-' ), 3298synepoch . day , 3299synhtssep ( 'T' ), 3300synepoch . hour , 3301synhtssep ( ':' ), 3302synepoch . minute , 3303synhtssep ( ':' ), 3304synepoch . second , 3305h ( ':' ), 3306} , 3307{ 3308msh ( ' % Key Value' ), 3309} , 3310{ 3311ms ( 'Short' ), 3312msk ( 't ' ), 3313{ 3314{ 'ShaDaEntryMapShort' , 'ShaDaMsgpackBinaryString' , 'ShaDaMsgpackStringQuotes' } , 3315'"' , 3316} , 3317{ { 'ShaDaEntryMapShort' , 'ShaDaMsgpackBinaryString' } , 'test' } , 3318{ { 'ShaDaEntryMapShort' , 'ShaDaMsgpackStringQuotes' } , '"' } , 3319} , 3320{ 3321hname ( 'Jump' ), 3322h ( ' with timestamp ' ), 3323synepoch . year , 3324synhtssep ( '-' ), 3325synepoch . month , 3326synhtssep ( '-' ), 3327synepoch . day , 3328synhtssep ( 'T' ), 3329synepoch . hour , 3330synhtssep ( ':' ), 3331synepoch . minute , 3332synhtssep ( ':' ), 3333synepoch . second , 3334h ( ':' ), 3335} , 3336{ 3337mlh ( ' % Key________ Description Value' ), 3338} , 3339{ 3340ms ( 'Long' ), 3341mlk ( 'n ' ), 3342mld ( 'name ' ), 3343{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackCharacter' } , "'A'" } , 3344} , 3345{ 3346ms ( 'Long' ), 3347mlk ( 'f ' ), 3348mld ( 'file name ' ), 3349{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackArrayBraces' } , '[' } , 3350{ 3351{ 3352'ShaDaEntryMapLong' , 3353'ShaDaMsgpackArray' , 3354'ShaDaMsgpackBinaryString' , 3355'ShaDaMsgpackStringQuotes' , 3356} , 3357'"' , 3358} , 3359{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackBinaryString' } , 'foo' } , 3360{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackStringQuotes' } , '"' } , 3361{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackArrayBraces' } , ']' } , 3362} , 3363{ 3364ms ( 'Long' ), 3365mlk ( 'l ' ), 3366mld ( 'line number ' ), 3367{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackInteger' } , '2' } , 3368} , 3369{ 3370ms ( 'Long' ), 3371mlk ( 'c ' ), 3372mld ( 'column ' ), 3373{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackInteger' } , '-200' } , 3374} , 3375{ 3376hname ( 'Register' ), 3377h ( ' with timestamp ' ), 3378synepoch . year , 3379synhtssep ( '-' ), 3380synepoch . month , 3381synhtssep ( '-' ), 3382synepoch . day , 3383synhtssep ( 'T' ), 3384synepoch . hour , 3385synhtssep ( ':' ), 3386synepoch . minute , 3387synhtssep ( ':' ), 3388synepoch . second , 3389h ( ':' ), 3390} , 3391{ 3392mlh ( ' % Key Description Value' ), 3393} , 3394{ 3395ms ( 'Long' ), 3396mlk ( 'rc ' ), 3397mld ( 'contents ' ), 3398{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackMultilineArray' } , '@' } , 3399} , 3400{ 3401mbas ( 'Long' ), 3402{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackMapBraces' } , '{' } , 3403{ 3404{ 3405'ShaDaEntryMapLong' , 3406'ShaDaMsgpackMap' , 3407'ShaDaMsgpackBinaryString' , 3408'ShaDaMsgpackStringQuotes' , 3409} , 3410'"' , 3411} , 3412{ 3413{ 'ShaDaEntryMapLong' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackBinaryString' } , 3414'abcdefghijklmnopqrstuvwxyz' , 3415} , 3416{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackStringQuotes' } , '"' } , 3417{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackColon' } , ':' } , 3418{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackMap' } , ' ' } , 3419{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackFloat' } , '1.0' } , 3420{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackMapBraces' } , '}' } , 3421} , 3422{ 3423ms ( 'Long' ), 3424mlk ( 'rt ' ), 3425mld ( 'type ' ), 3426{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackShaDaKeyword' } , 'CHARACTERWISE' } , 3427} , 3428{ 3429ms ( 'Long' ), 3430mlk ( 'rt ' ), 3431mld ( 'type ' ), 3432{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackShaDaKeyword' } , 'LINEWISE' } , 3433} , 3434{ 3435ms ( 'Long' ), 3436mlk ( 'rt ' ), 3437mld ( 'type ' ), 3438{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackShaDaKeyword' } , 'BLOCKWISE' } , 3439} , 3440{ 3441hname ( 'Replacement string' ), 3442h ( ' with timestamp ' ), 3443synepoch . year , 3444synhtssep ( '-' ), 3445synepoch . month , 3446synhtssep ( '-' ), 3447synepoch . day , 3448synhtssep ( 'T' ), 3449synepoch . hour , 3450synhtssep ( ':' ), 3451synepoch . minute , 3452synhtssep ( ':' ), 3453synepoch . second , 3454h ( ':' ), 3455} , 3456{ 3457ah ( ' @ Description__________ Value' ), 3458} , 3459{ 3460as (), 3461ad ( ':s replacement string ' ), 3462{ { 'ShaDaEntryArray' , 'ShaDaMsgpackShaDaKeyword' } , 'CMD' } , 3463} , 3464{ 3465as (), 3466ad ( ':s replacement string ' ), 3467{ { 'ShaDaEntryArray' , 'ShaDaMsgpackShaDaKeyword' } , 'SEARCH' } , 3468} , 3469{ 3470as (), 3471ad ( ':s replacement string ' ), 3472{ { 'ShaDaEntryArray' , 'ShaDaMsgpackShaDaKeyword' } , 'EXPR' } , 3473} , 3474{ 3475as (), 3476ad ( ':s replacement string ' ), 3477{ { 'ShaDaEntryArray' , 'ShaDaMsgpackShaDaKeyword' } , 'INPUT' } , 3478} , 3479{ 3480as (), 3481ad ( ':s replacement string ' ), 3482{ { 'ShaDaEntryArray' , 'ShaDaMsgpackShaDaKeyword' } , 'DEBUG' } , 3483} , 3484{ 3485hname ( 'Buffer list' ), 3486h ( ' with timestamp ' ), 3487synepoch . year , 3488synhtssep ( '-' ), 3489synepoch . month , 3490synhtssep ( '-' ), 3491synepoch . day , 3492synhtssep ( 'T' ), 3493synepoch . hour , 3494synhtssep ( ':' ), 3495synepoch . minute , 3496synhtssep ( ':' ), 3497synepoch . second , 3498h ( ':' ), 3499} , 3500{ 3501c ( ' # Expected array of maps' ), 3502} , 3503{ 3504{ { 'ShaDaEntryRawMsgpack' } , ' = ' } , 3505{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArrayBraces' } , '[' } , 3506{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackMapBraces' } , '{' } , 3507{ 3508{ 3509'ShaDaMsgpackArray' , 3510'ShaDaMsgpackMap' , 3511'ShaDaMsgpackBinaryString' , 3512'ShaDaMsgpackStringQuotes' , 3513} , 3514'"' , 3515} , 3516{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackBinaryString' } , 'a' } , 3517{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackStringQuotes' } , '"' } , 3518{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackColon' } , ':' } , 3519{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' } , ' ' } , 3520{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackExt' } , '+(' } , 3521{ 3522{ 3523'ShaDaMsgpackArray' , 3524'ShaDaMsgpackMap' , 3525'ShaDaMsgpackExt' , 3526'ShaDaMsgpackExtType' , 3527} , 3528'10' , 3529} , 3530{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackExt' } , ')' } , 3531{ 3532{ 3533'ShaDaMsgpackArray' , 3534'ShaDaMsgpackMap' , 3535'ShaDaMsgpackBinaryString' , 3536'ShaDaMsgpackStringQuotes' , 3537} , 3538'"' , 3539} , 3540{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackBinaryString' } , 'ac' } , 3541{ 3542{ 3543'ShaDaMsgpackArray' , 3544'ShaDaMsgpackMap' , 3545'ShaDaMsgpackBinaryString' , 3546'ShaDaMsgpackBinaryStringEscape' , 3547} , 3548'\\0' , 3549} , 3550{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackBinaryString' } , 'df' } , 3551{ 3552{ 3553'ShaDaMsgpackArray' , 3554'ShaDaMsgpackMap' , 3555'ShaDaMsgpackBinaryString' , 3556'ShaDaMsgpackBinaryStringEscape' , 3557} , 3558'\\n' , 3559} , 3560{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackBinaryString' } , 'gi' } , 3561{ 3562{ 3563'ShaDaMsgpackArray' , 3564'ShaDaMsgpackMap' , 3565'ShaDaMsgpackBinaryString' , 3566'ShaDaMsgpackBinaryStringEscape' , 3567} , 3568'\\"' , 3569} , 3570{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackBinaryString' } , 'tt\\.' } , 3571{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackStringQuotes' } , '"' } , 3572{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackComma' } , ',' } , 3573{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' } , ' ' } , 3574{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackKeyword' } , 'TRUE' } , 3575{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackColon' } , ':' } , 3576{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' } , ' ' } , 3577{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMap' , 'ShaDaMsgpackKeyword' } , 'FALSE' } , 3578{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackMapBraces' } , '}' } , 3579{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackComma' } , ',' } , 3580{ { 'ShaDaMsgpackArray' } , ' ' } , 3581{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackArrayBraces' } , '[' } , 3582{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackKeyword' } , 'NIL' } , 3583{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackComma' } , ',' } , 3584{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArray' } , ' ' } , 3585{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackExt' } , '+(' } , 3586{ 3587{ 3588'ShaDaMsgpackArray' , 3589'ShaDaMsgpackArray' , 3590'ShaDaMsgpackExt' , 3591'ShaDaMsgpackExtType' , 3592} , 3593'-10' , 3594} , 3595{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackExt' } , ')' } , 3596{ 3597{ 3598'ShaDaMsgpackArray' , 3599'ShaDaMsgpackArray' , 3600'ShaDaMsgpackBinaryString' , 3601'ShaDaMsgpackStringQuotes' , 3602} , 3603'"' , 3604} , 3605{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArray' , 'ShaDaMsgpackStringQuotes' } , '"' } , 3606{ { 'ShaDaMsgpackArray' , 'ShaDaMsgpackArrayBraces' } , ']' } , 3607{ { 'ShaDaMsgpackArrayBraces' } , ']' } , 3608} , 3609{ 3610hname ( 'Buffer list' ), 3611h ( ' with timestamp ' ), 3612synepoch . year , 3613synhtssep ( '-' ), 3614synepoch . month , 3615synhtssep ( '-' ), 3616synepoch . day , 3617synhtssep ( 'T' ), 3618synepoch . hour , 3619synhtssep ( ':' ), 3620synepoch . minute , 3621synhtssep ( ':' ), 3622synepoch . second , 3623h ( ':' ), 3624} , 3625{ 3626mlh ( ' % Key Description Value' ), 3627} , 3628{} , 3629{ 3630mlh ( ' % Key Description Value' ), 3631} , 3632{ 3633hname ( 'Header' ), 3634h ( ' with timestamp ' ), 3635synepoch . year , 3636synhtssep ( '-' ), 3637synepoch . month , 3638synhtssep ( '-' ), 3639synepoch . day , 3640synhtssep ( 'T' ), 3641synepoch . hour , 3642synhtssep ( ':' ), 3643synepoch . minute , 3644synhtssep ( ':' ), 3645synepoch . second , 3646h ( ':' ), 3647} , 3648{ 3649mlh ( ' % Key Description________ Value' ), 3650} , 3651{ 3652mles ( ' + ' ), 3653mlk ( 'se ' ), 3654mld ( 'place cursor at end ' ), 3655{ { 'ShaDaEntryMapLong' , 'ShaDaMsgpackKeyword' } , 'TRUE' } , 3656} , 3657} 3658eq ( exp , act ) 3659end ) 3660end )