vim-themis icon indicating copy to clipboard operation
vim-themis copied to clipboard

Vimspec style tests fail in vim9 script

Open mmktomato opened this issue 3 years ago • 2 comments

Describe the bug

Vimspec style tests fail in vim9 script.

How to reproduce the problem from Vim startup

Create test.vimspec as follows:

vim9script

Describe d
    Context c
        It should pass
            Assert Equals(3, 1 + 2)
        End
    End
End

Then run ./bin/themis test.vimspec.

$ ./bin/themis test.vimspec
Bail out!  Error occurred in script loading.                                                                                                            
# function themis/Runner.load_scripts(files_with_styles, target_bundle) abort dict  Line:11  [ Absolute Line: 130 ]  (~/vimfiles/pack/cui/start/vim-them
is/autoload/themis/runner.vim)                                                                                                                          
# function themis/style['vimspec'].load_script(filename, runner) abort dict  Line:5  [ Absolute Line: 298 ]  (~/vimfiles/pack/cui/start/vim-themis/autol
oad/themis/style/vimspec.vim)                                                                                                                           
# function script()  This function is already deleted.                                                                                                  
#   1:                                                                                                                                                  
# Vim(vim9script):E1039: "vim9script" must be the first command in a script

On the other hand, basic style tests don't fail.

vim9script

var assert = themis#helper('assert')

def MyTest()
    assert.equals(3, 1 + 2)
enddef
$ ./bin/themis test.vim
1..0                                                                                                                                                    
                                                                                                                                                        
# tests 0                                                                                                                                               
# passes 0 

Expected behavior

I expect vimspec style tests don't fail in vim9 script as well as basic style tests.

Actual behavior

See above.

Your environment

  • OS: Mac OS Monterey 12.5
  • Vim's version: 8.1.5151
  • Plugin's version: 1.7.0

mmktomato avatar Aug 15 '22 02:08 mmktomato

So… right of the top, methinks this is a translation issue. Since this was built in legacy vimscript, it was built for legacy vimscript.

Digging…

igbanam avatar Dec 07 '22 00:12 igbanam

Digging a bit deeper, my original assumption seems right. Turns out the translation assumes legacy vimscript. If you look at the style/vimspec.vim, you'd realize that the parse_<> functions — s:parse_describe, s:parse_hook s:parse_example and s:parse_end — all assume translations into legacy vimscript.

One solution here is to define a vim9script strategy which could auto-detect on the vim9script keyword and parse accordingly.

igbanam avatar Dec 07 '22 00:12 igbanam