comparison src/testdir/test_scriptnames.vim @ 29861:8dca33bca038 v9.0.0269

patch 9.0.0269: getscriptinfo() does not include the version Commit: https://github.com/vim/vim/commit/520f6ef60a59f7b5f3da9199999d13dbe817d3ce Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Aug 25 17:40:40 2022 +0100 patch 9.0.0269: getscriptinfo() does not include the version Problem: getscriptinfo() does not include the version. Cannot select entries by script name. Solution: Add the "version" item and the "name" argument. (Yegappan Lakshmanan, closes #10962)
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Aug 2022 18:45:04 +0200
parents 761631155a90
children cd573d7bc30d
comparison
equal deleted inserted replaced
29860:21b386bb3f61 29861:8dca33bca038
29 call assert_equal(msgs, execute('messages')) 29 call assert_equal(msgs, execute('messages'))
30 endfunc 30 endfunc
31 31
32 " Test for the getscriptinfo() function 32 " Test for the getscriptinfo() function
33 func Test_getscriptinfo() 33 func Test_getscriptinfo()
34 call writefile(['let loaded_script_id = expand("<SID>")'], 'Xscript') 34 let lines =<< trim END
35 source Xscript 35 let g:loaded_script_id = expand("<SID>")
36 let s:XscriptVar = [1, #{v: 2}]
37 func s:XscriptFunc()
38 endfunc
39 END
40 call writefile(lines, 'X22script91')
41 source X22script91
36 let l = getscriptinfo() 42 let l = getscriptinfo()
37 call assert_match('Xscript$', l[-1].name) 43 call assert_match('X22script91$', l[-1].name)
38 call assert_equal(g:loaded_script_id, $"<SNR>{l[-1].sid}_") 44 call assert_equal(g:loaded_script_id, $"<SNR>{l[-1].sid}_")
39 call delete('Xscript') 45
46 let l = getscriptinfo({'name': '22script91'})
47 call assert_equal(1, len(l))
48 call assert_match('22script91$', l[0].name)
49
50 let l = getscriptinfo({'name': 'foobar'})
51 call assert_equal(0, len(l))
52 let l = getscriptinfo({'name': ''})
53 call assert_true(len(l) > 1)
54
55 call assert_fails("echo getscriptinfo({'name': []})", 'E730:')
56 call assert_fails("echo getscriptinfo({'name': '\\@'})", 'E866:')
57 let l = getscriptinfo({'name': test_null_string()})
58 call assert_true(len(l) > 1)
59 call assert_fails("echo getscriptinfo('foobar')", 'E1206:')
60
61 call delete('X22script91')
40 endfunc 62 endfunc
41 63
42 " vim: shiftwidth=2 sts=2 expandtab 64 " vim: shiftwidth=2 sts=2 expandtab