File: WhitespaceOnlyTests.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 (69 lines) | stat: -rw-r--r-- 2,555 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
63
64
65
66
67
68
69
Describe Whitespace-restricted completion
    Before each
        call autopairs#Variables#InitVariables()
        let g:AutoPairsCompleteOnlyOnSpace = 1
    End
    It should support the basic functionality
        new | only!
        " Control test for later
        call Expect("'Henlo (").ToMatch("'Henlo ('")

        call Expect("[").ToMatch("[]")
        call Expect("[[").ToMatch("[[]]")
        call Expect("[a\<left>[").ToMatch("[[a]")
        let b:AutoPairsCompleteOnlyOnSpace = 0
        call Expect("[a\<left>[").ToMatch("[[]a]")

    End
    It should support fully disabling the whitelist
        let g:AutoPairsAutoBuildSpaceWhitelist = 0
        new | only!

        call Expect("[").ToMatch("[]")
        call Expect("[[").ToMatch("[[]")

        call Expect("[ \<left>[").ToMatch("[[]  ]")
        call Expect("[b\<left>[").ToMatch("[[b]")
    End
    It should support a whitelist without auto-building one

        let g:AutoPairsAutoBuildSpaceWhitelist = 0
        let g:AutoPairsNextCharWhitelist = ['a', ']']
        new | only!
        call Expect("[").ToMatch("[]")
        call Expect("[[").ToMatch("[[]]")
        call Expect("[a\<left>[").ToMatch("[[]a]")
        call Expect("[b\<left>[").ToMatch("[[b]")
    End
    It should support adding to the whitelist when auto-building

        let g:AutoPairsNextCharWhitelist = ['a', ']']
        new | only!

        call Expect("[").ToMatch("[]")
        call Expect("[[").ToMatch("[[]]")

        call Expect("[a\<left>[").ToMatch("[[]a]")
        call Expect("[b\<left>[").ToMatch("[[b]")
    End
    It should support a flexible regex
        let g:AutoPairsSpaceCompletionRegex = '\w'
        new | only!
        call Expect("ab\<esc>0i(").ToMatch('(ab')
        call Expect("'Henlo (").ToMatch("'Henlo ()'")
        call Expect("여우\<esc>0i(").ToMatch('()여우')

        let b:AutoPairsSpaceCompletionRegex = '[abcdef]'
        call Expect("fox\<esc>0i(").ToMatch('(fox')
        call Expect("wolf\<esc>0i(").ToMatch('()wolf')
        call Expect("Fox\<esc>0i(").ToMatch('(Fox')
        call Expect("Wolf\<esc>0i(").ToMatch('()Wolf')

        let b:AutoPairsSpaceCompletionRegex = '[[:lower:][:upper:]0-9]'
        call Expect("fox\<esc>0i(").ToMatch('(fox')
        call Expect("wolf\<esc>0i(").ToMatch('(wolf')
        call Expect("æøå\<esc>0i(").ToMatch('(æøå')
        call Expect("Æøå\<esc>0i(").ToMatch('(Æøå')
        call Expect("여우\<esc>0i(").ToMatch('(여우')
    End
End