aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/put_spec.lua
blob: c78946d6904cf903a3dfd36463d7460922efb8fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local api = helpers.api
local source = helpers.source
local eq = helpers.eq

local function sizeoflong()
  if not exec_lua('return pcall(require, "ffi")') then
    pending('missing LuaJIT FFI')
  end
  return exec_lua('return require("ffi").sizeof(require("ffi").typeof("long"))')
end

describe('put', function()
  before_each(clear)
  after_each(function()
    eq({}, api.nvim_get_vvar('errors'))
  end)

  it('very large count 64-bit', function()
    if sizeoflong() < 8 then
      pending('Skipped: only works with 64 bit long ints')
    end

    source [[
      new
      let @" = repeat('x', 100)
      call assert_fails('norm 999999999p', 'E1240:')
      bwipe!
    ]]
  end)

  it('very large count (visual block) 64-bit', function()
    if sizeoflong() < 8 then
      pending('Skipped: only works with 64 bit long ints')
    end

    source [[
      new
      call setline(1, repeat('x', 100))
      exe "norm \<C-V>$y"
      call assert_fails('norm 999999999p', 'E1240:')
      bwipe!
    ]]
  end)

  -- oldtest: Test_put_other_window()
  it('above topline in buffer in two splits', function()
    local screen = Screen.new(80, 10)
    screen:attach()
    source([[
      40vsplit
      0put ='some text at the top'
      put ='  one more text'
      put ='  two more text'
      put ='  three more text'
      put ='  four more text'
    ]])

    screen:expect([[
      some text at the top                    │some text at the top                   |
        one more text                         │  one more text                        |
        two more text                         │  two more text                        |
        three more text                       │  three more text                      |
        ^four more text                        │  four more text                       |
                                              │                                       |
      ~                                       │~                                      |*2
      [No Name] [+]                            [No Name] [+]                          |
                                                                                      |
    ]])
  end)

  -- oldtest: Test_put_in_last_displayed_line()
  it('in last displayed line', function()
    local screen = Screen.new(75, 10)
    screen:attach()
    source([[
      autocmd CursorMoved * eval line('w$')
      let @a = 'x'->repeat(&columns * 2 - 2)
      eval range(&lines)->setline(1)
      call feedkeys('G"ap')
    ]])

    screen:expect([[
      2                                                                          |
      3                                                                          |
      4                                                                          |
      5                                                                          |
      6                                                                          |
      7                                                                          |
      8                                                                          |
      9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x |
                                                                                 |
    ]])
  end)
end)