File: DeleteTest.vimspec

package info (click to toggle)
vim-autopairs 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 444 kB
  • sloc: makefile: 4
file content (62 lines) | stat: -rw-r--r-- 2,121 bytes parent folder | download | duplicates (2)
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
Describe <BS> tests
    Before each
        call autopairs#Variables#InitVariables()
        let g:AutoPairsMapBS = 1
    End
    It isn't explicitly made to handle balanced deletion
        new | only!
        call autopairs#AutoPairsInit()
        call Expect("some random text ((\<delete>\<bs>").ToMatch("some random text (")
    End
    It is supposed to delete pairs
        new | only!
        call autopairs#AutoPairsInit()
        " Let's do this incrementally
        call Expect("(((\<BS>").ToMatch("(())")
        call Expect("(((\<BS>\<BS>").ToMatch("()")
        call Expect("(((\<BS>\<BS>\<BS>").ToMatch("")
    End
    It should delete after, but only when enabled
        new | only!
        call autopairs#AutoPairsInit()

        call Expect("()\<BS>").ToMatch("")
        let b:AutoPairsBSIn = 0
        call Expect("(\<BS>").ToMatch(")")
    End
    It should allow mapping other default events
        new | only!
        call autopairs#AutoPairsInit()
        inoremap <silent><expr> <Delete> autopairs#AutoPairsDelete("\<Delete>")
        inoremap <silent><expr> <C-w> autopairs#AutoPairsDelete("\<C-w>")

        call Expect("(\<Delete>").ToMatch("")
        " This is sort of dumb, but eh, it's an edge-case
        call Expect("()\<Delete>").ToMatch("")


        call Expect("(\<C-w>").ToMatch("")
        call Expect("()\<C-w>").ToMatch("")
        call Expect("Word Two\<C-w>").ToMatch("Word ")

        call Expect("(Hello\<Ignore>\<C-w>").ToMatch("()")
        call Expect("(Hello\<Ignore>\<C-w>\<Ignore>\<C-w>").ToMatch("")
        " Just for good measure
        call Expect("[(Hello\<Ignore>\<C-w>\<Ignore>\<C-w>").ToMatch("[]")

        iunmap <C-w>
        iunmap <Delete>
    End
    " Not sure if this is strictly speaking necessary or not
    It should not break <BS> with other maps
        inoremap <silent><expr> <Delete> autopairs#AutoPairsDelete("\<Delete>")
        inoremap <silent><expr> <C-w> autopairs#AutoPairsDelete("\<C-w>")

        call Expect("(\<BS>").ToMatch("")
        call Expect("[\<BS>").ToMatch("")

        iunmap <C-w>
        iunmap <Delete>
    End

End