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

Can Vader work with Vim9 script? #225

Open
Aster89 opened this issue Feb 14, 2022 · 1 comment
Open

Can Vader work with Vim9 script? #225

Aster89 opened this issue Feb 14, 2022 · 1 comment

Comments

@Aster89
Copy link

Aster89 commented Feb 14, 2022

Such a code passes (and it expectedly fails if I change the second argument to AssertEqual), suggesting that Vader is indeed executing Vim9 script code:

Execute (vim9 var):
  vim9cmd var path = '/some/path/to/file.txt'
  AssertEqual path, '/some/path/to/file.txt'

But if I write this

Execute (vim9 lambda):
  vim9cmd var Identity = (x) => x
  AssertEqual Identity(3), 3

it fails like this

Starting Vader: 1 suite(s), 1 case(s)
  Starting Vader: /home/enrico/.vim/plugged/WinZoZ/test/winzoz.vader
    (1/1) [EXECUTE] vim9 lambda
    (1/1) [EXECUTE] (X) Vim(call):E117: Unknown function: Identity
      > command line..function <SNR>24_vader[5]..vader#run[63]..<SNR>96_run[42]..<SNR>96_execute[2]..vader#window#execute[11]..script /tmp/vvIdE4r/3, line 2
  Success/Total: 0/1
Success/Total: 0/1 (assertions: 0/0)
Elapsed time: 0.01 sec.
Failure

suggesting that something is not quite right...

Anybody knows?

@igbanam
Copy link

igbanam commented Mar 12, 2023

You'd need to modify your test in a few ways.

tl;dr

Execute (vim9 lambda):
  vim9cmd g:Identity = (x) => x
  AssertEqual Identity(3), 3

Modifications…

  1. Identity must be global to be used with Assert...
  2. Vim9 does not allow us "declare" global variables with var

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

No branches or pull requests

2 participants