robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
3.5 KiB91 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3local Screen = require('test.functional.ui.screen')
4
5local describe, it, before_each = t.describe, t.it, t.before_each
6local clear = n.clear
7local eq = t.eq
8local api = n.api
9local fn = n.fn
10local exec = n.exec
11local feed = n.feed
12
13describe('oldtests', function()
14  before_each(clear)
15
16  local exec_lines = function(str)
17    return fn.split(fn.execute(str), '\n')
18  end
19
20  local add_an_autocmd = function()
21    exec [[
22      augroup vimBarTest
23        au BufReadCmd * echo 'hello'
24      augroup END
25    ]]
26
27    eq(3, #exec_lines('au vimBarTest'))
28    eq(1, #api.nvim_get_autocmds({ group = 'vimBarTest' }))
29  end
30
31  it('should recognize a bar before the {event}', function()
32    -- Good spacing
33    add_an_autocmd()
34    exec [[ augroup vimBarTest | au! | augroup END ]]
35    eq(1, #exec_lines('au vimBarTest'))
36    eq({}, api.nvim_get_autocmds({ group = 'vimBarTest' }))
37
38    -- Sad spacing
39    add_an_autocmd()
40    exec [[ augroup vimBarTest| au!| augroup END ]]
41    eq(1, #exec_lines('au vimBarTest'))
42
43    -- test that a bar is recognized after the {event}
44    add_an_autocmd()
45    exec [[ augroup vimBarTest| au!BufReadCmd| augroup END ]]
46    eq(1, #exec_lines('au vimBarTest'))
47
48    add_an_autocmd()
49    exec [[ au! vimBarTest|echo 'hello' ]]
50    eq(1, #exec_lines('au vimBarTest'))
51  end)
52
53  -- oldtest: Test_delete_ml_get_errors()
54  it('no ml_get error with TextChanged autocommand and delete', function()
55    local screen = Screen.new(75, 10)
56    screen:add_extra_attr_ids {
57      [100] = { background = Screen.colors.Cyan1 },
58    }
59    exec([[
60      set noshowcmd noruler scrolloff=0
61      source test/old/testdir/samples/matchparen.vim
62      edit test/old/testdir/samples/box.txt
63    ]])
64    feed('249GV<C-End>d')
65    screen:expect([[
66              const auto themeEmoji = _forPeer->themeEmoji();                    |
67              if (themeEmoji.isEmpty()) {                                        |
68                      return nonCustom;                                          |
69              }                                                                  |
70              const auto &themes = _forPeer->owner().cloudThemes();              |
71              const auto theme = themes.themeForEmoji(themeEmoji);               |
72              if (!theme) {100:{}                                                      |
73                      return nonCustom;                                          |
74              {100:^}}                                                                  |
75      353 fewer lines                                                            |
76    ]])
77    feed('<PageUp>')
78    screen:expect([[
79                                                                                 |
80      auto BackgroundBox::Inner::resolveResetCustomPaper() const                 |
81      -> std::optional<Data::WallPaper> {                                        |
82              if (!_forPeer) {                                                   |
83                      return {};                                                 |
84              }                                                                  |
85              const auto nonCustom = Window::Theme::Background()->paper();       |
86              const auto themeEmoji = _forPeer->themeEmoji();                    |
87              ^if (themeEmoji.isEmpty()) {                                        |
88      353 fewer lines                                                            |
89    ]])
90  end)
91end)