mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
vim-patch:9.1.1421: tests: need a test for the new-style tutor.tutor (#34267)
Problem: tests: need a test for the new-style tutor.tutor, patch
9.1.1384 broke the expected positions for the signs
Solution: Update all number keys in tutor.tutor.json to match the
correct line numbers in tutor.tutor, replace tabs by spaces,
add a screen-dump test to verify it does not regress
(Pham Bình An)
closes: vim/vim#17416
a541f1de2b
This commit is contained in:
@ -1,35 +1,35 @@
|
|||||||
{
|
{
|
||||||
"expect": {
|
"expect": {
|
||||||
"63": "This is text with **important information**",
|
"56": "This is text with **important information**",
|
||||||
"64": "This is text with **important information**",
|
"57": "This is text with **important information**",
|
||||||
"71": "TODO: Document '&variable'",
|
"64": "TODO: Document '&variable'",
|
||||||
"72": "TODO: Document '&variable'",
|
"65": "TODO: Document '&variable'",
|
||||||
"78": "# This is a level 1 header",
|
"71": "# This is a level 1 header",
|
||||||
"79": "# This is a level 1 header",
|
"72": "# This is a level 1 header",
|
||||||
"80": "### This is a level 3 header",
|
"73": "### This is a level 3 header",
|
||||||
"81": "### This is a level 3 header",
|
"74": "### This is a level 3 header",
|
||||||
"82": "# This is a header with a label {*label*}",
|
"75": "# This is a header with a label {*label*}",
|
||||||
"83": "# This is a header with a label {*label*}",
|
"76": "# This is a header with a label {*label*}",
|
||||||
"108": "A link to help for the ['breakindent']('breakindent') option",
|
"101": "A link to help for the ['breakindent']('breakindent') option",
|
||||||
"109": "A link to help for the ['breakindent']('breakindent') option",
|
"102": "A link to help for the ['breakindent']('breakindent') option",
|
||||||
"123": "A link to the [Links](*links*) section",
|
"116": "A link to the [Links](*links*) section",
|
||||||
"124": "A link to the [Links](*links*) section",
|
"117": "A link to the [Links](*links*) section",
|
||||||
"139": "A link to [the vim-tutor-mode tutorial](@tutor:tutor)",
|
"132": "A link to [the vim-tutor-mode tutorial](@tutor:tutor)",
|
||||||
"140": "A link to [the vim-tutor-mode tutorial](@tutor:tutor)",
|
"133": "A link to [the vim-tutor-mode tutorial](@tutor:tutor)",
|
||||||
"157": "~~~ viml",
|
"150": "~~~ viml",
|
||||||
"158": "echom 'the value of &number is'.string(&number)",
|
"151": "echom 'the value of &number is'.string(&number)",
|
||||||
"159": "~~~",
|
"152": "~~~",
|
||||||
"161": "~~~ viml",
|
"154": "~~~ viml",
|
||||||
"162": "echom 'the value of &number is'.string(&number)",
|
"155": "echom 'the value of &number is'.string(&number)",
|
||||||
"163": "~~~",
|
"156": "~~~",
|
||||||
"188": "~~~ normal",
|
"181": "~~~ normal",
|
||||||
"189": "d2w",
|
"182": "d2w",
|
||||||
"190": "~~~",
|
"183": "~~~",
|
||||||
"192": "~~~ normal",
|
"185": "~~~ normal",
|
||||||
"193": "d2w",
|
"186": "d2w",
|
||||||
"194": "~~~",
|
"187": "~~~",
|
||||||
"206": "`d2w`{normal}",
|
"199": "`d2w`{normal}",
|
||||||
"207": "`d2w`{normal}",
|
"200": "`d2w`{normal}",
|
||||||
"244": -1
|
"237": -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,3 +135,61 @@ describe(':Tutor', function()
|
|||||||
screen:expect(expected)
|
screen:expect(expected)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe(':Tutor tutor', function()
|
||||||
|
local screen --- @type test.functional.ui.screen
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
clear({ args = { '--clean' } })
|
||||||
|
command('set cmdheight=0')
|
||||||
|
command('Tutor tutor')
|
||||||
|
screen = Screen.new(81, 30)
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[0] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray },
|
||||||
|
[1] = { bold = true },
|
||||||
|
[2] = { underline = true, foreground = tonumber('0x0088ff') },
|
||||||
|
[3] = { foreground = Screen.colors.SlateBlue },
|
||||||
|
[4] = { bold = true, foreground = Screen.colors.Brown },
|
||||||
|
[5] = { bold = true, foreground = Screen.colors.Magenta1 },
|
||||||
|
[6] = { italic = true },
|
||||||
|
[7] = { foreground = tonumber('0x00ff88'), bold = true, background = Screen.colors.Grey },
|
||||||
|
[8] = { bold = true, foreground = Screen.colors.Blue1 },
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('applies interactive marks', function()
|
||||||
|
feed(':216<CR>zt')
|
||||||
|
screen:expect([[
|
||||||
|
{0: }{3:^###}{5: expect } |
|
||||||
|
{0: } |
|
||||||
|
{0: }"expect" lines check that the contents of the line are identical to some preset|
|
||||||
|
{0: } text |
|
||||||
|
{0: }(like in the exercises above). |
|
||||||
|
{0: } |
|
||||||
|
{0: }These elements are specified in separate JSON files like this |
|
||||||
|
{0: } |
|
||||||
|
{0: }{3:~~~ json} |
|
||||||
|
{0: }{ |
|
||||||
|
{0: } "expect": { |
|
||||||
|
{0: } "1": "This is how this line should look.", |
|
||||||
|
{0: } "2": "This is how this line should look.", |
|
||||||
|
{0: } "3": -1 |
|
||||||
|
{0: } } |
|
||||||
|
{0: }} |
|
||||||
|
{0: }{3:~~~} |
|
||||||
|
{0: } |
|
||||||
|
{0: }These files contain an "expect" dictionary, for which the keys are line numbers|
|
||||||
|
{0: } and |
|
||||||
|
{0: }the values are the expected text. A value of -1 means that the condition for th|
|
||||||
|
{0: }e line |
|
||||||
|
{0: }will always be satisfied, no matter what (this is useful for letting the user p|
|
||||||
|
{0: }lay a bit). |
|
||||||
|
{0: } |
|
||||||
|
{7:✓ }{3:This is an "expect" line that is always satisfied. Try changing it.} |
|
||||||
|
{0: } |
|
||||||
|
{0: }These files conventionally have the same name as the tutorial document with the|
|
||||||
|
{0: } .json |
|
||||||
|
{0: }extension appended (for a full example, see the file that corresponds to thi{8:@@@}|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
" Test for the new-tutor plugin
|
" Test for the new-tutor plugin
|
||||||
|
|
||||||
|
source screendump.vim
|
||||||
|
source check.vim
|
||||||
|
source script_util.vim
|
||||||
|
|
||||||
func SetUp()
|
func SetUp()
|
||||||
set nocompatible
|
set nocompatible
|
||||||
runtime plugin/tutor.vim
|
runtime plugin/tutor.vim
|
||||||
@ -32,3 +36,20 @@ func Test_tutor_link()
|
|||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_mark()
|
||||||
|
CheckScreendump
|
||||||
|
call writefile([
|
||||||
|
\ 'set nocompatible',
|
||||||
|
\ 'runtime plugin/tutor.vim',
|
||||||
|
\ 'Tutor tutor',
|
||||||
|
\ 'set statusline=',
|
||||||
|
\ ], 'Xtest_plugin_tutor_mark', 'D')
|
||||||
|
let buf = RunVimInTerminal('-S Xtest_plugin_tutor_mark', {'rows': 20, 'cols': 78})
|
||||||
|
call term_sendkeys(buf, ":240\<CR>")
|
||||||
|
call WaitForAssert({-> assert_match('Bot$', term_getline(buf, 20))})
|
||||||
|
call VerifyScreenDump(buf, 'Test_plugin_tutor_mark_1', {})
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
Reference in New Issue
Block a user