2009-06-23 08:45:04 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
#
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
# To execute this test requires two terminals, one for running Vim and one
|
|
|
|
# for executing the test script. Both terminals should have their current
|
|
|
|
# working directories set to this directory (the one containing this test.py
|
|
|
|
# script).
|
|
|
|
#
|
|
|
|
# In one terminal, launch a GNU ``screen`` session named ``vim``:
|
|
|
|
# $ screen -S vim
|
|
|
|
#
|
|
|
|
# Within this new session, launch Vim with the absolute bare minimum settings
|
|
|
|
# to ensure a consistent test environment:
|
|
|
|
# $ vim -u NONE
|
|
|
|
#
|
|
|
|
# The '-u NONE' disables normal .vimrc and .gvimrc processing (note
|
|
|
|
# that '-u NONE' implies '-U NONE').
|
|
|
|
#
|
|
|
|
# All other settings are configured by the test script.
|
|
|
|
#
|
|
|
|
# Now, from another terminal, launch the testsuite:
|
|
|
|
# $ ./test.py
|
2010-08-15 09:08:51 -04:00
|
|
|
#
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
# The testsuite will use ``screen`` to inject commands into the Vim under test,
|
|
|
|
# and will compare the resulting output to expected results.
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-01 04:39:46 -04:00
|
|
|
import os
|
|
|
|
import tempfile
|
2009-06-23 08:45:04 -04:00
|
|
|
import unittest
|
2009-07-01 04:39:46 -04:00
|
|
|
import time
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
from textwrap import dedent
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-05 07:20:58 -04:00
|
|
|
# Some constants for better reading
|
|
|
|
BS = '\x7f'
|
|
|
|
ESC = '\x1b'
|
|
|
|
ARR_L = '\x1bOD'
|
|
|
|
ARR_R = '\x1bOC'
|
|
|
|
ARR_U = '\x1bOA'
|
|
|
|
ARR_D = '\x1bOB'
|
|
|
|
|
2009-07-09 09:30:23 -04:00
|
|
|
# Defined Constants
|
|
|
|
JF = "?" # Jump forwards
|
|
|
|
JB = "+" # Jump backwards
|
2009-08-16 12:50:14 -04:00
|
|
|
LS = "@" # List snippets
|
2009-07-09 09:30:23 -04:00
|
|
|
EX = "\t" # EXPAND
|
|
|
|
|
2009-07-15 12:16:42 -04:00
|
|
|
# Some VIM functions
|
|
|
|
COMPL_KW = chr(24)+chr(14)
|
|
|
|
COMPL_ACCEPT = chr(25)
|
|
|
|
|
2009-07-04 10:08:14 -04:00
|
|
|
def send(s,session):
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
s = s.replace("'", r"'\''")
|
|
|
|
os.system("screen -x %s -X stuff '%s'" % (session, s))
|
2009-07-04 10:08:14 -04:00
|
|
|
|
2009-07-10 12:34:46 -04:00
|
|
|
def type(str, session, sleeptime):
|
2009-07-04 10:08:14 -04:00
|
|
|
"""
|
|
|
|
Send the keystrokes to vim via screen. Pause after each char, so
|
|
|
|
vim can handle this
|
|
|
|
"""
|
|
|
|
for c in str:
|
|
|
|
send(c, session)
|
2009-07-10 12:34:46 -04:00
|
|
|
time.sleep(sleeptime)
|
2009-07-04 10:08:14 -04:00
|
|
|
|
2009-07-01 04:39:46 -04:00
|
|
|
class _VimTest(unittest.TestCase):
|
2009-07-05 12:51:12 -04:00
|
|
|
snippets = ("dummy", "donotdefine")
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
snippets_test_file = ("", "", "") # file type, file name, file content
|
2009-07-02 03:49:42 -04:00
|
|
|
text_before = " --- some text before --- "
|
|
|
|
text_after = " --- some text after --- "
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
expected_error = ""
|
2009-07-05 12:51:12 -04:00
|
|
|
wanted = ""
|
|
|
|
keys = ""
|
2009-08-30 14:04:17 -04:00
|
|
|
sleeptime = 0.00
|
2009-07-04 18:53:30 -04:00
|
|
|
|
2009-07-04 10:08:14 -04:00
|
|
|
def send(self,s):
|
|
|
|
send(s, self.session)
|
2009-07-01 11:11:33 -04:00
|
|
|
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
def send_py(self,s):
|
|
|
|
self.send(":py << EOF\n%s\nEOF\n" % s)
|
|
|
|
|
2009-07-04 10:08:14 -04:00
|
|
|
def type(self,s):
|
2009-07-10 12:34:46 -04:00
|
|
|
type(s, self.session, self.sleeptime)
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-02 03:49:42 -04:00
|
|
|
def check_output(self):
|
|
|
|
wanted = self.text_before + '\n\n' + self.wanted + \
|
|
|
|
'\n\n' + self.text_after
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
if self.expected_error:
|
|
|
|
wanted = wanted + "\n" + self.expected_error
|
|
|
|
for i in range(4):
|
2009-08-24 06:28:54 -04:00
|
|
|
if self.output != wanted:
|
2010-08-17 11:05:35 -04:00
|
|
|
# Redo this, but slower
|
|
|
|
self.sleeptime += 0.02
|
2009-08-24 06:28:54 -04:00
|
|
|
self.setUp()
|
2009-07-02 03:49:42 -04:00
|
|
|
self.assertEqual(self.output, wanted)
|
|
|
|
|
2009-07-05 12:51:12 -04:00
|
|
|
def runTest(self): self.check_output()
|
|
|
|
|
2009-07-12 11:23:39 -04:00
|
|
|
def _options_on(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def _options_off(self):
|
|
|
|
pass
|
|
|
|
|
2009-06-23 08:45:04 -04:00
|
|
|
def setUp(self):
|
2009-07-05 07:20:58 -04:00
|
|
|
self.send(ESC)
|
2009-07-01 04:39:46 -04:00
|
|
|
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
self.send(":py UltiSnips_Manager.reset(test_error=True)\n")
|
|
|
|
|
|
|
|
# Clear the buffer
|
|
|
|
self.send("bggVGd")
|
2009-06-28 16:22:19 -04:00
|
|
|
|
2010-08-15 09:08:51 -04:00
|
|
|
if len(self.snippets) and not isinstance(self.snippets[0],tuple):
|
2009-07-01 14:03:29 -04:00
|
|
|
self.snippets = ( self.snippets, )
|
|
|
|
|
2009-07-04 15:58:13 -04:00
|
|
|
for s in self.snippets:
|
|
|
|
sv,content = s[:2]
|
|
|
|
descr = ""
|
2009-07-17 17:33:48 -04:00
|
|
|
options = ""
|
|
|
|
if len(s) > 2:
|
|
|
|
descr = s[2]
|
|
|
|
if len(s) > 3:
|
|
|
|
options = s[3]
|
|
|
|
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
self.send_py("UltiSnips_Manager.add_snippet(%r, %r, %r, %r)" %
|
|
|
|
(sv, content, descr, options))
|
2009-07-01 11:11:33 -04:00
|
|
|
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
ft, fn, file_data = self.snippets_test_file
|
|
|
|
if ft:
|
|
|
|
self.send_py("UltiSnips_Manager._parse_snippets(%r, %r, %r)" %
|
|
|
|
(ft, fn, dedent(file_data + '\n')))
|
2009-07-01 04:39:46 -04:00
|
|
|
|
2009-07-01 09:20:40 -04:00
|
|
|
if not self.interrupt:
|
|
|
|
# Enter insert mode
|
2009-07-01 11:11:33 -04:00
|
|
|
self.send("i")
|
2009-06-28 16:22:19 -04:00
|
|
|
|
2009-07-02 03:49:42 -04:00
|
|
|
self.send(self.text_before + '\n\n')
|
|
|
|
self.send('\n\n' + self.text_after)
|
|
|
|
|
2009-07-12 11:23:39 -04:00
|
|
|
self.send(ESC)
|
|
|
|
|
2009-07-02 03:49:42 -04:00
|
|
|
# Go to the middle of the buffer
|
2009-07-12 11:23:39 -04:00
|
|
|
self.send(ESC + "ggjj")
|
|
|
|
|
|
|
|
self._options_on()
|
|
|
|
|
|
|
|
self.send("i")
|
2009-07-02 03:49:42 -04:00
|
|
|
|
2009-07-01 09:20:40 -04:00
|
|
|
# Execute the command
|
2009-07-05 12:46:08 -04:00
|
|
|
self.type(self.keys)
|
2009-07-02 03:49:42 -04:00
|
|
|
|
2009-07-12 11:23:39 -04:00
|
|
|
self.send(ESC)
|
|
|
|
|
|
|
|
self._options_off()
|
|
|
|
|
2009-07-10 06:47:54 -04:00
|
|
|
handle, fn = tempfile.mkstemp(prefix="UltiSnips_Test",suffix=".txt")
|
2009-07-01 09:20:40 -04:00
|
|
|
os.close(handle)
|
2009-07-04 18:53:30 -04:00
|
|
|
os.unlink(fn)
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-05 07:20:58 -04:00
|
|
|
self.send(ESC + ":w! %s\n" % fn)
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-01 09:20:40 -04:00
|
|
|
# Read the output, chop the trailing newline
|
2009-07-04 18:53:30 -04:00
|
|
|
tries = 50
|
|
|
|
while tries:
|
|
|
|
if os.path.exists(fn):
|
|
|
|
self.output = open(fn,"r").read()[:-1]
|
|
|
|
break
|
|
|
|
time.sleep(.05)
|
|
|
|
tries -= 1
|
2009-06-23 08:45:04 -04:00
|
|
|
|
|
|
|
##################
|
|
|
|
# Simple Expands #
|
|
|
|
##################
|
|
|
|
class _SimpleExpands(_VimTest):
|
2009-07-01 14:03:29 -04:00
|
|
|
snippets = ("hallo", "Hallo Welt!")
|
2009-06-23 08:45:04 -04:00
|
|
|
|
|
|
|
class SimpleExpand_ExceptCorrectResult(_SimpleExpands):
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "Hallo Welt!"
|
2009-07-09 11:49:59 -04:00
|
|
|
class SimpleExpandTwice_ExceptCorrectResult(_SimpleExpands):
|
|
|
|
keys = "hallo" + EX + '\nhallo' + EX
|
|
|
|
wanted = "Hallo Welt!\nHallo Welt!"
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-10 12:34:46 -04:00
|
|
|
class SimpleExpandNewLineAndBackspae_ExceptCorrectResult(_SimpleExpands):
|
|
|
|
keys = "hallo" + EX + "\nHallo Welt!\n\n\b\b\b\b\b"
|
|
|
|
wanted = "Hallo Welt!\nHallo We"
|
2009-07-12 11:23:39 -04:00
|
|
|
def _options_on(self):
|
2009-07-10 12:34:46 -04:00
|
|
|
self.send(":set backspace=eol,start\n")
|
2009-07-12 11:23:39 -04:00
|
|
|
def _options_off(self):
|
2009-07-10 12:34:46 -04:00
|
|
|
self.send(":set backspace=\n")
|
|
|
|
|
2009-06-23 08:45:04 -04:00
|
|
|
class SimpleExpandTypeAfterExpand_ExceptCorrectResult(_SimpleExpands):
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "and again"
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "Hallo Welt!and again"
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-03 04:59:55 -04:00
|
|
|
class SimpleExpandTypeAndDelete_ExceptCorrectResult(_SimpleExpands):
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "na du hallo" + EX + "and again\b\b\b\b\bblub"
|
2009-07-03 04:59:55 -04:00
|
|
|
wanted = "na du Hallo Welt!and blub"
|
2009-06-23 08:45:04 -04:00
|
|
|
|
|
|
|
class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands):
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo " + EX
|
2009-08-24 06:28:54 -04:00
|
|
|
wanted = "hallo " + EX
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-08-25 19:18:06 -04:00
|
|
|
class ExitSnippetModeAfterTabstopZero(_VimTest):
|
|
|
|
snippets = ("test", "SimpleText")
|
|
|
|
keys = "test" + EX + EX
|
|
|
|
wanted = "SimpleText" + EX
|
|
|
|
|
2009-06-23 08:45:04 -04:00
|
|
|
class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands):
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "Wie hallo gehts" + ESC + "bhi" + EX
|
|
|
|
wanted = "Wie Hallo Welt! gehts"
|
2009-06-23 08:45:04 -04:00
|
|
|
class MultilineExpand_ExceptCorrectResult(_VimTest):
|
2009-07-09 09:30:23 -04:00
|
|
|
snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts")
|
|
|
|
keys = "Wie hallo gehts" + ESC + "bhi" + EX
|
|
|
|
wanted = "Wie Hallo Welt!\nUnd Wie gehts gehts"
|
2009-06-28 08:51:27 -04:00
|
|
|
class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest):
|
2009-07-09 09:30:23 -04:00
|
|
|
snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts")
|
|
|
|
wanted = "Wie Hallo Welt!\nUnd Wie gehtsHuiui! gehts"
|
|
|
|
keys = "Wie hallo gehts" + ESC + "bhi" + EX + "Huiui!"
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-16 04:16:30 -04:00
|
|
|
class MultilineExpandWithFormatoptionsOn_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "${1:longer expand}\n$0")
|
|
|
|
keys = "test" + EX + "This is a longer text that should wrap"
|
|
|
|
wanted = "This is a longer\ntext that should\nwrap\n"
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set tw=20\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set tw=0\n")
|
|
|
|
|
|
|
|
|
2009-06-23 08:45:04 -04:00
|
|
|
############
|
|
|
|
# TabStops #
|
|
|
|
############
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopSimpleReplace_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("hallo", "hallo ${0:End} ${1:Beginning}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "na" + JF + "Du Nase"
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "hallo Du Nase na"
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopSimpleReplaceSurrounded_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("hallo", "hallo ${0:End} a small feed")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "Nase"
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "hallo Nase a small feed"
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopSimpleReplaceSurrounded1_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("hallo", "hallo $0 a small feed")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "Nase"
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "hallo Nase a small feed"
|
2009-07-09 04:20:25 -04:00
|
|
|
class TabStopSimpleReplaceEndingWithNewline_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("hallo", "Hallo Welt\n")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "\nAnd more"
|
2009-07-09 04:20:25 -04:00
|
|
|
wanted = "Hallo Welt\n\nAnd more"
|
2009-06-23 08:45:04 -04:00
|
|
|
|
2009-07-01 14:03:29 -04:00
|
|
|
|
|
|
|
class ExitTabStop_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("echo", "$0 run")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "echo" + EX + "test"
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "test run"
|
2009-06-28 08:51:27 -04:00
|
|
|
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopNoReplace_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("echo", "echo ${1:Hallo}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "echo" + EX
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "echo Hallo"
|
2009-06-28 16:22:19 -04:00
|
|
|
|
2009-07-22 06:08:21 -04:00
|
|
|
class TabStop_EscapingCharsBackticks(_VimTest):
|
|
|
|
snippets = ("test", r"snip \` literal")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "snip ` literal"
|
|
|
|
class TabStop_EscapingCharsDollars(_VimTest):
|
|
|
|
snippets = ("test", r"snip \$0 $$0 end")
|
|
|
|
keys = "test" + EX + "hi"
|
|
|
|
wanted = "snip $0 $hi end"
|
|
|
|
class TabStop_EscapingChars_RealLife(_VimTest):
|
|
|
|
snippets = ("test", r"usage: \`basename \$0\` ${1:args}")
|
|
|
|
keys = "test" + EX + "[ -u -v -d ]"
|
|
|
|
wanted = "usage: `basename $0` [ -u -v -d ]"
|
|
|
|
|
2009-07-06 10:55:48 -04:00
|
|
|
class TabStopEscapingWhenSelected_ECR(_VimTest):
|
|
|
|
snippets = ("test", "snip ${1:default}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + ESC + "0ihi"
|
2009-07-06 10:55:48 -04:00
|
|
|
wanted = "hisnip default"
|
2009-07-06 10:57:22 -04:00
|
|
|
class TabStopEscapingWhenSelectedSingleCharTS_ECR(_VimTest):
|
|
|
|
snippets = ("test", "snip ${1:i}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + ESC + "0ihi"
|
2009-07-06 10:57:22 -04:00
|
|
|
wanted = "hisnip i"
|
|
|
|
class TabStopEscapingWhenSelectedNoCharTS_ECR(_VimTest):
|
|
|
|
snippets = ("test", "snip $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + ESC + "0ihi"
|
2009-07-06 10:57:22 -04:00
|
|
|
wanted = "hisnip "
|
2009-07-06 10:55:48 -04:00
|
|
|
|
2009-07-06 11:44:04 -04:00
|
|
|
class TabStopUsingBackspaceToDeleteDefaultValue_ECR(_VimTest):
|
|
|
|
snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + BS
|
2009-07-06 11:44:04 -04:00
|
|
|
wanted = "snip "
|
|
|
|
class TabStopUsingBackspaceToDeleteDefaultValueInFirstTab_ECR(_VimTest):
|
2009-07-16 11:34:36 -04:00
|
|
|
sleeptime = 0.09 # Do this very slowly
|
2009-07-06 11:44:04 -04:00
|
|
|
snippets = ("test", "snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} "
|
|
|
|
"${1:default} ${2:def}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + BS + JF + "hi"
|
2009-07-06 11:44:04 -04:00
|
|
|
wanted = "snip m2 hi"
|
|
|
|
class TabStopUsingBackspaceToDeleteDefaultValueInSecondTab_ECR(_VimTest):
|
|
|
|
snippets = ("test", "snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} "
|
|
|
|
"${1:default} ${2:def}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hi" + JF + BS
|
2009-07-06 11:44:04 -04:00
|
|
|
wanted = "snip m1 hi "
|
|
|
|
class TabStopUsingBackspaceToDeleteDefaultValueTypeSomethingThen_ECR(_VimTest):
|
|
|
|
snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + BS + "hallo"
|
2009-07-06 11:44:04 -04:00
|
|
|
wanted = "snip matched hallo"
|
|
|
|
|
2009-07-03 07:54:35 -04:00
|
|
|
class TabStopWithOneChar_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("hallo", "nothing ${1:i} hups")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "ship"
|
2009-07-03 07:54:35 -04:00
|
|
|
wanted = "nothing ship hups"
|
|
|
|
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopTestJumping_ExceptCorrectResult(_VimTest):
|
2009-07-03 07:54:35 -04:00
|
|
|
snippets = ("hallo", "hallo ${2:End} mitte ${1:Beginning}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + JF + "Test" + JF + "Hi"
|
2009-07-04 11:36:06 -04:00
|
|
|
wanted = "hallo Test mitte BeginningHi"
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopTestJumping2_ExceptCorrectResult(_VimTest):
|
2009-07-06 05:35:18 -04:00
|
|
|
snippets = ("hallo", "hallo $2 $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + JF + "Test" + JF + "Hi"
|
2009-07-04 11:36:06 -04:00
|
|
|
wanted = "hallo Test Hi"
|
2009-07-10 03:35:21 -04:00
|
|
|
class TabStopTestJumpingRLExampleWithZeroTab_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "each_byte { |${1:byte}| $0 }")
|
|
|
|
keys = "test" + EX + JF + "Blah"
|
|
|
|
wanted = "each_byte { |byte| Blah }"
|
2009-07-01 09:20:40 -04:00
|
|
|
|
2009-07-06 05:35:18 -04:00
|
|
|
class TestJumpingDontJumpToEndIfThereIsTabZero_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("hallo", "hallo $0 $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "Test" + JF + "Hi" + JF + JF + "du"
|
2009-07-06 05:35:18 -04:00
|
|
|
wanted = "hallo Hidu Test"
|
|
|
|
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopTestBackwardJumping_ExceptCorrectResult(_VimTest):
|
2009-07-06 05:47:27 -04:00
|
|
|
snippets = ("hallo", "hallo ${2:End} mitte${1:Beginning}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "Somelengthy Text" + JF + "Hi" + JB + \
|
|
|
|
"Lets replace it again" + JF + "Blah" + JF + JB*2 + JF
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "hallo Blah mitteLets replace it again"
|
2009-07-01 14:03:29 -04:00
|
|
|
class TabStopTestBackwardJumping2_ExceptCorrectResult(_VimTest):
|
2009-07-06 05:47:27 -04:00
|
|
|
snippets = ("hallo", "hallo $2 $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo" + EX + "Somelengthy Text" + JF + "Hi" + JB + \
|
|
|
|
"Lets replace it again" + JF + "Blah" + JF + JB*2 + JF
|
2009-07-02 03:49:42 -04:00
|
|
|
wanted = "hallo Blah Lets replace it again"
|
2009-07-01 14:03:29 -04:00
|
|
|
|
2009-07-01 14:22:12 -04:00
|
|
|
class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("hallo", "hallo $0\nnice $1 work\n$3 $2\nSeem to work")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys ="test hallo World" + ESC + "02f i" + EX + "world" + JF + "try" + \
|
|
|
|
JF + "test" + JF + "one more" + JF + JF
|
2009-07-02 05:48:35 -04:00
|
|
|
wanted = "test hallo one more\nnice world work\n" \
|
|
|
|
"test try\nSeem to work World"
|
2009-07-01 14:22:12 -04:00
|
|
|
|
2009-07-09 11:04:57 -04:00
|
|
|
class TabStop_TSInDefaultTextRLExample_OverwriteNone_ECR(_VimTest):
|
|
|
|
snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = """<div id="some_id">\n \n</div>"""
|
|
|
|
class TabStop_TSInDefaultTextRLExample_OverwriteFirst(_VimTest):
|
|
|
|
snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
|
|
|
|
keys = "test" + EX + " blah" + JF + "Hallo"
|
|
|
|
wanted = """<div blah>\n Hallo\n</div>"""
|
|
|
|
class TabStop_TSInDefaultTextRLExample_DeleteFirst(_VimTest):
|
|
|
|
snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
|
|
|
|
keys = "test" + EX + BS + JF + "Hallo"
|
|
|
|
wanted = """<div>\n Hallo\n</div>"""
|
2009-07-09 11:49:59 -04:00
|
|
|
class TabStop_TSInDefaultTextRLExample_OverwriteFirstJumpBack(_VimTest):
|
|
|
|
snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
|
|
|
|
keys = "test" + EX + "Hi" + JF + "Hallo" + JB + "SomethingElse" + JF + \
|
|
|
|
"Nupl" + JF + "Nox"
|
|
|
|
wanted = """<divSomethingElse>\n Nupl Nox\n</div>"""
|
2009-07-09 11:04:57 -04:00
|
|
|
class TabStop_TSInDefaultTextRLExample_OverwriteSecond(_VimTest):
|
|
|
|
snippets = ("test", """<div${1: id="${2:some_id}"}>\n $0\n</div>""")
|
|
|
|
keys = "test" + EX + JF + "no" + JF + "End"
|
|
|
|
wanted = """<div id="no">\n End\n</div>"""
|
2009-07-09 11:49:59 -04:00
|
|
|
class TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBack(_VimTest):
|
|
|
|
snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
|
|
|
|
keys = "test" + EX + JF + "no" + JF + "End" + JB + "yes" + JF + "Begin" \
|
|
|
|
+ JF + "Hi"
|
|
|
|
wanted = """<div id="yes">\n Begin Hi\n</div>"""
|
|
|
|
class TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBackTwice(_VimTest):
|
|
|
|
snippets = ("test", """<div${1: id="${2:some_id}"}>\n $3 $0\n</div>""")
|
|
|
|
keys = "test" + EX + JF + "no" + JF + "End" + JB + "yes" + JB + \
|
|
|
|
" allaway" + JF + "Third" + JF + "Last"
|
|
|
|
wanted = """<div allaway>\n Third Last\n</div>"""
|
|
|
|
|
|
|
|
class TabStop_TSInDefaultNested_OverwriteOneJumpBackToOther(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:this ${2:second ${3:third}}} $4")
|
|
|
|
keys = "test" + EX + JF + "Hallo" + JF + "Ende"
|
|
|
|
wanted = "hi this Hallo Ende"
|
|
|
|
class TabStop_TSInDefaultNested_OverwriteOneJumpToThird(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:this ${2:second ${3:third}}} $4")
|
|
|
|
keys = "test" + EX + JF + JF + "Hallo" + JF + "Ende"
|
|
|
|
wanted = "hi this second Hallo Ende"
|
|
|
|
class TabStop_TSInDefaultNested_OverwriteOneJumpAround(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:this ${2:second ${3:third}}} $4")
|
|
|
|
keys = "test" + EX + JF + JF + "Hallo" + JB+JB + "Blah" + JF + "Ende"
|
|
|
|
wanted = "hi Blah Ende"
|
|
|
|
|
|
|
|
class TabStop_TSInDefault_MirrorsOutside_DoNothing(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:this ${2:second}} $2")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi this second second"
|
|
|
|
class TabStop_TSInDefault_MirrorsOutside_OverwriteSecond(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:this ${2:second}} $2")
|
|
|
|
keys = "test" + EX + JF + "Hallo"
|
2009-07-10 02:46:49 -04:00
|
|
|
wanted = "hi this Hallo Hallo"
|
2009-07-09 11:49:59 -04:00
|
|
|
class TabStop_TSInDefault_MirrorsOutside_Overwrite(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:this ${2:second}} $2")
|
|
|
|
keys = "test" + EX + "Hallo"
|
|
|
|
wanted = "hi Hallo "
|
|
|
|
|
2009-07-10 06:06:58 -04:00
|
|
|
class TabStop_Multiline_Leave(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:first line\nsecond line} world" )
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi first line\nsecond line world"
|
|
|
|
class TabStop_Multiline_Overwrite(_VimTest):
|
|
|
|
snippets = ("test", "hi ${1:first line\nsecond line} world" )
|
|
|
|
keys = "test" + EX + "Nothing"
|
|
|
|
wanted = "hi Nothing world"
|
|
|
|
class TabStop_Multiline_MirrorInFront_Leave(_VimTest):
|
|
|
|
snippets = ("test", "hi $1 ${1:first line\nsecond line} world" )
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi first line\nsecond line first line\nsecond line world"
|
|
|
|
class TabStop_Multiline_MirrorInFront_Overwrite(_VimTest):
|
|
|
|
snippets = ("test", "hi $1 ${1:first line\nsecond line} world" )
|
|
|
|
keys = "test" + EX + "Nothing"
|
|
|
|
wanted = "hi Nothing Nothing world"
|
|
|
|
class TabStop_Multiline_DelFirstOverwriteSecond_Overwrite(_VimTest):
|
|
|
|
snippets = ("test", "hi $1 $2 ${1:first line\nsecond line} ${2:Hi} world" )
|
|
|
|
keys = "test" + EX + BS + JF + "Nothing"
|
|
|
|
wanted = "hi Nothing Nothing world"
|
|
|
|
|
|
|
|
###########################
|
|
|
|
# ShellCode Interpolation #
|
|
|
|
###########################
|
|
|
|
class TabStop_Shell_SimpleExample(_VimTest):
|
|
|
|
snippets = ("test", "hi `echo hallo` you!")
|
|
|
|
keys = "test" + EX + "and more"
|
|
|
|
wanted = "hi hallo you!and more"
|
|
|
|
class TabStop_Shell_TextInNextLine(_VimTest):
|
|
|
|
snippets = ("test", "hi `echo hallo`\nWeiter")
|
|
|
|
keys = "test" + EX + "and more"
|
|
|
|
wanted = "hi hallo\nWeiterand more"
|
|
|
|
class TabStop_Shell_InDefValue_Leave(_VimTest):
|
2009-07-16 11:34:36 -04:00
|
|
|
sleeptime = 0.09 # Do this very slowly
|
2009-07-10 06:06:58 -04:00
|
|
|
snippets = ("test", "Hallo ${1:now `echo fromecho`} end")
|
|
|
|
keys = "test" + EX + JF + "and more"
|
|
|
|
wanted = "Hallo now fromecho endand more"
|
|
|
|
class TabStop_Shell_InDefValue_Overwrite(_VimTest):
|
|
|
|
snippets = ("test", "Hallo ${1:now `echo fromecho`} end")
|
|
|
|
keys = "test" + EX + "overwrite" + JF + "and more"
|
|
|
|
wanted = "Hallo overwrite endand more"
|
2009-07-22 06:08:21 -04:00
|
|
|
class TabStop_Shell_TestEscapedChars_Overwrite(_VimTest):
|
|
|
|
snippets = ("test", r"""`echo \`echo "\\$hi"\``""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "$hi"
|
|
|
|
class TabStop_Shell_TestEscapedCharsAndShellVars_Overwrite(_VimTest):
|
|
|
|
snippets = ("test", r"""`hi="blah"; echo \`echo "$hi"\``""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "blah"
|
2009-07-10 06:06:58 -04:00
|
|
|
|
|
|
|
class TabStop_Shell_ShebangPython(_VimTest):
|
2009-07-16 11:34:36 -04:00
|
|
|
sleeptime = 0.09 # Do this very slowly
|
2009-07-10 06:06:58 -04:00
|
|
|
snippets = ("test", """Hallo ${1:now `#!/usr/bin/env python
|
|
|
|
print "Hallo Welt"
|
|
|
|
`} end""")
|
|
|
|
keys = "test" + EX + JF + "and more"
|
|
|
|
wanted = "Hallo now Hallo Welt endand more"
|
|
|
|
|
2009-07-13 05:36:13 -04:00
|
|
|
############################
|
|
|
|
# PythonCode Interpolation #
|
|
|
|
############################
|
2010-07-29 21:38:24 -04:00
|
|
|
|
2010-07-29 21:42:38 -04:00
|
|
|
#### Deprecated way ##########
|
2010-07-29 21:38:24 -04:00
|
|
|
class PythonCodeOld_SimpleExample(_VimTest):
|
2009-07-13 05:36:13 -04:00
|
|
|
snippets = ("test", """hi `!p res = "Hallo"` End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi Hallo End"
|
2010-07-29 21:38:24 -04:00
|
|
|
class PythonCodeOld_ReferencePlaceholder(_VimTest):
|
2009-07-13 05:36:13 -04:00
|
|
|
snippets = ("test", """${1:hi} `!p res = t[1]+".blah"` End""")
|
|
|
|
keys = "test" + EX + "ho"
|
|
|
|
wanted = "ho ho.blah End"
|
2010-07-29 21:38:24 -04:00
|
|
|
class PythonCodeOld_ReferencePlaceholderBefore(_VimTest):
|
2009-07-15 11:40:24 -04:00
|
|
|
snippets = ("test", """`!p res = len(t[1])*"#"`\n${1:some text}""")
|
|
|
|
keys = "test" + EX + "Hallo Welt"
|
|
|
|
wanted = "##########\nHallo Welt"
|
2010-07-29 21:38:24 -04:00
|
|
|
class PythonCodeOld_TransformedBeforeMultiLine(_VimTest):
|
2009-07-19 11:12:57 -04:00
|
|
|
snippets = ("test", """${1/.+/egal/m} ${1:`!p
|
|
|
|
res = "Hallo"`} End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "egal Hallo End"
|
2010-07-29 21:38:24 -04:00
|
|
|
class PythonCodeOld_IndentedMultiline(_VimTest):
|
2009-07-28 02:04:53 -04:00
|
|
|
snippets = ("test", """start `!p a = 1
|
|
|
|
b = 2
|
|
|
|
if b > a:
|
|
|
|
res = "b isbigger a"
|
|
|
|
else:
|
|
|
|
res = "a isbigger b"` end""")
|
|
|
|
keys = " test" + EX
|
|
|
|
wanted = " start b isbigger a end"
|
2009-07-13 05:36:13 -04:00
|
|
|
|
2010-07-29 21:38:24 -04:00
|
|
|
#### New way ##########
|
|
|
|
|
|
|
|
class PythonCode_UseNewOverOld(_VimTest):
|
|
|
|
snippets = ("test", """hi `!p res = "Old"
|
|
|
|
snip.rv = "New"` End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi New End"
|
|
|
|
|
|
|
|
class PythonCode_SimpleExample(_VimTest):
|
|
|
|
snippets = ("test", """hi `!p snip.rv = "Hallo"` End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi Hallo End"
|
|
|
|
|
|
|
|
class PythonCode_ReferencePlaceholder(_VimTest):
|
|
|
|
snippets = ("test", """${1:hi} `!p snip.rv = t[1]+".blah"` End""")
|
|
|
|
keys = "test" + EX + "ho"
|
|
|
|
wanted = "ho ho.blah End"
|
|
|
|
|
|
|
|
class PythonCode_ReferencePlaceholderBefore(_VimTest):
|
|
|
|
snippets = ("test", """`!p snip.rv = len(t[1])*"#"`\n${1:some text}""")
|
|
|
|
keys = "test" + EX + "Hallo Welt"
|
|
|
|
wanted = "##########\nHallo Welt"
|
|
|
|
|
|
|
|
class PythonCode_TransformedBeforeMultiLine(_VimTest):
|
|
|
|
snippets = ("test", """${1/.+/egal/m} ${1:`!p
|
|
|
|
snip.rv = "Hallo"`} End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "egal Hallo End"
|
|
|
|
|
|
|
|
class PythonCode_MultilineIndented(_VimTest):
|
|
|
|
snippets = ("test", """start `!p a = 1
|
|
|
|
b = 2
|
|
|
|
if b > a:
|
|
|
|
snip.rv = "b isbigger a"
|
|
|
|
else:
|
|
|
|
snip.rv = "a isbigger b"` end""")
|
|
|
|
keys = " test" + EX
|
|
|
|
wanted = " start b isbigger a end"
|
|
|
|
|
|
|
|
class PythonCode_SimpleAppend(_VimTest):
|
|
|
|
snippets = ("test", """hi `!p snip.rv = "Hallo1"
|
|
|
|
snip += "Hallo2"` End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi Hallo1\nHallo2 End"
|
|
|
|
|
|
|
|
class PythonCode_MultiAppend(_VimTest):
|
|
|
|
snippets = ("test", """hi `!p snip.rv = "Hallo1"
|
|
|
|
snip += "Hallo2"
|
|
|
|
snip += "Hallo3"` End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi Hallo1\nHallo2\nHallo3 End"
|
|
|
|
|
|
|
|
class PythonCode_MultiAppend(_VimTest):
|
|
|
|
snippets = ("test", """hi `!p snip.rv = "Hallo1"
|
|
|
|
snip += "Hallo2"
|
|
|
|
snip += "Hallo3"` End""")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "hi Hallo1\nHallo2\nHallo3 End"
|
|
|
|
|
|
|
|
class PythonCode_MultiAppendSimpleIndent(_VimTest):
|
|
|
|
snippets = ("test", """hi
|
|
|
|
`!p snip.rv="Hallo1"
|
|
|
|
snip += "Hallo2"
|
|
|
|
snip += "Hallo3"`
|
|
|
|
End""")
|
|
|
|
keys = """
|
|
|
|
test""" + EX
|
|
|
|
wanted = """
|
|
|
|
hi
|
|
|
|
Hallo1
|
|
|
|
Hallo2
|
|
|
|
Hallo3
|
|
|
|
End"""
|
|
|
|
|
|
|
|
class PythonCode_SimpleMkline(_VimTest):
|
|
|
|
snippets = ("test", r"""hi
|
|
|
|
`!p snip.rv="Hallo1\n"
|
|
|
|
snip.rv += snip.mkline("Hallo2") + "\n"
|
|
|
|
snip.rv += snip.mkline("Hallo3")`
|
|
|
|
End""")
|
|
|
|
keys = """
|
|
|
|
test""" + EX
|
|
|
|
wanted = """
|
|
|
|
hi
|
|
|
|
Hallo1
|
|
|
|
Hallo2
|
|
|
|
Hallo3
|
|
|
|
End"""
|
|
|
|
|
|
|
|
class PythonCode_MultiAppendShift(_VimTest):
|
|
|
|
snippets = ("test", r"""hi
|
|
|
|
`!p snip.rv="i1"
|
|
|
|
snip += "i1"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i2"
|
|
|
|
snip << 2
|
|
|
|
snip += "i0"
|
|
|
|
snip >> 3
|
|
|
|
snip += "i3"`
|
|
|
|
End""")
|
|
|
|
keys = """
|
|
|
|
test""" + EX
|
|
|
|
wanted = """
|
|
|
|
hi
|
|
|
|
i1
|
|
|
|
i1
|
|
|
|
i2
|
|
|
|
i0
|
|
|
|
i3
|
|
|
|
End"""
|
|
|
|
|
|
|
|
class PythonCode_MultiAppendShiftMethods(_VimTest):
|
|
|
|
snippets = ("test", r"""hi
|
|
|
|
`!p snip.rv="i1\n"
|
|
|
|
snip.rv += snip.mkline("i1\n")
|
|
|
|
snip.shift(1)
|
|
|
|
snip.rv += snip.mkline("i2\n")
|
|
|
|
snip.unshift(2)
|
|
|
|
snip.rv += snip.mkline("i0\n")
|
|
|
|
snip.shift(3)
|
|
|
|
snip.rv += snip.mkline("i3")`
|
|
|
|
End""")
|
|
|
|
keys = """
|
|
|
|
test""" + EX
|
|
|
|
wanted = """
|
|
|
|
hi
|
|
|
|
i1
|
|
|
|
i1
|
|
|
|
i2
|
|
|
|
i0
|
|
|
|
i3
|
|
|
|
End"""
|
|
|
|
|
|
|
|
|
|
|
|
class PythonCode_ResetIndent(_VimTest):
|
|
|
|
snippets = ("test", r"""hi
|
|
|
|
`!p snip.rv="i1"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i2"
|
|
|
|
snip.reset_indent()
|
|
|
|
snip += "i1"
|
|
|
|
snip << 1
|
|
|
|
snip += "i0"
|
|
|
|
snip.reset_indent()
|
|
|
|
snip += "i1"`
|
|
|
|
End""")
|
|
|
|
keys = """
|
|
|
|
test""" + EX
|
|
|
|
wanted = """
|
|
|
|
hi
|
|
|
|
i1
|
|
|
|
i2
|
|
|
|
i1
|
|
|
|
i0
|
|
|
|
i1
|
|
|
|
End"""
|
|
|
|
|
|
|
|
class PythonCode_IndentEtSw(_VimTest):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=3\n")
|
|
|
|
self.send(":set expandtab\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set noexpandtab\n")
|
|
|
|
snippets = ("test", r"""hi
|
|
|
|
`!p snip.rv = "i1"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i2"
|
|
|
|
snip << 2
|
|
|
|
snip += "i0"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i1"
|
|
|
|
`
|
|
|
|
End""")
|
|
|
|
keys = """ test""" + EX
|
|
|
|
wanted = """ hi
|
|
|
|
i1
|
|
|
|
i2
|
|
|
|
i0
|
|
|
|
i1
|
|
|
|
End"""
|
|
|
|
|
|
|
|
class PythonCode_IndentEtSwOffset(_VimTest):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=3\n")
|
|
|
|
self.send(":set expandtab\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set noexpandtab\n")
|
|
|
|
snippets = ("test", r"""hi
|
|
|
|
`!p snip.rv = "i1"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i2"
|
|
|
|
snip << 2
|
|
|
|
snip += "i0"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i1"
|
|
|
|
`
|
|
|
|
End""")
|
|
|
|
keys = """ test""" + EX
|
|
|
|
wanted = """ hi
|
|
|
|
i1
|
|
|
|
i2
|
|
|
|
i0
|
|
|
|
i1
|
|
|
|
End"""
|
|
|
|
|
|
|
|
class PythonCode_IndentNoetSwTs(_VimTest):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=3\n")
|
|
|
|
self.send(":set ts=4\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set ts=8\n")
|
|
|
|
snippets = ("test", r"""hi
|
|
|
|
`!p snip.rv = "i1"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i2"
|
|
|
|
snip << 2
|
|
|
|
snip += "i0"
|
|
|
|
snip >> 1
|
|
|
|
snip += "i1"
|
|
|
|
`
|
|
|
|
End""")
|
|
|
|
keys = """ test""" + EX
|
|
|
|
wanted = """ hi
|
|
|
|
i1
|
|
|
|
\t i2
|
|
|
|
i0
|
|
|
|
i1
|
|
|
|
End"""
|
|
|
|
|
|
|
|
# Test using 'opt'
|
|
|
|
class PythonCode_OptExists(_VimTest):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(':let g:UStest="yes"\n')
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":unlet g:UStest\n")
|
|
|
|
snippets = ("test", r"""hi `!p snip.rv = snip.opt("g:UStest") or "no"` End""")
|
|
|
|
keys = """test""" + EX
|
|
|
|
wanted = """hi yes End"""
|
|
|
|
|
|
|
|
class PythonCode_OptNoExists(_VimTest):
|
|
|
|
snippets = ("test", r"""hi `!p snip.rv = snip.opt("g:UStest") or "no"` End""")
|
|
|
|
keys = """test""" + EX
|
|
|
|
wanted = """hi no End"""
|
|
|
|
|
|
|
|
# locals
|
|
|
|
class PythonCode_Locals(_VimTest):
|
2010-08-16 20:59:41 -04:00
|
|
|
snippets = ("test", r"""hi `!p a = "test"
|
|
|
|
snip.rv = "nothing"` `!p snip.rv = a
|
2010-07-29 21:38:24 -04:00
|
|
|
` End""")
|
|
|
|
keys = """test""" + EX
|
|
|
|
wanted = """hi nothing test End"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-15 10:28:33 -04:00
|
|
|
###########################
|
|
|
|
# VimScript Interpolation #
|
|
|
|
###########################
|
|
|
|
class TabStop_VimScriptInterpolation_SimpleExample(_VimTest):
|
|
|
|
snippets = ("test", """hi `!v indent(".")` End""")
|
|
|
|
keys = " test" + EX
|
|
|
|
wanted = " hi 4 End"
|
|
|
|
|
2009-07-29 03:49:44 -04:00
|
|
|
#############
|
|
|
|
# EXPANDTAB #
|
|
|
|
#############
|
|
|
|
class _ExpandTabs(_VimTest):
|
|
|
|
def _options_on(self):
|
2010-11-22 08:59:06 -05:00
|
|
|
self.send(":set sw=3\n")
|
2009-07-29 03:49:44 -04:00
|
|
|
self.send(":set expandtab\n")
|
|
|
|
def _options_off(self):
|
2010-11-22 08:59:06 -05:00
|
|
|
self.send(":set sw=8\n")
|
2009-07-29 03:49:44 -04:00
|
|
|
self.send(":set noexpandtab\n")
|
|
|
|
|
|
|
|
class RecTabStopsWithExpandtab_SimpleExample_ECR(_ExpandTabs):
|
|
|
|
snippets = ("m", "\tBlaahblah \t\t ")
|
|
|
|
keys = "m" + EX
|
2010-11-18 11:58:15 -05:00
|
|
|
wanted = " Blaahblah \t\t "
|
2009-07-29 03:49:44 -04:00
|
|
|
|
|
|
|
class RecTabStopsWithExpandtab_SpecialIndentProblem_ECR(_ExpandTabs):
|
|
|
|
snippets = (
|
|
|
|
("m1", "Something"),
|
|
|
|
("m", "\t$0"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + '\nHallo'
|
|
|
|
wanted = " Something\n Hallo"
|
|
|
|
def _options_on(self):
|
|
|
|
_ExpandTabs._options_on(self)
|
|
|
|
self.send(":set indentkeys=o,O,*<Return>,<>>,{,}\n")
|
|
|
|
self.send(":set indentexpr=8\n")
|
|
|
|
def _options_off(self):
|
|
|
|
_ExpandTabs._options_off(self)
|
|
|
|
self.send(":set indentkeys=\n")
|
|
|
|
self.send(":set indentexpr=\n")
|
|
|
|
|
|
|
|
|
2009-07-16 11:00:25 -04:00
|
|
|
|
|
|
|
###############################
|
|
|
|
# Recursive (Nested) Snippets #
|
|
|
|
###############################
|
2009-07-16 08:10:59 -04:00
|
|
|
class RecTabStops_SimpleCase_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("m", "[ ${1:first} ${2:sec} ]")
|
|
|
|
keys = "m" + EX + "m" + EX + "hello" + JF + "world" + JF + "end"
|
|
|
|
wanted = "[ [ hello world ] end ]"
|
|
|
|
class RecTabStops_SimpleCaseLeaveSecondSecond_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("m", "[ ${1:first} ${2:sec} ]")
|
|
|
|
keys = "m" + EX + "m" + EX + "hello" + JF + "world" + JF + JF + "end"
|
|
|
|
wanted = "[ [ hello world ] sec ]end"
|
|
|
|
class RecTabStops_SimpleCaseLeaveFirstSecond_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("m", "[ ${1:first} ${2:sec} ]")
|
|
|
|
keys = "m" + EX + "m" + EX + "hello" + JF + JF + "world" + JF + "end"
|
|
|
|
wanted = "[ [ hello sec ] world ]end"
|
2009-07-05 16:25:01 -04:00
|
|
|
|
2009-07-16 11:00:25 -04:00
|
|
|
class RecTabStops_InnerWOTabStop_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m1", "Just some Text"),
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + "hi" + JF + "two" + JF + "end"
|
|
|
|
wanted = "[ Just some Texthi two ]end"
|
|
|
|
class RecTabStops_InnerWOTabStopTwiceDirectly_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m1", "JST"),
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + " m1" + EX + "hi" + JF + "two" + JF + "end"
|
|
|
|
wanted = "[ JST JSThi two ]end"
|
|
|
|
class RecTabStops_InnerWOTabStopTwice_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m1", "JST"),
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + JF + "m1" + EX + "hi" + JF + "end"
|
|
|
|
wanted = "[ JST JSThi ]end"
|
|
|
|
class RecTabStops_OuterOnlyWithZeroTS_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "A $0 B"),
|
|
|
|
("m1", "C $1 D $0 E"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + "CD" + JF + "DE"
|
|
|
|
wanted = "A C CD D DE E B"
|
|
|
|
class RecTabStops_OuterOnlyWithZero_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "A $0 B"),
|
|
|
|
("m1", "C $1 D $0 E"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + "CD" + JF + "DE"
|
|
|
|
wanted = "A C CD D DE E B"
|
|
|
|
class RecTabStops_ExpandedInZeroTS_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "A $0 B $1"),
|
|
|
|
("m1", "C $1 D $0 E"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "hi" + JF + "m1" + EX + "CD" + JF + "DE"
|
|
|
|
wanted = "A C CD D DE E B hi"
|
|
|
|
class RecTabStops_ExpandedInZeroTSTwice_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "A $0 B $1"),
|
|
|
|
("m1", "C $1 D $0 E"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "hi" + JF + "m" + EX + "again" + JF + "m1" + \
|
|
|
|
EX + "CD" + JF + "DE"
|
|
|
|
wanted = "A A C CD D DE E B again B hi"
|
|
|
|
class RecTabStops_ExpandedInZeroTSSecondTimeIgnoreZTS_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "A $0 B $1"),
|
|
|
|
("m1", "C $1 D $0 E"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "hi" + JF + "m" + EX + "m1" + EX + "CD" + JF + "DE"
|
|
|
|
wanted = "A A DE B C CD D E B hi"
|
|
|
|
|
|
|
|
class RecTabStops_MirrorInnerSnippet_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "[ $1 $2 ] $1"),
|
|
|
|
("m1", "ASnip $1 ASnip $2 ASnip"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + "Hallo" + JF + "Hi" + JF + "two" + JF + "end"
|
|
|
|
wanted = "[ ASnip Hallo ASnip Hi ASnip two ] ASnip Hallo ASnip Hi ASnipend"
|
|
|
|
|
|
|
|
class RecTabStops_NotAtBeginningOfTS_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("m", "[ ${1:first} ${2:sec} ]")
|
|
|
|
keys = "m" + EX + "hello m" + EX + "hi" + JF + "two" + JF + "three" + \
|
|
|
|
JF + "end"
|
|
|
|
wanted = "[ hello [ hi two ] three ]end"
|
|
|
|
class RecTabStops_InNewlineInTabstop_ExceptCorrectResult(_VimTest):
|
2009-08-17 11:33:28 -04:00
|
|
|
sleeptime = 0.09 # Do this very slowly
|
2009-07-16 11:00:25 -04:00
|
|
|
snippets = ("m", "[ ${1:first} ${2:sec} ]")
|
|
|
|
keys = "m" + EX + "hello\nm" + EX + "hi" + JF + "two" + JF + "three" + \
|
|
|
|
JF + "end"
|
|
|
|
wanted = "[ hello\n[ hi two ] three ]end"
|
|
|
|
class RecTabStops_InNewlineInTabstopNotAtBeginOfLine_ECR(_VimTest):
|
|
|
|
snippets = ("m", "[ ${1:first} ${2:sec} ]")
|
|
|
|
keys = "m" + EX + "hello\nhello again m" + EX + "hi" + JF + "two" + \
|
|
|
|
JF + "three" + JF + "end"
|
|
|
|
wanted = "[ hello\nhello again [ hi two ] three ]end"
|
|
|
|
|
2009-07-16 11:49:35 -04:00
|
|
|
class RecTabStops_InNewlineMultiline_ECR(_VimTest):
|
|
|
|
snippets = ("m", "M START\n$0\nM END")
|
|
|
|
keys = "m" + EX + "m" + EX
|
|
|
|
wanted = "M START\nM START\n\nM END\nM END"
|
2009-07-16 12:08:32 -04:00
|
|
|
class RecTabStops_InNewlineManualIndent_ECR(_VimTest):
|
|
|
|
snippets = ("m", "M START\n$0\nM END")
|
|
|
|
keys = "m" + EX + " m" + EX + "hi"
|
|
|
|
wanted = "M START\n M START\n hi\n M END\nM END"
|
2009-07-17 17:42:33 -04:00
|
|
|
class RecTabStops_InNewlineManualIndentTextInFront_ECR(_VimTest):
|
|
|
|
snippets = ("m", "M START\n$0\nM END")
|
|
|
|
keys = "m" + EX + " hallo m" + EX + "hi"
|
|
|
|
wanted = "M START\n hallo M START\n hi\n M END\nM END"
|
2009-07-16 12:08:32 -04:00
|
|
|
class RecTabStops_InNewlineMultilineWithIndent_ECR(_VimTest):
|
|
|
|
snippets = ("m", "M START\n $0\nM END")
|
|
|
|
keys = "m" + EX + "m" + EX + "hi"
|
|
|
|
wanted = "M START\n M START\n hi\n M END\nM END"
|
|
|
|
class RecTabStops_InNewlineMultilineWithNonZeroTS_ECR(_VimTest):
|
|
|
|
snippets = ("m", "M START\n $1\nM END -> $0")
|
|
|
|
keys = "m" + EX + "m" + EX + "hi" + JF + "hallo"
|
|
|
|
wanted = "M START\n M START\n hi\n M END -> \n" \
|
|
|
|
"M END -> hallo"
|
2009-07-16 11:34:36 -04:00
|
|
|
|
|
|
|
class RecTabStops_BarelyNotLeavingInner_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m" + EX + "a" + 3*ARR_L + JF + "hallo" + \
|
|
|
|
JF + "world" + JF + "end"
|
|
|
|
wanted = "[ [ a hallo ] world ]end"
|
|
|
|
class RecTabStops_LeavingInner_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m" + EX + "a" + 4*ARR_L + JF + "hallo" + \
|
|
|
|
JF + "world"
|
|
|
|
wanted = "[ [ a sec ] hallo ]world"
|
|
|
|
class RecTabStops_LeavingInnerInner_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m" + EX + "m" + EX + "a" + 4*ARR_L + JF + "hallo" + \
|
|
|
|
JF + "world" + JF + "end"
|
|
|
|
wanted = "[ [ [ a sec ] hallo ] world ]end"
|
|
|
|
class RecTabStops_LeavingInnerInnerTwo_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m" + EX + "m" + EX + "a" + 6*ARR_L + JF + "hallo" + \
|
|
|
|
JF + "end"
|
|
|
|
wanted = "[ [ [ a sec ] sec ] hallo ]end"
|
2009-07-16 11:00:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
class RecTabStops_IgnoreZeroTS_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m1", "[ ${1:first} $0 ${2:sec} ]"),
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + "hi" + JF + "two" + \
|
|
|
|
JF + "three" + JF + "end"
|
|
|
|
wanted = "[ [ hi two ] three ]end"
|
|
|
|
class RecTabStops_MirroredZeroTS_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("m1", "[ ${1:first} ${0:Year, some default text} $0 ${2:sec} ]"),
|
|
|
|
("m", "[ ${1:first} ${2:sec} ]"),
|
|
|
|
)
|
|
|
|
keys = "m" + EX + "m1" + EX + "hi" + JF + "two" + \
|
|
|
|
JF + "three" + JF + "end"
|
|
|
|
wanted = "[ [ hi two ] three ]end"
|
|
|
|
|
|
|
|
###########
|
|
|
|
# MIRRORS #
|
|
|
|
###########
|
2009-07-03 05:39:46 -04:00
|
|
|
class TextTabStopTextAfterTab_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 Hinten\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo Hinten\nhallo"
|
|
|
|
class TextTabStopTextBeforeTab_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "Vorne $1\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "Vorne hallo\nhallo"
|
|
|
|
class TextTabStopTextSurroundedTab_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "Vorne $1 Hinten\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo test"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "Vorne hallo test Hinten\nhallo test"
|
|
|
|
|
|
|
|
class TextTabStopTextBeforeMirror_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\nVorne $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo\nVorne hallo"
|
|
|
|
class TextTabStopAfterMirror_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\n$1 Hinten")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo\nhallo Hinten"
|
|
|
|
class TextTabStopSurroundMirror_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\nVorne $1 Hinten")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo welt"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo welt\nVorne hallo welt Hinten"
|
|
|
|
class TextTabStopAllSurrounded_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ObenVorne $1 ObenHinten\nVorne $1 Hinten")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo welt"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "ObenVorne hallo welt ObenHinten\nVorne hallo welt Hinten"
|
|
|
|
|
2009-07-03 07:54:35 -04:00
|
|
|
class MirrorBeforeTabstopLeave_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1:this is it} $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX
|
2009-07-03 07:54:35 -04:00
|
|
|
wanted = "this is it this is it this is it"
|
|
|
|
class MirrorBeforeTabstopOverwrite_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1:this is it} $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "a"
|
2009-07-03 07:54:35 -04:00
|
|
|
wanted = "a a a"
|
|
|
|
|
2009-07-03 05:39:46 -04:00
|
|
|
class TextTabStopSimpleMirrorMultiline_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo\nhallo"
|
|
|
|
class SimpleMirrorMultilineMany_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", " $1\n$1\na$1b\n$1\ntest $1 mich")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = " hallo\nhallo\nahallob\nhallo\ntest hallo mich"
|
|
|
|
class MultilineTabStopSimpleMirrorMultiline_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\n\n$1\n\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo Du\nHi"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo Du\nHi\n\nhallo Du\nHi\n\nhallo Du\nHi"
|
|
|
|
class MultilineTabStopSimpleMirrorMultiline1_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\n$1\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo Du\nHi"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo Du\nHi\nhallo Du\nHi\nhallo Du\nHi"
|
|
|
|
class MultilineTabStopSimpleMirrorDeleteInLine_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\n$1\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo Du\nHi\b\bAch Blah"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo Du\nAch Blah\nhallo Du\nAch Blah\nhallo Du\nAch Blah"
|
2009-07-04 09:01:19 -04:00
|
|
|
class TextTabStopSimpleMirrorMultilineMirrorInFront_ECR(_VimTest):
|
|
|
|
snippets = ("test", "$1\n${1:sometext}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo\nagain"
|
2009-07-04 09:01:19 -04:00
|
|
|
wanted = "hallo\nagain\nhallo\nagain"
|
2009-07-03 05:39:46 -04:00
|
|
|
|
|
|
|
class SimpleMirrorDelete_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo\b\b"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hal\nhal"
|
|
|
|
|
|
|
|
class SimpleMirrorSameLine_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo hallo"
|
2009-07-04 06:14:13 -04:00
|
|
|
class Transformation_SimpleMirrorSameLineBeforeTabDefVal_ECR(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1:replace me}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo foo"
|
2009-07-04 06:14:13 -04:00
|
|
|
wanted = "hallo foo hallo foo"
|
2009-07-03 05:39:46 -04:00
|
|
|
class SimpleMirrorSameLineMany_ExceptCorrectResult(_VimTest):
|
2009-07-04 17:04:12 -04:00
|
|
|
snippets = ("test", "$1 $1 $1 $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo du"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "hallo du hallo du hallo du hallo du"
|
|
|
|
class SimpleMirrorSameLineManyMultiline_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 $1 $1 $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo du\nwie gehts"
|
|
|
|
wanted = "hallo du\nwie gehts hallo du\nwie gehts hallo du\nwie gehts" \
|
|
|
|
" hallo du\nwie gehts"
|
2009-07-03 05:39:46 -04:00
|
|
|
class SimpleMirrorDeleteSomeEnterSome_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo\b\bhups"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "halhups\nhalhups"
|
|
|
|
|
|
|
|
|
|
|
|
class SimpleTabstopWithDefaultSimpelType_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha ${1:defa}\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "world"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "ha world\nworld"
|
|
|
|
class SimpleTabstopWithDefaultComplexType_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha ${1:default value} $1\nanother: $1 mirror")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "world"
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "ha world world\nanother: world mirror"
|
|
|
|
class SimpleTabstopWithDefaultSimpelKeep_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha ${1:defa}\n$1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "ha defa\ndefa"
|
|
|
|
class SimpleTabstopWithDefaultComplexKeep_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha ${1:default value} $1\nanother: $1 mirror")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX
|
2009-07-03 05:39:46 -04:00
|
|
|
wanted = "ha default value default value\nanother: default value mirror"
|
|
|
|
|
2009-07-06 17:26:01 -04:00
|
|
|
class TabstopWithMirrorManyFromAll_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha $5 ${1:blub} $4 $0 ${2:$1.h} $1 $3 ${4:More}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hi" + JF + "hu" + JF + "hub" + JF + "hulla" + \
|
|
|
|
JF + "blah" + JF + "end"
|
2009-07-06 17:26:01 -04:00
|
|
|
wanted = "ha blah hi hulla end hu hi hub hulla"
|
2009-07-03 06:05:34 -04:00
|
|
|
class TabstopWithMirrorInDefaultNoType_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha ${1:blub} ${2:$1.h}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX
|
2009-07-03 06:05:34 -04:00
|
|
|
wanted = "ha blub blub.h"
|
|
|
|
class TabstopWithMirrorInDefaultTwiceAndExtra_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha $1 ${2:$1.h $1.c}\ntest $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "stdin"
|
2009-07-03 06:05:34 -04:00
|
|
|
wanted = "ha stdin stdin.h stdin.c\ntest stdin"
|
2009-07-03 06:11:09 -04:00
|
|
|
class TabstopWithMirrorInDefaultMultipleLeave_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha $1 ${2:snip} ${3:$1.h $2}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "stdin"
|
2009-07-03 06:11:09 -04:00
|
|
|
wanted = "ha stdin snip stdin.h snip"
|
|
|
|
class TabstopWithMirrorInDefaultMultipleOverwrite_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha $1 ${2:snip} ${3:$1.h $2}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "stdin" + JF + "do snap"
|
2009-07-03 06:11:09 -04:00
|
|
|
wanted = "ha stdin do snap stdin.h do snap"
|
2009-07-03 06:05:34 -04:00
|
|
|
class TabstopWithMirrorInDefaultOverwrite_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "ha $1 ${2:$1.h}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "stdin" + JF + "overwritten"
|
2009-07-03 06:05:34 -04:00
|
|
|
wanted = "ha stdin overwritten"
|
2009-07-03 05:39:46 -04:00
|
|
|
|
2009-07-03 07:54:35 -04:00
|
|
|
class MirrorRealLifeExample_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("for", "for(size_t ${2:i} = 0; $2 < ${1:count}; ${3:++$2})" \
|
2009-07-09 09:30:23 -04:00
|
|
|
"\n{\n" + EX + "${0:/* code */}\n}"),
|
2009-07-03 07:54:35 -04:00
|
|
|
)
|
2009-07-09 09:30:23 -04:00
|
|
|
keys ="for" + EX + "100" + JF + "avar\b\b\b\ba_variable" + JF + \
|
|
|
|
"a_variable *= 2" + JF + "// do nothing"
|
2009-07-03 07:54:35 -04:00
|
|
|
wanted = """for(size_t a_variable = 0; a_variable < 100; a_variable *= 2)
|
|
|
|
{
|
|
|
|
\t// do nothing
|
|
|
|
}"""
|
2009-07-01 14:03:29 -04:00
|
|
|
|
|
|
|
|
2009-07-03 07:54:35 -04:00
|
|
|
###################
|
|
|
|
# TRANSFORMATIONS #
|
|
|
|
###################
|
|
|
|
class Transformation_SimpleCase_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/foo/batzl/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo foo boy"
|
2009-07-03 07:54:35 -04:00
|
|
|
wanted = "hallo foo boy hallo batzl boy"
|
|
|
|
class Transformation_SimpleCaseNoTransform_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/foo/batzl/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 07:54:35 -04:00
|
|
|
wanted = "hallo hallo"
|
2009-07-04 06:14:13 -04:00
|
|
|
class Transformation_SimpleCaseTransformInFront_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "${1/foo/batzl/} $1")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo foo"
|
2009-07-04 06:14:13 -04:00
|
|
|
wanted = "hallo batzl hallo foo"
|
|
|
|
class Transformation_SimpleCaseTransformInFrontDefVal_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1/foo/batzl/} ${1:replace me}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo foo"
|
2009-07-04 06:14:13 -04:00
|
|
|
wanted = "hallo batzl hallo foo"
|
2009-07-03 11:50:52 -04:00
|
|
|
class Transformation_MultipleTransformations_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1:Some Text}${1/.+/\U$0\E/}\n${1/.+/\L$0\E/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "SomE tExt "
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "SomE tExt SOME TEXT \nsome text "
|
2009-07-04 17:01:23 -04:00
|
|
|
class Transformation_TabIsAtEndAndDeleted_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1/.+/is something/}${1:some}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo test" + EX + "some\b\b\b\b\b"
|
2009-07-04 17:01:23 -04:00
|
|
|
wanted = "hallo "
|
|
|
|
class Transformation_TabIsAtEndAndDeleted1_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1/.+/is something/}${1:some}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo test" + EX + "some\b\b\b\bmore"
|
2009-07-04 17:01:23 -04:00
|
|
|
wanted = "hallo is somethingmore"
|
|
|
|
class Transformation_TabIsAtEndNoTextLeave_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1/.+/is something/}${1}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo test" + EX
|
2009-07-04 17:01:23 -04:00
|
|
|
wanted = "hallo "
|
|
|
|
class Transformation_TabIsAtEndNoTextType_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1/.+/is something/}${1}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hallo test" + EX + "b"
|
2009-07-04 17:01:23 -04:00
|
|
|
wanted = "hallo is somethingb"
|
2009-07-06 15:16:02 -04:00
|
|
|
class Transformation_InsideTabLeaveAtDefault_ECR(_VimTest):
|
2009-07-06 15:45:30 -04:00
|
|
|
snippets = ("test", r"$1 ${2:${1/.+/(?0:defined $0)/}}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "sometext" + JF
|
2009-07-06 15:16:02 -04:00
|
|
|
wanted = "sometext defined sometext"
|
|
|
|
class Transformation_InsideTabOvertype_ECR(_VimTest):
|
2009-07-06 15:45:30 -04:00
|
|
|
snippets = ("test", r"$1 ${2:${1/.+/(?0:defined $0)/}}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "sometext" + JF + "overwrite"
|
2009-07-06 15:16:02 -04:00
|
|
|
wanted = "sometext overwrite"
|
2009-07-04 17:01:23 -04:00
|
|
|
|
2009-07-03 11:50:52 -04:00
|
|
|
|
2009-07-03 10:13:39 -04:00
|
|
|
class Transformation_Backreference_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/([ab])oo/$1ull/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "foo boo aoo"
|
2009-07-03 10:13:39 -04:00
|
|
|
wanted = "foo boo aoo foo bull aoo"
|
|
|
|
class Transformation_BackreferenceTwice_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/(dead) (par[^ ]*)/this $2 is a bit $1/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "dead parrot"
|
2009-07-03 10:13:39 -04:00
|
|
|
wanted = "dead parrot this parrot is a bit dead"
|
|
|
|
|
|
|
|
class Transformation_CleverTransformUpercaseChar_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/(.)/\u$1/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 10:13:39 -04:00
|
|
|
wanted = "hallo Hallo"
|
|
|
|
class Transformation_CleverTransformLowercaseChar_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/(.*)/\l$1/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "Hallo"
|
2009-07-03 10:13:39 -04:00
|
|
|
wanted = "Hallo hallo"
|
|
|
|
class Transformation_CleverTransformLongUpper_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/(.*)/\U$1\E/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "hallo"
|
2009-07-03 10:13:39 -04:00
|
|
|
wanted = "hallo HALLO"
|
|
|
|
class Transformation_CleverTransformLongLower_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/(.*)/\L$1\E/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "HALLO"
|
2009-07-03 10:13:39 -04:00
|
|
|
wanted = "HALLO hallo"
|
|
|
|
|
2009-07-03 11:50:52 -04:00
|
|
|
class Transformation_ConditionalInsertionSimple_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/(^a).*/(?0:began with an a)/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "a some more text"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "a some more text began with an a"
|
|
|
|
class Transformation_CIBothDefinedNegative_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/(?:(^a)|(^b)).*/(?1:yes:no)/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "b some"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "b some no"
|
|
|
|
class Transformation_CIBothDefinedPositive_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1/(?:(^a)|(^b)).*/(?1:yes:no)/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "a some"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "a some yes"
|
|
|
|
class Transformation_ConditionalInsertRWEllipsis_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/(\w+(?:\W+\w+){,7})\W*(.+)?/$1(?2:...)/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "a b c d e f ghhh h oha"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "a b c d e f ghhh h oha a b c d e f ghhh h..."
|
2009-07-19 10:44:29 -04:00
|
|
|
class Transformation_ConditionalInConditional_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}")
|
|
|
|
keys = "test" + EX + "hallo" + ESC + "$a\n" + \
|
|
|
|
"test" + EX + "hallo-" + ESC + "$a\n" + \
|
|
|
|
"test" + EX + "hallo->"
|
|
|
|
wanted = "hallo .\nhallo- >\nhallo-> "
|
2009-07-03 11:50:52 -04:00
|
|
|
|
|
|
|
class Transformation_CINewlines_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/, */\n/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "test, hallo"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "test, hallo test\nhallo"
|
2009-07-04 18:26:19 -04:00
|
|
|
class Transformation_CIEscapedParensinReplace_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/hal((?:lo)|(?:ul))/(?1:ha\($1\))/}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "test, halul"
|
2009-07-04 18:26:19 -04:00
|
|
|
wanted = "test, halul test, ha(ul)"
|
2009-07-03 11:50:52 -04:00
|
|
|
|
|
|
|
class Transformation_OptionIgnoreCase_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/test/blah/i}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "TEST"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "TEST blah"
|
|
|
|
class Transformation_OptionReplaceGlobal_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/, */-/g}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "a, nice, building"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "a, nice, building a-nice-building"
|
|
|
|
class Transformation_OptionReplaceGlobalMatchInReplace_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1/, */, /g}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "a, nice, building"
|
2009-07-03 11:50:52 -04:00
|
|
|
wanted = "a, nice, building a, nice, building"
|
|
|
|
|
2009-07-04 06:14:13 -04:00
|
|
|
###################
|
|
|
|
# CURSOR MOVEMENT #
|
|
|
|
###################
|
2009-07-04 09:01:19 -04:00
|
|
|
class CursorMovement_Multiline_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${1:a tab}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "this is something\nvery nice\nnot" + JF + "more text"
|
|
|
|
wanted = "this is something\nvery nice\nnot " \
|
|
|
|
"this is something\nvery nice\nnotmore text"
|
2009-07-04 06:14:13 -04:00
|
|
|
|
2009-07-05 16:25:01 -04:00
|
|
|
|
|
|
|
######################
|
|
|
|
# INSERT MODE MOVING #
|
|
|
|
######################
|
|
|
|
class IMMoving_CursorsKeys_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1:Some}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "text" + 3*ARR_U + 6*ARR_D
|
2009-07-05 16:25:01 -04:00
|
|
|
wanted = "text"
|
2009-07-06 04:31:12 -04:00
|
|
|
class IMMoving_DoNotAcceptInputWhenMoved_ECR(_VimTest):
|
2009-07-05 16:25:01 -04:00
|
|
|
snippets = ("test", r"$1 ${1:a tab}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "this" + ARR_L + "hallo"
|
2009-07-05 16:25:01 -04:00
|
|
|
wanted = "this thihallos"
|
2009-07-06 04:31:12 -04:00
|
|
|
class IMMoving_NoExiting_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${2:a tab} ${1:Tab}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hello test this" + ESC + "02f i" + EX + "tab" + 7*ARR_L + \
|
|
|
|
JF + "hallo"
|
2009-07-06 04:31:12 -04:00
|
|
|
wanted = "hello tab hallo tab this"
|
|
|
|
class IMMoving_NoExitingEventAtEnd_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${2:a tab} ${1:Tab}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hello test this" + ESC + "02f i" + EX + "tab" + JF + "hallo"
|
2009-07-06 04:31:12 -04:00
|
|
|
wanted = "hello tab hallo tab this"
|
|
|
|
class IMMoving_ExitWhenOutsideRight_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"$1 ${2:blub} ${1:Tab}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hello test this" + ESC + "02f i" + EX + "tab" + ARR_R + JF + "hallo"
|
2009-07-06 04:31:12 -04:00
|
|
|
wanted = "hello tab blub tab hallothis"
|
|
|
|
class IMMoving_NotExitingWhenBarelyOutsideLeft_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"${1:Hi} ${2:blub}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hello test this" + ESC + "02f i" + EX + "tab" + 3*ARR_L + \
|
|
|
|
JF + "hallo"
|
2009-07-06 04:31:12 -04:00
|
|
|
wanted = "hello tab hallo this"
|
|
|
|
class IMMoving_ExitWhenOutsideLeft_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"${1:Hi} ${2:blub}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hello test this" + ESC + "02f i" + EX + "tab" + 4*ARR_L + \
|
|
|
|
JF + "hallo"
|
2009-07-06 04:31:12 -04:00
|
|
|
wanted = "hellohallo tab blub this"
|
2009-07-06 10:43:24 -04:00
|
|
|
class IMMoving_ExitWhenOutsideAbove_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1:Hi}\n${2:blub}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hello test this" + ESC + "02f i" + EX + "tab" + 1*ARR_U + JF + \
|
|
|
|
"\nhallo"
|
2009-07-06 10:43:24 -04:00
|
|
|
wanted = "hallo\nhello tab\nblub this"
|
|
|
|
class IMMoving_ExitWhenOutsideBelow_ECR(_VimTest):
|
|
|
|
snippets = ("test", "${1:Hi}\n${2:blub}")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "hello test this" + ESC + "02f i" + EX + "tab" + 2*ARR_D + JF + \
|
|
|
|
"testhallo\n"
|
2009-07-06 10:43:24 -04:00
|
|
|
wanted = "hello tab\nblub this\ntesthallo"
|
2009-07-05 16:25:01 -04:00
|
|
|
|
2009-07-15 17:16:57 -04:00
|
|
|
|
2009-07-04 11:59:50 -04:00
|
|
|
####################
|
|
|
|
# PROPER INDENTING #
|
|
|
|
####################
|
|
|
|
class ProperIndenting_SimpleCase_ECR(_VimTest):
|
|
|
|
snippets = ("test", "for\n blah")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = " test" + EX + "Hui"
|
2009-07-04 11:59:50 -04:00
|
|
|
wanted = " for\n blahHui"
|
2009-07-06 04:40:07 -04:00
|
|
|
class ProperIndenting_SingleLineNoReindenting_ECR(_VimTest):
|
|
|
|
snippets = ("test", "hui")
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = " test" + EX + "blah"
|
2009-07-06 04:40:07 -04:00
|
|
|
wanted = " huiblah"
|
2009-07-12 11:23:39 -04:00
|
|
|
class ProperIndenting_AutoIndentAndNewline_ECR(_VimTest):
|
|
|
|
snippets = ("test", "hui")
|
|
|
|
keys = " test" + EX + "\n"+ "blah"
|
|
|
|
wanted = " hui\n blah"
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set autoindent\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set noautoindent\n")
|
2009-07-12 11:34:10 -04:00
|
|
|
|
2009-07-15 12:16:42 -04:00
|
|
|
####################
|
|
|
|
# COMPLETION TESTS #
|
|
|
|
####################
|
|
|
|
class Completion_SimpleExample_ECR(_VimTest):
|
|
|
|
snippets = ("test", "$1 ${1:blah}")
|
|
|
|
keys = "superkallifragilistik\ntest" + EX + "sup" + COMPL_KW + \
|
|
|
|
COMPL_ACCEPT + " some more"
|
|
|
|
wanted = "superkallifragilistik\nsuperkallifragilistik some more " \
|
|
|
|
"superkallifragilistik some more"
|
|
|
|
|
2010-07-12 08:52:12 -04:00
|
|
|
# We need >2 different words with identical starts to create the
|
|
|
|
# popup-menu:
|
|
|
|
COMPLETION_OPTIONS = "completion1\ncompletion2\n"
|
|
|
|
|
|
|
|
class Completion_ForwardsJumpWithoutCOMPL_ACCEPT(_VimTest):
|
|
|
|
# completions should not be truncated when JF is activated without having
|
|
|
|
# pressed COMPL_ACCEPT (Bug #598903)
|
|
|
|
snippets = ("test", "$1 $2")
|
|
|
|
keys = COMPLETION_OPTIONS + "test" + EX + "com" + COMPL_KW + JF + "foo"
|
|
|
|
wanted = COMPLETION_OPTIONS + "completion1 foo"
|
|
|
|
|
|
|
|
class Completion_BackwardsJumpWithoutCOMPL_ACCEPT(_VimTest):
|
|
|
|
# completions should not be truncated when JB is activated without having
|
|
|
|
# pressed COMPL_ACCEPT (Bug #598903)
|
|
|
|
snippets = ("test", "$1 $2")
|
|
|
|
keys = COMPLETION_OPTIONS + "test" + EX + "foo" + JF + "com" + COMPL_KW + \
|
|
|
|
JB + "foo"
|
|
|
|
wanted = COMPLETION_OPTIONS + "foo completion1"
|
2009-07-15 12:16:42 -04:00
|
|
|
|
2009-07-17 17:33:48 -04:00
|
|
|
###################
|
|
|
|
# SNIPPET OPTIONS #
|
|
|
|
###################
|
|
|
|
class SnippetOptions_OverwriteExisting_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test", "${1:Hallo}", "Types Hallo"),
|
|
|
|
("test", "${1:World}", "Types World"),
|
|
|
|
("test", "We overwrite", "Overwrite the two", "!"),
|
|
|
|
)
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "We overwrite"
|
|
|
|
class SnippetOptions_OverwriteTwice_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test", "${1:Hallo}", "Types Hallo"),
|
|
|
|
("test", "${1:World}", "Types World"),
|
|
|
|
("test", "We overwrite", "Overwrite the two", "!"),
|
|
|
|
("test", "again", "Overwrite again", "!"),
|
|
|
|
)
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "again"
|
|
|
|
class SnippetOptions_OverwriteThenChoose_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test", "${1:Hallo}", "Types Hallo"),
|
|
|
|
("test", "${1:World}", "Types World"),
|
|
|
|
("test", "We overwrite", "Overwrite the two", "!"),
|
|
|
|
("test", "No overwrite", "Not overwritten", ""),
|
|
|
|
)
|
|
|
|
keys = "test" + EX + "1\n\n" + "test" + EX + "2\n"
|
|
|
|
wanted = "We overwrite\nNo overwrite"
|
2009-07-17 18:51:19 -04:00
|
|
|
class SnippetOptions_OnlyExpandWhenWSInFront_Expand(_VimTest):
|
|
|
|
snippets = ("test", "Expand me!", "", "b")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
class SnippetOptions_OnlyExpandWhenWSInFront_Expand2(_VimTest):
|
|
|
|
snippets = ("test", "Expand me!", "", "b")
|
|
|
|
keys = " test" + EX
|
|
|
|
wanted = " Expand me!"
|
|
|
|
class SnippetOptions_OnlyExpandWhenWSInFront_DontExpand(_VimTest):
|
|
|
|
snippets = ("test", "Expand me!", "", "b")
|
|
|
|
keys = "a test" + EX
|
2009-08-24 06:28:54 -04:00
|
|
|
wanted = "a test" + EX
|
2009-07-17 18:51:19 -04:00
|
|
|
class SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWO(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test", "Expand me!", "", "b"),
|
|
|
|
("test", "not at beginning", "", ""),
|
|
|
|
)
|
|
|
|
keys = "a test" + EX
|
|
|
|
wanted = "a not at beginning"
|
|
|
|
class SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWOChoose(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test", "Expand me!", "", "b"),
|
|
|
|
("test", "not at beginning", "", ""),
|
|
|
|
)
|
|
|
|
keys = " test" + EX + "1\n"
|
|
|
|
wanted = " Expand me!"
|
2009-07-15 11:40:24 -04:00
|
|
|
|
2009-08-16 10:34:54 -04:00
|
|
|
|
|
|
|
class SnippetOptions_ExpandInwordSnippets_SimpleExpand(_VimTest):
|
|
|
|
snippets = (("test", "Expand me!", "", "i"), )
|
|
|
|
keys = "atest" + EX
|
|
|
|
wanted = "aExpand me!"
|
|
|
|
class SnippetOptions_ExpandInwordSnippets_ExpandSingle(_VimTest):
|
|
|
|
snippets = (("test", "Expand me!", "", "i"), )
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
class SnippetOptions_ExpandInwordSnippetsWithOtherChars_Expand(_VimTest):
|
|
|
|
snippets = (("test", "Expand me!", "", "i"), )
|
|
|
|
keys = "$test" + EX
|
|
|
|
wanted = "$Expand me!"
|
|
|
|
class SnippetOptions_ExpandInwordSnippetsWithOtherChars_Expand2(_VimTest):
|
|
|
|
snippets = (("test", "Expand me!", "", "i"), )
|
|
|
|
keys = "-test" + EX
|
|
|
|
wanted = "-Expand me!"
|
|
|
|
class SnippetOptions_ExpandInwordSnippetsWithOtherChars_Expand3(_VimTest):
|
|
|
|
snippets = (("test", "Expand me!", "", "i"), )
|
|
|
|
keys = "ätest" + EX
|
|
|
|
wanted = "äExpand me!"
|
|
|
|
|
2009-08-23 18:44:19 -04:00
|
|
|
class _SnippetOptions_ExpandWordSnippets(_VimTest):
|
|
|
|
snippets = (("test", "Expand me!", "", "w"), )
|
|
|
|
class SnippetOptions_ExpandWordSnippets_NormalExpand(
|
|
|
|
_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
class SnippetOptions_ExpandWordSnippets_NoExpand(
|
|
|
|
_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "atest" + EX
|
2009-08-30 14:39:27 -04:00
|
|
|
wanted = "atest" + EX
|
2009-08-23 18:44:19 -04:00
|
|
|
class SnippetOptions_ExpandWordSnippets_ExpandSuffix(
|
|
|
|
_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "a-test" + EX
|
|
|
|
wanted = "a-Expand me!"
|
|
|
|
class SnippetOptions_ExpandWordSnippets_ExpandSuffix2(
|
|
|
|
_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "a(test" + EX
|
|
|
|
wanted = "a(Expand me!"
|
|
|
|
class SnippetOptions_ExpandWordSnippets_ExpandSuffix3(
|
|
|
|
_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "[[test" + EX
|
|
|
|
wanted = "[[Expand me!"
|
2010-11-22 09:14:47 -05:00
|
|
|
|
|
|
|
####################
|
|
|
|
# NO TAB EXPANSION #
|
|
|
|
####################
|
|
|
|
class _No_Tab_Expand(_VimTest):
|
|
|
|
snippets = ("test", "\t\tExpand\tme!\t", "", "t")
|
|
|
|
|
|
|
|
class No_Tab_Expand_Simple(_No_Tab_Expand):
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "\t\tExpand\tme!\t"
|
|
|
|
|
|
|
|
class No_Tab_Expand_Leading_Spaces(_No_Tab_Expand):
|
|
|
|
keys = " test" + EX
|
|
|
|
wanted = " \t\tExpand\tme!\t"
|
|
|
|
|
|
|
|
class No_Tab_Expand_Leading_Tabs(_No_Tab_Expand):
|
|
|
|
keys = "\ttest" + EX
|
|
|
|
wanted = "\t\t\tExpand\tme!\t"
|
|
|
|
|
|
|
|
class No_Tab_Expand_No_TS(_No_Tab_Expand):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=3\n")
|
|
|
|
self.send(":set sts=3\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set sts=0\n")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "\t\tExpand\tme!\t"
|
|
|
|
|
|
|
|
class No_Tab_Expand_ET(_No_Tab_Expand):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=3\n")
|
|
|
|
self.send(":set expandtab\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set noexpandtab\n")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "\t\tExpand\tme!\t"
|
|
|
|
|
|
|
|
class No_Tab_Expand_ET_Leading_Spaces(_No_Tab_Expand):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=3\n")
|
|
|
|
self.send(":set expandtab\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set noexpandtab\n")
|
|
|
|
keys = " test" + EX
|
|
|
|
wanted = " \t\tExpand\tme!\t"
|
|
|
|
|
|
|
|
class No_Tab_Expand_ET_SW(_No_Tab_Expand):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set expandtab\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set noexpandtab\n")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "\t\tExpand\tme!\t"
|
|
|
|
|
|
|
|
class No_Tab_Expand_ET_SW_TS(_No_Tab_Expand):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set sw=3\n")
|
|
|
|
self.send(":set sts=3\n")
|
|
|
|
self.send(":set ts=3\n")
|
|
|
|
self.send(":set expandtab\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set sw=8\n")
|
|
|
|
self.send(":set ts=8\n")
|
|
|
|
self.send(":set sts=0\n")
|
|
|
|
self.send(":set noexpandtab\n")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "\t\tExpand\tme!\t"
|
|
|
|
|
2009-08-16 10:34:54 -04:00
|
|
|
|
2010-08-08 18:29:46 -04:00
|
|
|
#################
|
|
|
|
# REGEX MATCHES #
|
|
|
|
#################
|
|
|
|
class SnippetOptions_Regex_Expand(_VimTest):
|
|
|
|
snippets = ("(test)", "Expand me!", "", "r")
|
|
|
|
keys = "test" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
class SnippetOptions_Regex_Multiple(_VimTest):
|
|
|
|
snippets = ("(test *)+", "Expand me!", "", "r")
|
|
|
|
keys = "test test test" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
|
|
|
|
class _Regex_Self(_VimTest):
|
|
|
|
snippets = (r"((?<=\W)|^)(\.)", "self.", "", "r")
|
|
|
|
class SnippetOptions_Regex_Self_Start(_Regex_Self):
|
|
|
|
keys = "." + EX
|
|
|
|
wanted = "self."
|
|
|
|
class SnippetOptions_Regex_Self_Space(_Regex_Self):
|
|
|
|
keys = " ." + EX
|
|
|
|
wanted = " self."
|
|
|
|
class SnippetOptions_Regex_Self_TextAfter(_Regex_Self):
|
|
|
|
keys = " .a" + EX
|
|
|
|
wanted = " .a" + EX
|
|
|
|
class SnippetOptions_Regex_Self_TextBefore(_Regex_Self):
|
|
|
|
keys = "a." + EX
|
|
|
|
wanted = "a." + EX
|
|
|
|
|
2010-08-08 20:49:03 -04:00
|
|
|
class SnippetOptions_Regex_PythonBlockMatch(_VimTest):
|
2010-08-16 20:59:41 -04:00
|
|
|
snippets = (r"([abc]+)([def]+)", r"""`!p m = match
|
2010-08-08 20:49:03 -04:00
|
|
|
snip.rv += m.group(2)
|
|
|
|
snip.rv += m.group(1)
|
|
|
|
`""", "", "r")
|
|
|
|
keys = "test cabfed" + EX
|
|
|
|
wanted = "test fedcab"
|
|
|
|
class SnippetOptions_Regex_PythonBlockNoMatch(_VimTest):
|
2010-08-16 20:59:41 -04:00
|
|
|
snippets = (r"cabfed", r"""`!p snip.rv = match or "No match"`""")
|
2010-08-08 20:49:03 -04:00
|
|
|
keys = "test cabfed" + EX
|
|
|
|
wanted = "test No match"
|
|
|
|
|
2010-08-08 20:32:36 -04:00
|
|
|
#######################
|
|
|
|
# MULTI-WORD SNIPPETS #
|
|
|
|
#######################
|
|
|
|
|
|
|
|
class MultiWordSnippet_Simple(_VimTest):
|
|
|
|
snippets = ("test me", "Expand me!")
|
|
|
|
keys = "test me" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
|
|
|
|
class MultiWord_SnippetOptions_OverwriteExisting_ECR(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test me", "${1:Hallo}", "Types Hallo"),
|
|
|
|
("test me", "${1:World}", "Types World"),
|
|
|
|
("test me", "We overwrite", "Overwrite the two", "!"),
|
|
|
|
)
|
|
|
|
keys = "test me" + EX
|
|
|
|
wanted = "We overwrite"
|
|
|
|
class MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_Expand(_VimTest):
|
|
|
|
snippets = ("test it", "Expand me!", "", "b")
|
|
|
|
keys = "test it" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
class MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_Expand2(_VimTest):
|
|
|
|
snippets = ("test it", "Expand me!", "", "b")
|
|
|
|
keys = " test it" + EX
|
|
|
|
wanted = " Expand me!"
|
|
|
|
class MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_DontExpand(_VimTest):
|
|
|
|
snippets = ("test it", "Expand me!", "", "b")
|
|
|
|
keys = "a test it" + EX
|
|
|
|
wanted = "a test it" + EX
|
|
|
|
class MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWO(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test it", "Expand me!", "", "b"),
|
|
|
|
("test it", "not at beginning", "", ""),
|
|
|
|
)
|
|
|
|
keys = "a test it" + EX
|
|
|
|
wanted = "a not at beginning"
|
|
|
|
class MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWOChoose(_VimTest):
|
|
|
|
snippets = (
|
|
|
|
("test it", "Expand me!", "", "b"),
|
|
|
|
("test it", "not at beginning", "", ""),
|
|
|
|
)
|
|
|
|
keys = " test it" + EX + "1\n"
|
|
|
|
wanted = " Expand me!"
|
|
|
|
|
|
|
|
|
|
|
|
class MultiWord_SnippetOptions_ExpandInwordSnippets_SimpleExpand(_VimTest):
|
|
|
|
snippets = (("test it", "Expand me!", "", "i"), )
|
|
|
|
keys = "atest it" + EX
|
|
|
|
wanted = "aExpand me!"
|
|
|
|
class MultiWord_SnippetOptions_ExpandInwordSnippets_ExpandSingle(_VimTest):
|
|
|
|
snippets = (("test it", "Expand me!", "", "i"), )
|
|
|
|
keys = "test it" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
|
|
|
|
class _MultiWord_SnippetOptions_ExpandWordSnippets(_VimTest):
|
|
|
|
snippets = (("test it", "Expand me!", "", "w"), )
|
|
|
|
class MultiWord_SnippetOptions_ExpandWordSnippets_NormalExpand(
|
|
|
|
_MultiWord_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "test it" + EX
|
|
|
|
wanted = "Expand me!"
|
|
|
|
class MultiWord_SnippetOptions_ExpandWordSnippets_NoExpand(
|
|
|
|
_MultiWord_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "atest it" + EX
|
|
|
|
wanted = "atest it" + EX
|
|
|
|
class MultiWord_SnippetOptions_ExpandWordSnippets_ExpandSuffix(
|
|
|
|
_MultiWord_SnippetOptions_ExpandWordSnippets):
|
|
|
|
keys = "a-test it" + EX
|
|
|
|
wanted = "a-Expand me!"
|
2009-08-16 10:34:54 -04:00
|
|
|
|
2009-07-04 15:58:13 -04:00
|
|
|
######################
|
|
|
|
# SELECTING MULTIPLE #
|
|
|
|
######################
|
2009-08-02 04:35:23 -04:00
|
|
|
class _MultipleMatches(_VimTest):
|
2009-07-04 15:58:13 -04:00
|
|
|
snippets = ( ("test", "Case1", "This is Case 1"),
|
|
|
|
("test", "Case2", "This is Case 2") )
|
2009-08-02 04:35:23 -04:00
|
|
|
class Multiple_SimpleCaseSelectFirst_ECR(_MultipleMatches):
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "1\n"
|
2009-07-04 15:58:13 -04:00
|
|
|
wanted = "Case1"
|
2009-08-02 04:35:23 -04:00
|
|
|
class Multiple_SimpleCaseSelectSecond_ECR(_MultipleMatches):
|
2009-07-09 09:30:23 -04:00
|
|
|
keys = "test" + EX + "2\n"
|
2009-07-04 15:58:13 -04:00
|
|
|
wanted = "Case2"
|
2009-08-02 04:35:23 -04:00
|
|
|
class Multiple_SimpleCaseSelectTooHigh_ESelectLast(_MultipleMatches):
|
|
|
|
keys = "test" + EX + "5\n"
|
|
|
|
wanted = "Case2"
|
|
|
|
class Multiple_SimpleCaseSelectZero_EEscape(_MultipleMatches):
|
|
|
|
keys = "test" + EX + "0\n" + "hi"
|
|
|
|
wanted = "testhi"
|
|
|
|
class Multiple_SimpleCaseEscapeOut_ECR(_MultipleMatches):
|
|
|
|
keys = "test" + EX + ESC + "hi"
|
|
|
|
wanted = "testhi"
|
2009-08-09 09:00:20 -04:00
|
|
|
class Multiple_ManySnippetsOneTrigger_ECR(_VimTest):
|
|
|
|
# Snippet definition {{{
|
|
|
|
snippets = (
|
|
|
|
("test", "Case1", "This is Case 1"),
|
|
|
|
("test", "Case2", "This is Case 2"),
|
|
|
|
("test", "Case3", "This is Case 3"),
|
|
|
|
("test", "Case4", "This is Case 4"),
|
|
|
|
("test", "Case5", "This is Case 5"),
|
|
|
|
("test", "Case6", "This is Case 6"),
|
|
|
|
("test", "Case7", "This is Case 7"),
|
|
|
|
("test", "Case8", "This is Case 8"),
|
|
|
|
("test", "Case9", "This is Case 9"),
|
|
|
|
("test", "Case10", "This is Case 10"),
|
|
|
|
("test", "Case11", "This is Case 11"),
|
|
|
|
("test", "Case12", "This is Case 12"),
|
|
|
|
("test", "Case13", "This is Case 13"),
|
|
|
|
("test", "Case14", "This is Case 14"),
|
|
|
|
("test", "Case15", "This is Case 15"),
|
|
|
|
("test", "Case16", "This is Case 16"),
|
|
|
|
("test", "Case17", "This is Case 17"),
|
|
|
|
("test", "Case18", "This is Case 18"),
|
|
|
|
("test", "Case19", "This is Case 19"),
|
|
|
|
("test", "Case20", "This is Case 20"),
|
|
|
|
("test", "Case21", "This is Case 21"),
|
|
|
|
("test", "Case22", "This is Case 22"),
|
|
|
|
("test", "Case23", "This is Case 23"),
|
|
|
|
("test", "Case24", "This is Case 24"),
|
|
|
|
("test", "Case25", "This is Case 25"),
|
|
|
|
("test", "Case26", "This is Case 26"),
|
|
|
|
("test", "Case27", "This is Case 27"),
|
|
|
|
("test", "Case28", "This is Case 28"),
|
|
|
|
("test", "Case29", "This is Case 29"),
|
|
|
|
) # }}}
|
2009-09-17 08:26:57 -04:00
|
|
|
sleeptime = 0.09 # Do this very slowly
|
2009-09-17 08:11:43 -04:00
|
|
|
keys = "test" + EX + " " + ESC + ESC + "ahi"
|
2009-08-09 09:00:20 -04:00
|
|
|
wanted = "testhi"
|
2009-07-04 15:58:13 -04:00
|
|
|
|
2009-08-16 14:55:08 -04:00
|
|
|
|
|
|
|
##################################
|
|
|
|
# LIST OF ALL AVAILABLE SNIPPETS #
|
|
|
|
##################################
|
|
|
|
class _ListAllSnippets(_VimTest):
|
|
|
|
snippets = ( ("testblah", "BLAAH", "Say BLAH"),
|
|
|
|
("test", "TEST ONE", "Say tst one"),
|
|
|
|
("aloha", "OHEEEE", "Say OHEE"),
|
|
|
|
)
|
|
|
|
|
|
|
|
class ListAllAvailable_NothingTyped_ExceptCorrectResult(_ListAllSnippets):
|
|
|
|
keys = "" + LS + "3\n"
|
|
|
|
wanted = "OHEEEE"
|
|
|
|
class ListAllAvailable_testtyped_ExceptCorrectResult(_ListAllSnippets):
|
|
|
|
keys = "hallo test" + LS + "1\n"
|
|
|
|
wanted = "hallo BLAAH"
|
|
|
|
class ListAllAvailable_testtypedSecondOpt_ExceptCorrectResult(_ListAllSnippets):
|
|
|
|
keys = "hallo test" + LS + "2\n"
|
|
|
|
wanted = "hallo TEST ONE"
|
|
|
|
|
2010-08-15 09:08:51 -04:00
|
|
|
class ListAllAvailable_NonDefined_NoExceptionShouldBeRaised(_ListAllSnippets):
|
|
|
|
keys = "hallo qualle" + LS + "Hi"
|
|
|
|
wanted = "hallo qualleHi"
|
|
|
|
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
#########################
|
|
|
|
# SNIPPETS FILE PARSING #
|
|
|
|
#########################
|
|
|
|
|
|
|
|
class ParseSnippets_SimpleSnippet(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet testsnip "Test Snippet" b!
|
|
|
|
This is a test snippet!
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
keys = "testsnip" + EX
|
|
|
|
wanted = "This is a test snippet!"
|
|
|
|
|
|
|
|
class ParseSnippets_MissingEndSnippet(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet testsnip "Test Snippet" b!
|
|
|
|
This is a test snippet!
|
|
|
|
""")
|
|
|
|
keys = "testsnip" + EX
|
|
|
|
wanted = "testsnip" + EX
|
|
|
|
expected_error = dedent("""
|
|
|
|
UltiSnips: Missing 'endsnippet' for 'testsnip' in test_file(5)
|
|
|
|
""").strip()
|
|
|
|
|
|
|
|
class ParseSnippets_UnknownDirective(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
unknown directive
|
|
|
|
""")
|
|
|
|
keys = "testsnip" + EX
|
|
|
|
wanted = "testsnip" + EX
|
|
|
|
expected_error = dedent("""
|
|
|
|
UltiSnips: Invalid line 'unknown directive' in test_file(2)
|
|
|
|
""").strip()
|
|
|
|
|
|
|
|
class ParseSnippets_ExtendsWithoutFiletype(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
extends
|
|
|
|
""")
|
|
|
|
keys = "testsnip" + EX
|
|
|
|
wanted = "testsnip" + EX
|
|
|
|
expected_error = dedent("""
|
|
|
|
UltiSnips: 'extends' without file types in test_file(2)
|
|
|
|
""").strip()
|
|
|
|
|
|
|
|
class ParseSnippets_ClearAll(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet testsnip "Test snippet"
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
clearsnippets
|
|
|
|
""")
|
|
|
|
keys = "testsnip" + EX
|
|
|
|
wanted = "testsnip" + EX
|
|
|
|
|
|
|
|
class ParseSnippets_ClearOne(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet testsnip "Test snippet"
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet toclear "Snippet to clear"
|
|
|
|
Do not expand.
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
clearsnippets toclear
|
|
|
|
""")
|
|
|
|
keys = "toclear" + EX + "\n" + "testsnip" + EX
|
|
|
|
wanted = "toclear" + EX + "\n" + "This is a test."
|
|
|
|
|
|
|
|
class ParseSnippets_ClearTwo(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet testsnip "Test snippet"
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet toclear "Snippet to clear"
|
|
|
|
Do not expand.
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
clearsnippets testsnip toclear
|
|
|
|
""")
|
|
|
|
keys = "toclear" + EX + "\n" + "testsnip" + EX
|
|
|
|
wanted = "toclear" + EX + "\n" + "testsnip" + EX
|
|
|
|
|
|
|
|
|
2010-08-08 20:32:36 -04:00
|
|
|
class _ParseSnippets_MultiWord(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet /test snip/
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet !snip test! "Another snippet"
|
|
|
|
This is another test.
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet "snippet test" "Another snippet" b
|
|
|
|
This is yet another test.
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
class ParseSnippets_MultiWord_Simple(_ParseSnippets_MultiWord):
|
|
|
|
keys = "test snip" + EX
|
|
|
|
wanted = "This is a test."
|
|
|
|
class ParseSnippets_MultiWord_Description(_ParseSnippets_MultiWord):
|
|
|
|
keys = "snip test" + EX
|
|
|
|
wanted = "This is another test."
|
|
|
|
class ParseSnippets_MultiWord_Description_Option(_ParseSnippets_MultiWord):
|
|
|
|
keys = "snippet test" + EX
|
|
|
|
wanted = "This is yet another test."
|
|
|
|
|
|
|
|
class _ParseSnippets_MultiWord_RE(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet /[d-f]+/ "" r
|
|
|
|
az test
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet !^(foo|bar)$! "" r
|
|
|
|
foo-bar test
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet "(test ?)+" "" r
|
|
|
|
re-test
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
class ParseSnippets_MultiWord_RE1(_ParseSnippets_MultiWord_RE):
|
|
|
|
keys = "abc def" + EX
|
|
|
|
wanted = "abc az test"
|
|
|
|
class ParseSnippets_MultiWord_RE2(_ParseSnippets_MultiWord_RE):
|
|
|
|
keys = "foo" + EX + " bar" + EX + "\nbar" + EX
|
|
|
|
wanted = "foo-bar test bar\t\nfoo-bar test"
|
|
|
|
class ParseSnippets_MultiWord_RE3(_ParseSnippets_MultiWord_RE):
|
|
|
|
keys = "test test test" + EX
|
|
|
|
wanted = "re-test"
|
|
|
|
|
|
|
|
class ParseSnippets_MultiWord_Quotes(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet "test snip"
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
keys = "test snip" + EX
|
|
|
|
wanted = "This is a test."
|
2010-08-08 21:15:34 -04:00
|
|
|
class ParseSnippets_MultiWord_WithQuotes(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet !"test snip"!
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
keys = '"test snip"' + EX
|
|
|
|
wanted = "This is a test."
|
2010-08-08 20:32:36 -04:00
|
|
|
|
|
|
|
class ParseSnippets_MultiWord_NoContainer(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet test snip
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
keys = "test snip" + EX
|
|
|
|
wanted = keys
|
|
|
|
expected_error = dedent("""
|
|
|
|
UltiSnips: Invalid multiword trigger: 'test snip' in test_file(2)
|
|
|
|
""").strip()
|
|
|
|
|
|
|
|
class ParseSnippets_MultiWord_UnmatchedContainer(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
snippet !inv snip/
|
|
|
|
This is a test.
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
keys = "inv snip" + EX
|
|
|
|
wanted = keys
|
|
|
|
expected_error = dedent("""
|
|
|
|
UltiSnips: Invalid multiword trigger: '!inv snip/' in test_file(2)
|
|
|
|
""").strip()
|
|
|
|
|
2010-08-16 20:59:41 -04:00
|
|
|
class ParseSnippets_Global_Python(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
global !p
|
|
|
|
def tex(ins):
|
|
|
|
return "a " + ins + " b"
|
2010-08-16 23:12:30 -04:00
|
|
|
endglobal
|
2010-08-16 20:59:41 -04:00
|
|
|
|
|
|
|
snippet ab
|
|
|
|
x `!p snip.rv = tex("bob")` y
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ac
|
|
|
|
x `!p snip.rv = tex("jon")` y
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
keys = "ab" + EX + "\nac" + EX
|
|
|
|
wanted = "x a bob b y\nx a jon b y"
|
|
|
|
|
|
|
|
class ParseSnippets_Global_Local_Python(_VimTest):
|
|
|
|
snippets_test_file = ("all", "test_file", r"""
|
|
|
|
global !p
|
|
|
|
def tex(ins):
|
|
|
|
return "a " + ins + " b"
|
2010-08-16 23:12:30 -04:00
|
|
|
endglobal
|
2010-08-16 20:59:41 -04:00
|
|
|
|
|
|
|
snippet ab
|
|
|
|
x `!p first = tex("bob")
|
|
|
|
snip.rv = "first"` `!p snip.rv = first` y
|
|
|
|
endsnippet
|
|
|
|
""")
|
|
|
|
keys = "ab" + EX
|
|
|
|
wanted = "x first a bob b y"
|
|
|
|
|
2010-08-08 20:32:36 -04:00
|
|
|
|
2010-08-19 04:26:10 -04:00
|
|
|
#######################
|
|
|
|
# Test for bug 501727 #
|
|
|
|
#######################
|
2010-08-18 04:11:29 -04:00
|
|
|
class TestNonEmptyLangmap_ExceptCorrectResult(_VimTest):
|
|
|
|
snippets = ("testme",
|
|
|
|
"""my snipped ${1:some_default}
|
|
|
|
and a mirror: $1
|
|
|
|
$2...$3
|
|
|
|
$0""")
|
|
|
|
keys = "testme" + EX + "hi1" + JF + "hi2" + JF + "hi3" + JF + "hi4"
|
|
|
|
wanted ="""my snipped hi1
|
|
|
|
and a mirror: hi1
|
|
|
|
hi2...hi3
|
|
|
|
hi4"""
|
|
|
|
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set langmap=dj,rk,nl,ln,jd,kr,DJ,RK,NL,LN,JD,KR\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set langmap=\n")
|
|
|
|
|
2010-08-19 04:26:10 -04:00
|
|
|
########################
|
|
|
|
# Tests for bug 616315 #
|
|
|
|
########################
|
2010-08-19 07:35:06 -04:00
|
|
|
class TrailingNewline_TabStop_NLInsideStuffBehind(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:
|
|
|
|
}<-behind1
|
|
|
|
$2<-behind2""")
|
|
|
|
keys = "test" + EX + "j" + JF + "k"
|
|
|
|
wanted = """
|
|
|
|
xj<-behind1
|
|
|
|
k<-behind2"""
|
|
|
|
|
|
|
|
class TrailingNewline_TabStop_JustNL(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:
|
|
|
|
}
|
|
|
|
$2""")
|
|
|
|
keys = "test" + EX + "j" + JF + "k"
|
|
|
|
wanted = """
|
|
|
|
xj
|
|
|
|
k"""
|
|
|
|
|
|
|
|
class TrailingNewline_TabStop_EndNL(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:a
|
|
|
|
}
|
|
|
|
$2""")
|
|
|
|
keys = "test" + EX + "j" + JF + "k"
|
|
|
|
wanted = """
|
|
|
|
xj
|
|
|
|
k"""
|
|
|
|
|
|
|
|
class TrailingNewline_TabStop_StartNL(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:
|
|
|
|
a}
|
|
|
|
$2""")
|
|
|
|
keys = "test" + EX + "j" + JF + "k"
|
|
|
|
wanted = """
|
|
|
|
xj
|
|
|
|
k"""
|
|
|
|
|
|
|
|
class TrailingNewline_TabStop_EndStartNL(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:
|
|
|
|
a
|
|
|
|
}
|
|
|
|
$2""")
|
|
|
|
keys = "test" + EX + "j" + JF + "k"
|
|
|
|
wanted = """
|
|
|
|
xj
|
|
|
|
k"""
|
|
|
|
|
2010-08-19 04:26:10 -04:00
|
|
|
class TrailingNewline_TabStop_NotEndStartNL(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:a
|
|
|
|
a}
|
|
|
|
$2""")
|
|
|
|
keys = "test" + EX + "j" + JF + "k"
|
|
|
|
wanted = """
|
|
|
|
xj
|
|
|
|
k"""
|
|
|
|
|
2010-08-19 07:35:06 -04:00
|
|
|
class TrailingNewline_TabStop_ExtraNL_ECR(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:a
|
|
|
|
a}
|
|
|
|
$2
|
|
|
|
""")
|
|
|
|
keys = "test" + EX + "j" + JF + "k"
|
|
|
|
wanted = """
|
|
|
|
xj
|
|
|
|
k
|
|
|
|
"""
|
2010-08-19 04:26:10 -04:00
|
|
|
|
2010-08-21 06:06:03 -04:00
|
|
|
class _MultiLineDefault(_VimTest):
|
|
|
|
snippets = ("test", r"""
|
|
|
|
x${1:a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
|
|
|
e
|
|
|
|
f}
|
|
|
|
$2""")
|
|
|
|
|
|
|
|
class MultiLineDefault_Jump(_MultiLineDefault):
|
|
|
|
keys = "test" + EX + JF + "y"
|
|
|
|
wanted = """
|
|
|
|
xa
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
|
|
|
e
|
|
|
|
f
|
|
|
|
y"""
|
|
|
|
|
|
|
|
class MultiLineDefault_Type(_MultiLineDefault):
|
|
|
|
keys = "test" + EX + "z" + JF + "y"
|
|
|
|
wanted = """
|
|
|
|
xz
|
|
|
|
y"""
|
|
|
|
|
|
|
|
class MultiLineDefault_BS(_MultiLineDefault):
|
|
|
|
keys = "test" + EX + BS + JF + "y"
|
|
|
|
wanted = """
|
|
|
|
x
|
|
|
|
y"""
|
|
|
|
|
2010-08-20 03:32:12 -04:00
|
|
|
#######################
|
|
|
|
# Test for bug 427298 #
|
|
|
|
#######################
|
|
|
|
class _SelectModeMappings(_VimTest):
|
|
|
|
snippets = ("test", "${1:World}")
|
|
|
|
keys = "test" + EX + "Hello"
|
|
|
|
wanted = "Hello"
|
|
|
|
maps = ("", "")
|
|
|
|
buffer_maps = ("", "")
|
|
|
|
do_unmapping = True
|
|
|
|
ignores = []
|
|
|
|
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":let g:UltiSnipsRemoveSelectModeMappings=%i\n" %
|
|
|
|
int(self.do_unmapping))
|
|
|
|
self.send(":let g:UltiSnipsMappingsToIgnore=%s\n" %
|
|
|
|
repr(self.ignores))
|
|
|
|
|
|
|
|
if not isinstance(self.maps[0], tuple):
|
|
|
|
self.maps = (self.maps,)
|
|
|
|
if not isinstance(self.buffer_maps[0], tuple):
|
|
|
|
self.buffer_maps = (self.buffer_maps,)
|
|
|
|
|
|
|
|
for key, m in self.maps:
|
|
|
|
if not len(key): continue
|
|
|
|
self.send(":smap %s %s\n" % (key,m))
|
|
|
|
for key, m in self.buffer_maps:
|
|
|
|
if not len(key): continue
|
|
|
|
self.send(":smap <buffer> %s %s\n" % (key,m))
|
|
|
|
|
|
|
|
def _options_off(self):
|
|
|
|
for key, m in self.maps:
|
|
|
|
if not len(key): continue
|
|
|
|
self.send(":sunmap %s\n" % key)
|
|
|
|
for key, m in self.buffer_maps:
|
|
|
|
if not len(key): continue
|
|
|
|
self.send(":sunmap <buffer> %s\n" % key)
|
|
|
|
|
|
|
|
self.send(":let g:UltiSnipsRemoveSelectModeMappings=1\n")
|
|
|
|
self.send(":let g:UltiSnipsMappingsToIgnore= []\n")
|
|
|
|
|
|
|
|
class SelectModeMappings_RemoveBeforeSelecting_ECR(_SelectModeMappings):
|
|
|
|
maps = ("H", "x")
|
|
|
|
wanted = "Hello"
|
|
|
|
class SelectModeMappings_DisableRemoveBeforeSelecting_ECR(_SelectModeMappings):
|
|
|
|
do_unmapping = False
|
|
|
|
maps = ("H", "x")
|
|
|
|
wanted = "xello"
|
|
|
|
class SelectModeMappings_IgnoreMappings_ECR(_SelectModeMappings):
|
|
|
|
ignores = ["e"]
|
|
|
|
maps = ("H", "x"), ("e", "l")
|
|
|
|
wanted = "Hello"
|
|
|
|
class SelectModeMappings_IgnoreMappings1_ECR(_SelectModeMappings):
|
|
|
|
ignores = ["H"]
|
|
|
|
maps = ("H", "x"), ("e", "l")
|
|
|
|
wanted = "xello"
|
|
|
|
class SelectModeMappings_IgnoreMappings2_ECR(_SelectModeMappings):
|
|
|
|
ignores = ["e", "H"]
|
|
|
|
maps = ("e", "l"), ("H", "x")
|
|
|
|
wanted = "xello"
|
|
|
|
class SelectModeMappings_BufferLocalMappings_ECR(_SelectModeMappings):
|
|
|
|
buffer_maps = ("H", "blah")
|
|
|
|
wanted = "Hello"
|
|
|
|
|
2010-09-23 04:49:39 -04:00
|
|
|
####################
|
|
|
|
# Folding problems #
|
|
|
|
####################
|
|
|
|
class FoldingEnabled_SnippetWithFold_ExpectNoFolding(_VimTest):
|
|
|
|
def _options_on(self):
|
|
|
|
self.send(":set foldlevel=0\n")
|
|
|
|
self.send(":set foldmethod=marker\n")
|
|
|
|
def _options_off(self):
|
|
|
|
self.send(":set foldlevel=0\n")
|
|
|
|
self.send(":set foldmethod=manual\n")
|
|
|
|
|
|
|
|
snippets = ("test", r"""Hello {{{
|
|
|
|
${1:Welt} }}}""")
|
|
|
|
keys = "test" + EX + "Ball"
|
|
|
|
wanted = """Hello {{{
|
|
|
|
Ball }}}"""
|
|
|
|
|
|
|
|
|
2010-08-20 03:32:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-19 04:26:10 -04:00
|
|
|
|
2009-07-04 15:58:13 -04:00
|
|
|
###########################################################################
|
|
|
|
# END OF TEST #
|
|
|
|
###########################################################################
|
2009-06-23 08:45:04 -04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys
|
2009-07-01 09:20:40 -04:00
|
|
|
import optparse
|
|
|
|
|
|
|
|
def parse_args():
|
|
|
|
p = optparse.OptionParser("%prog [OPTIONS] <test case names to run>")
|
|
|
|
|
2009-07-04 09:01:19 -04:00
|
|
|
p.set_defaults(session="vim", interrupt=False, verbose=False)
|
2009-07-01 09:20:40 -04:00
|
|
|
|
2009-07-04 09:01:19 -04:00
|
|
|
p.add_option("-v", "--verbose", dest="verbose", action="store_true",
|
|
|
|
help="print name of tests as they are executed")
|
2009-07-01 09:20:40 -04:00
|
|
|
p.add_option("-s", "--session", dest="session", metavar="SESSION",
|
|
|
|
help="send commands to screen session SESSION [%default]")
|
|
|
|
p.add_option("-i", "--interrupt", dest="interrupt",
|
|
|
|
action="store_true",
|
2010-08-22 07:57:19 -04:00
|
|
|
help="Stop after defining the snippet. This allows the user " \
|
|
|
|
"to interactively test the snippet in vim. You must give " \
|
|
|
|
"exactly one test case on the cmdline. The test will always fail."
|
2009-07-01 09:20:40 -04:00
|
|
|
)
|
2009-06-28 08:51:27 -04:00
|
|
|
|
2009-07-01 09:20:40 -04:00
|
|
|
o, args = p.parse_args()
|
|
|
|
return o, args
|
|
|
|
|
|
|
|
options,selected_tests = parse_args()
|
|
|
|
|
|
|
|
# The next line doesn't work in python 2.3
|
2009-07-02 05:48:35 -04:00
|
|
|
test_loader = unittest.TestLoader()
|
|
|
|
all_test_suites = test_loader.loadTestsFromModule(__import__("test"))
|
2009-07-01 09:20:40 -04:00
|
|
|
|
A "clearsnippets" feature
=========================
It's difficult for the user to control which of the default
bundled snippets are active in his environment. The
'runtimepath' variable must be set to the root of the ultisnips
installation, which brings in all of the bundled snippets.
Though the user may individually override the definition of the
bundled snippets using the "!" flag, the method has a couple of
problems:
- There's no way to remove a snippet, only to override it (and
each snippet must be overridden individually).
- The "!" flag currently doesn't remove the overridden snippets
from the "list snippets" command.
It might be considered a feature that "!" doesn't actually
remove the snippets from the "list snippets" command, though
perhaps that's an unintended effect. In any case, it would be
more convenient to allow the user to selectively remove the
bundled snippets from his environment.
A patch is provided in the following branch to address these problems:
http://code.launchpad.net/~drmikehenry/ultisnips/clearsnippets
The branch's primary purpose is the addition of a
"clearsnippets" command that may be placed in a user's
~/.vim/UltiSnips/ft.snippets file. The user may clear all
lower-priority snippet for that file type with the line:
clearsnippets
Alternatively, he may clear individual snippets by listing their
triggers:
clearsnippets trigger1 trigger2
A few changes were made to the testing system as part of the
incorporation of this new feature. These changes include:
- The "extends" directive is now supported on multiple lines
throughout file.
- A completely empty .snippets file is now possible.
- The test.py scripts now handles most of the vim setup,
simplifying the running of the tests. The invocation of Vim
now reduces to:
vim -u NONE
Instructions for running the tests are included at top of
test.py, where they should be more visible to interested
users; UltiSnips.vim now just points to test.py's
instructions.
- A new function vim_quote() encodes an arbitrary string into a
singly-quoted Vim string, with embedded quotes escaped.
- SnippetsFileParser() now allows file_data to be passed
directly for unit testing, avoiding the need to create files
in the filesystem for test purposes.
- A new _error() function reports errors to the user. At
runtime, this function uses :echo_err in general, but also can
append error text to current buffer to check for expected
errors during unit tests.
- Added error checks to snippets file parsing, along with unit
tests for the parsing.
- Increased retries from 2 to 4 (on my system, occasionally the
timing still causes tests to fail).
2009-09-08 20:15:10 -04:00
|
|
|
# Ensure we are not running in VI-compatible mode.
|
|
|
|
send(""":set nocompatible\n""", options.session)
|
|
|
|
|
|
|
|
# Ensure runtimepath includes only Vim's own runtime files
|
|
|
|
# and those of the UltiSnips directory under test ('.').
|
|
|
|
send(""":set runtimepath=$VIMRUNTIME,.\n""", options.session)
|
|
|
|
|
2009-07-21 04:21:05 -04:00
|
|
|
# Set the options
|
|
|
|
send(""":let g:UltiSnipsExpandTrigger="<tab>"\n""", options.session)
|
|
|
|
send(""":let g:UltiSnipsJumpForwardTrigger="?"\n""", options.session)
|
|
|
|
send(""":let g:UltiSnipsJumpBackwardTrigger="+"\n""", options.session)
|
2009-08-16 12:50:14 -04:00
|
|
|
send(""":let g:UltiSnipsListSnippets="@"\n""", options.session)
|
2009-07-21 04:21:05 -04:00
|
|
|
|
|
|
|
# Now, source our runtime
|
|
|
|
send(":so plugin/UltiSnips.vim\n", options.session)
|
2009-07-04 10:08:14 -04:00
|
|
|
|
2009-07-01 09:20:40 -04:00
|
|
|
# Inform all test case which screen session to use
|
2009-06-28 08:51:27 -04:00
|
|
|
suite = unittest.TestSuite()
|
2009-07-01 09:20:40 -04:00
|
|
|
for s in all_test_suites:
|
|
|
|
for test in s:
|
|
|
|
test.session = options.session
|
|
|
|
test.interrupt = options.interrupt
|
|
|
|
if len(selected_tests):
|
|
|
|
id = test.id().split('.')[1]
|
2009-07-03 11:50:52 -04:00
|
|
|
if not any([ id.startswith(t) for t in selected_tests ]):
|
2009-07-01 09:20:40 -04:00
|
|
|
continue
|
|
|
|
suite.addTest(test)
|
|
|
|
|
|
|
|
|
2009-07-04 09:01:19 -04:00
|
|
|
if options.verbose:
|
|
|
|
v = 2
|
|
|
|
else:
|
|
|
|
v = 1
|
|
|
|
res = unittest.TextTestRunner(verbosity=v).run(suite)
|
2009-07-01 09:20:40 -04:00
|
|
|
|