Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vimspec style tests fail in vim9 script #74

Open
mmktomato opened this issue Aug 15, 2022 · 2 comments
Open

Vimspec style tests fail in vim9 script #74

mmktomato opened this issue Aug 15, 2022 · 2 comments
Labels

Comments

@mmktomato
Copy link

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 mmktomato added the bug label Aug 15, 2022
@igbanam
Copy link

igbanam commented Dec 7, 2022

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
Copy link

igbanam commented Dec 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants