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
|
Describe Basic tests of pair functionality
Before each
call autopairs#Variables#InitVariables()
End
It should do basic insertion
new | only!
call autopairs#AutoPairsTryInit()
call Expect("(").ToMatch("()")
call Expect("Hello (me").ToMatch("Hello (me)")
" Welcome to a random mid-test rant: why the fuck does Vim require
" this? There's no sane ways to escape characters, and \<CR> doesn't
" actually send the right signal unless the CR is in a double-quote
" string. WTF?!
call Expect('"""' . "\<CR>").ToMatch('"""\n\n"""')
End
It should properly break blocks
let g:AutoPairsReturnOnEmptyOnly = 1
new | only!
call autopairs#AutoPairsTryInit()
call Expect("if(blah\<cr>").ToMatch('if(blah\n)')
End
It should also make other block expansions
new | only!
call autopairs#AutoPairsTryInit()
let b:AutoPairsReturnOnEmptyOnly = 0
" The resulting indent is a bit weird - not sure why.
call Expect("if(blah\<cr>").ToMatch('if(blah\n\n )')
End
It should handle multibyte pairs
let g:AutoPairs = {"Hello": ", is what I would say if I cared.", "H": "G"}
new | only!
call autopairs#AutoPairsTryInit()
call Expect('H').ToMatch("HG")
call Expect("Hello").ToMatch("Hello, is what I would say if I cared.")
End
It should handle nesting
" We don't map backspace here because this is a pair test primarily,
" and not a backspace test.
" Should probably separate out the return test, but whatever. The
" point being, not mapping BS here is the easiest way to test this
" specific situation. It's either that or \<left>\<delete> instead,
" which is substantially uglier.
let g:AutoPairsMapBS = 0
new | only!
call autopairs#AutoPairsTryInit()
call Expect("((\<bs>(").ToMatch("(())")
End
It shouldn't forcibly do multiline bullshit
new | only!
call autopairs#AutoPairsTryInit()
call Expect("[\<CR>").ToMatch('[\n\n]')
call Expect("[\<CR>]").ToMatch('[\n]\n]')
End
It should allow explicit multiline close
new | only!
call autopairs#AutoPairsTryInit()
let b:AutoPairsMultilineClose = 1
call Expect("[\<CR>]").ToMatch('[\n]')
End
It should work with spaces
new | only!
call autopairs#AutoPairsTryInit()
call Expect("[ ").ToMatch("[ ]")
End
It should erase old pairs on blank new pairs
call autopairs#AutoPairsAddPairs([#{open: '""', close: ""}, #{open: '"', close: 'abcd'}])
new | only!
call autopairs#AutoPairsTryInit()
call Expect('"').ToMatch('"abcd')
call Expect('""').ToMatch('""')
End
End
" vim:sw=4
|