@@ -20,7 +20,7 @@ def s:ScriptFuncLoad(arg: string)
2020 echo @z
2121enddef
2222
23- def Test_disassembleLoad ()
23+ def Test_disassemble_load ()
2424 assert_fails (' disass NoFunc' , ' E1061:' )
2525 assert_fails (' disass NotCompiled' , ' E1062:' )
2626
@@ -47,7 +47,7 @@ def s:ScriptFuncPush()
4747 endif
4848enddef
4949
50- def Test_disassemblePush ()
50+ def Test_disassemble_push ()
5151 let res = execute (' disass s:ScriptFuncPush' )
5252 assert_match (' <SNR>\d*_ScriptFuncPush.*'
5353 \ .. ' localbool = true.*'
@@ -78,7 +78,7 @@ def s:ScriptFuncStore()
7878 @z = ' rv'
7979enddef
8080
81- def Test_disassembleStore ()
81+ def Test_disassemble_store ()
8282 let res = execute (' disass s:ScriptFuncStore' )
8383 assert_match (' <SNR>\d*_ScriptFuncStore.*'
8484 \ .. ' localnr = 2.*'
@@ -110,7 +110,7 @@ def s:ScriptFuncTry()
110110 endtry
111111enddef
112112
113- def Test_disassembleTry ()
113+ def Test_disassemble_try ()
114114 let res = execute (' disass s:ScriptFuncTry' )
115115 assert_match (' <SNR>\d*_ScriptFuncTry.*'
116116 \ .. ' try.*'
@@ -135,7 +135,7 @@ def s:ScriptFuncNew()
135135 let dd = #{one: 1 , two: " val" }
136136enddef
137137
138- def Test_disassembleNew ()
138+ def Test_disassemble_new ()
139139 let res = execute (' disass s:ScriptFuncNew' )
140140 assert_match (' <SNR>\d*_ScriptFuncNew.*'
141141 \ .. ' let ll = \[1, "two", 333].*'
@@ -167,7 +167,7 @@ endfunc
167167def s: ScriptFuncCall (): string
168168 changenr ()
169169 char2nr (" abc" )
170- Test_disassembleNew ()
170+ Test_disassemble_new ()
171171 FuncWithArg (343 )
172172 ScriptFuncNew ()
173173 s: ScriptFuncNew ()
@@ -180,16 +180,16 @@ def s:ScriptFuncCall(): string
180180 return " yes"
181181enddef
182182
183- def Test_disassembleCall ()
183+ def Test_disassemble_call ()
184184 let res = execute (' disass s:ScriptFuncCall' )
185185 assert_match (' <SNR>\d\+_ScriptFuncCall.*'
186186 \ .. ' changenr().*'
187187 \ .. ' BCALL changenr(argc 0).*'
188188 \ .. ' char2nr("abc").*'
189189 \ .. ' PUSHS "abc".*'
190190 \ .. ' BCALL char2nr(argc 1).*'
191- \ .. ' Test_disassembleNew ().*'
192- \ .. ' DCALL Test_disassembleNew (argc 0).*'
191+ \ .. ' Test_disassemble_new ().*'
192+ \ .. ' DCALL Test_disassemble_new (argc 0).*'
193193 \ .. ' FuncWithArg(343).*'
194194 \ .. ' PUSHNR 343.*'
195195 \ .. ' DCALL FuncWithArg(argc 1).*'
@@ -245,7 +245,7 @@ def HasSomething()
245245 endif
246246enddef
247247
248- def Test_compile_const_expr ()
248+ def Test_disassemble_const_expr ()
249249 assert_equal (" \n yes" , execute (' call HasEval()' ))
250250 let instr = execute (' disassemble HasEval' )
251251 assert_match (' HasEval.*'
@@ -284,7 +284,7 @@ def WithLambda(): string
284284 return F (" x" )
285285enddef
286286
287- def Test_compile_lambda ()
287+ def Test_disassemble_lambda ()
288288 assert_equal (" XxX" , WithLambda ())
289289 let instr = execute (' disassemble WithLambda' )
290290 assert_match (' WithLambda.*'
@@ -304,7 +304,7 @@ def AndOr(arg): string
304304 return ' no'
305305enddef
306306
307- def Test_compile_and_or ()
307+ def Test_disassemble_and_or ()
308308 assert_equal (" yes" , AndOr (1 ))
309309 assert_equal (" no" , AndOr (2 ))
310310 assert_equal (" yes" , AndOr (4 ))
@@ -334,7 +334,7 @@ def ForLoop(): list<number>
334334 return res
335335enddef
336336
337- def Test_compile_for_loop ()
337+ def Test_disassemble_for_loop ()
338338 assert_equal ([0 , 1 , 2 ], ForLoop ())
339339 let instr = execute (' disassemble ForLoop' )
340340 assert_match (' ForLoop.*'
@@ -383,7 +383,7 @@ def Computing()
383383 endif
384384enddef
385385
386- def Test_computing ()
386+ def Test_disassemble_computing ()
387387 let instr = execute (' disassemble Computing' )
388388 assert_match (' Computing.*'
389389 \ .. ' let nr = 3.*'
@@ -435,4 +435,99 @@ def Test_computing()
435435 endif
436436enddef
437437
438+ def Test_disassemble_compare ()
439+ " TODO: COMPAREFUNC
440+ let cases = [
441+ \ [' true == false' , ' COMPAREBOOL ==' ],
442+ \ [' true != false' , ' COMPAREBOOL !=' ],
443+ \ [' v:none == v:null' , ' COMPARESPECIAL ==' ],
444+ \ [' v:none != v:null' , ' COMPARESPECIAL !=' ],
445+ \
446+ \ [' 111 == 222' , ' COMPARENR ==' ],
447+ \ [' 111 != 222' , ' COMPARENR !=' ],
448+ \ [' 111 > 222' , ' COMPARENR >' ],
449+ \ [' 111 < 222' , ' COMPARENR <' ],
450+ \ [' 111 >= 222' , ' COMPARENR >=' ],
451+ \ [' 111 <= 222' , ' COMPARENR <=' ],
452+ \ [' 111 =~ 222' , ' COMPARENR =\~' ],
453+ \ [' 111 !~ 222' , ' COMPARENR !\~' ],
454+ \
455+ \ [' "xx" == "yy"' , ' COMPARESTRING ==' ],
456+ \ [' "xx" != "yy"' , ' COMPARESTRING !=' ],
457+ \ [' "xx" > "yy"' , ' COMPARESTRING >' ],
458+ \ [' "xx" < "yy"' , ' COMPARESTRING <' ],
459+ \ [' "xx" >= "yy"' , ' COMPARESTRING >=' ],
460+ \ [' "xx" <= "yy"' , ' COMPARESTRING <=' ],
461+ \ [' "xx" =~ "yy"' , ' COMPARESTRING =\~' ],
462+ \ [' "xx" !~ "yy"' , ' COMPARESTRING !\~' ],
463+ \ [' "xx" is "yy"' , ' COMPARESTRING is' ],
464+ \ [' "xx" isnot "yy"' , ' COMPARESTRING isnot' ],
465+ \
466+ \ [' 0z11 == 0z22' , ' COMPAREBLOB ==' ],
467+ \ [' 0z11 != 0z22' , ' COMPAREBLOB !=' ],
468+ \ [' 0z11 is 0z22' , ' COMPAREBLOB is' ],
469+ \ [' 0z11 isnot 0z22' , ' COMPAREBLOB isnot' ],
470+ \
471+ \ [' [1,2] == [3,4]' , ' COMPARELIST ==' ],
472+ \ [' [1,2] != [3,4]' , ' COMPARELIST !=' ],
473+ \ [' [1,2] is [3,4]' , ' COMPARELIST is' ],
474+ \ [' [1,2] isnot [3,4]' , ' COMPARELIST isnot' ],
475+ \
476+ \ [' #{a:1} == #{x:2}' , ' COMPAREDICT ==' ],
477+ \ [' #{a:1} != #{x:2}' , ' COMPAREDICT !=' ],
478+ \ [' #{a:1} is #{x:2}' , ' COMPAREDICT is' ],
479+ \ [' #{a:1} isnot #{x:2}' , ' COMPAREDICT isnot' ],
480+ \
481+ \ [' {->33} == {->44}' , ' COMPAREPARTIAL ==' ],
482+ \ [' {->33} != {->44}' , ' COMPAREPARTIAL !=' ],
483+ \ [' {->33} is {->44}' , ' COMPAREPARTIAL is' ],
484+ \ [' {->33} isnot {->44}' , ' COMPAREPARTIAL isnot' ],
485+ \
486+ \ [' 77 == g:xx' , ' COMPAREANY ==' ],
487+ \ [' 77 != g:xx' , ' COMPAREANY !=' ],
488+ \ [' 77 > g:xx' , ' COMPAREANY >' ],
489+ \ [' 77 < g:xx' , ' COMPAREANY <' ],
490+ \ [' 77 >= g:xx' , ' COMPAREANY >=' ],
491+ \ [' 77 <= g:xx' , ' COMPAREANY <=' ],
492+ \ [' 77 =~ g:xx' , ' COMPAREANY =\~' ],
493+ \ [' 77 !~ g:xx' , ' COMPAREANY !\~' ],
494+ \ [' 77 is g:xx' , ' COMPAREANY is' ],
495+ \ [' 77 isnot g:xx' , ' COMPAREANY isnot' ],
496+ \ ]
497+ if has (' float' )
498+ cases- >extend ([
499+ \ [' 1.1 == 2.2' , ' COMPAREFLOAT ==' ],
500+ \ [' 1.1 != 2.2' , ' COMPAREFLOAT !=' ],
501+ \ [' 1.1 > 2.2' , ' COMPAREFLOAT >' ],
502+ \ [' 1.1 < 2.2' , ' COMPAREFLOAT <' ],
503+ \ [' 1.1 >= 2.2' , ' COMPAREFLOAT >=' ],
504+ \ [' 1.1 <= 2.2' , ' COMPAREFLOAT <=' ],
505+ \ [' 1.1 =~ 2.2' , ' COMPAREFLOAT =\~' ],
506+ \ [' 1.1 !~ 2.2' , ' COMPAREFLOAT !\~' ],
507+ \ ])
508+ endif
509+
510+ let nr = 1
511+ for case in cases
512+ writefile ([' def TestCase' .. nr .. ' ()' ,
513+ \ ' if ' .. case [0 ],
514+ \ ' echo 42'
515+ \ ' endif' ,
516+ \ ' enddef' ], ' Xdisassemble' )
517+ source Xdisassemble
518+ let instr = execute (' disassemble TestCase' .. nr)
519+ assert_match (' TestCase' .. nr .. ' .*'
520+ \ .. ' if ' .. substitute (case [0 ], ' [[~]' , ' \\\0' , ' g' ) .. ' .*'
521+ \ .. ' \d \(PUSH\|FUNCREF\).*'
522+ \ .. ' \d \(PUSH\|FUNCREF\|LOADG\).*'
523+ \ .. ' \d ' .. case [1 ] .. ' .*'
524+ \ .. ' \d JUMP_IF_FALSE -> \d\+.*'
525+ \, instr)
526+
527+ nr += 1
528+ endfor
529+
530+ " delete('Xdisassemble')
531+ enddef
532+
438533" vim: ts = 8 sw = 2 sts = 2 expandtab tw = 80 fdm = marker
0 commit comments