diff src/testdir/test_vim9_import.vim @ 27108:92e2e96ff559 v8.2.4083

patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable Commit: https://github.com/vim/vim/commit/0e3e7ba05fa9cebe17d38def97ecd38a987d02ec Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 13 20:18:56 2022 +0000 patch 8.2.4083: Vim9: no test for "vim9script autoload' using script variable Problem: Vim9: no test for "vim9script autoload' and using script variable in the same script. Solution: Add a simple test. Fix uncovered problem.
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Jan 2022 21:30:04 +0100
parents d7e6b85dd89d
children 60df9f2679a6
line wrap: on
line diff
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1091,7 +1091,7 @@ def Test_import_gone_when_sourced_twice(
 enddef
 
 " test using an auto-loaded function and variable
-def Test_vim9_autoload()
+def Test_vim9_autoload_full_name()
   var lines =<< trim END
      vim9script
      def some#gettest(): string
@@ -1146,11 +1146,16 @@ def Test_vim9script_autoload()
        return 'test'
      enddef
 
-     export func GetMore()
-       return Gettest() .. 'more'
+     export var name = 'name'
+
+     export func GetFunc()
+       return Gettest() .. 'more' .. s:name
      endfunc
 
-     export var name = 'name'
+     export def GetDef(): string
+       return Gettest() .. 'more' .. name
+     enddef
+
      export final fname = 'final'
      export const cname = 'const'
   END
@@ -1165,7 +1170,8 @@ def Test_vim9script_autoload()
       assert_equal('test', prefixed.Gettest())
       assert_equal(1, g:prefixed_loaded)
 
-      assert_equal('testmore', prefixed.GetMore())
+      assert_equal('testmorename', prefixed.GetFunc())
+      assert_equal('testmorename', prefixed.GetDef())
       assert_equal('name', prefixed.name)
       assert_equal('final', prefixed.fname)
       assert_equal('const', prefixed.cname)
@@ -1178,7 +1184,7 @@ def Test_vim9script_autoload()
   # can also get the items by autoload name
   lines =<< trim END
       call assert_equal('test', prefixed#Gettest())
-      call assert_equal('testmore', prefixed#GetMore())
+      call assert_equal('testmorename', prefixed#GetFunc())
       call assert_equal('name', prefixed#name)
       call assert_equal('final', prefixed#fname)
       call assert_equal('const', prefixed#cname)