Modified tests so that they test each snippet in the middle of other text. This revealed a few bugs which are fixed now

This commit is contained in:
Holger Rapp 2009-07-02 09:49:42 +02:00
parent ad7241bc82
commit f7e0624c8b
2 changed files with 131 additions and 128 deletions

View File

@ -42,9 +42,19 @@ class TextObject(object):
that has a span in any ways that has a span in any ways
""" """
def __init__(self, start, end): def __init__(self, start, end):
self._parent = None
self._start = start self._start = start
self._end = end self._end = end
def parent():
doc = "The parent TextObject this TextObject resides in"
def fget(self):
return self._parent
def fset(self, value):
self._parent = value
return locals()
parent = property(**parent())
@property @property
def start(self): def start(self):
return self._start return self._start
@ -73,7 +83,7 @@ class Mirror(TextObject):
if ts != self._tabstop: if ts != self._tabstop:
return 0 return 0
mirror_line = self.start.line mirror_line = self._parent.start.line + self.start.line
line = vim.current.buffer[mirror_line] line = vim.current.buffer[mirror_line]
line = line[:self.start.col] + \ line = line[:self.start.col] + \
@ -109,8 +119,8 @@ class TabStop(TextObject):
return locals() return locals()
current_text = property(**current_text()) current_text = property(**current_text())
def select(self,start): def select(self):
lineno, col = start.line, start.col lineno, col = self._parent.start.line, self._parent.start.col
newline = lineno + self._start.line newline = lineno + self._start.line
newcol = self._start.col newcol = self._start.col
@ -152,9 +162,13 @@ class SnippetInstance(TextObject):
self._cts = None self._cts = None
for to in self._text_objects:
to.parent = self
for ts in self._tabstops.values(): for ts in self._tabstops.values():
self._update_mirrors(ts) self._update_mirrors(ts)
def select_next_tab(self, backwards = False): def select_next_tab(self, backwards = False):
if self._cts == 0: if self._cts == 0:
if not backwards: if not backwards:
@ -183,7 +197,7 @@ class SnippetInstance(TextObject):
ts = self._tabstops[self._cts] ts = self._tabstops[self._cts]
ts.select(self._start) ts.select()
self._selected_tab = ts self._selected_tab = ts
return True return True
@ -193,32 +207,26 @@ class SnippetInstance(TextObject):
for m in self._mirrors: for m in self._mirrors:
moved = m.update(for_ts) moved = m.update(for_ts)
if moved: if moved:
self._move_to_on_line(moved, m.start.line, m.start.col,cobj=m) self._move_textobjects_behind(moved, m)
def _move_to_on_line(self,amount, lineno = None, col = None, cobj = None): def _move_textobjects_behind(self, amount, obj):
if self._cts is None: if self._cts is None:
return return
if lineno is None and col is None:
lineno,col = vim.current.window.cursor
lineno -= 1
cobj = self._tabstops[self._cts]
for m in self._text_objects: for m in self._text_objects:
if m.start.line != lineno: if m.start.line != obj.start.line:
continue continue
if m.start.col >= col and m != cobj: if m.start.col >= obj.start.col and m != obj:
m.start.col += amount m.start.col += amount
m.end.col += amount m.end.col += amount
def backspace(self,count): def backspace(self,count):
cts = self._tabstops[self._cts] cts = self._tabstops[self._cts]
ll = len(cts.current_text) ll = len(cts.current_text)
cts.current_text = cts.current_text[:-count] cts.current_text = cts.current_text[:-count]
self._move_to_on_line(len(cts.current_text)-ll) self._move_textobjects_behind(len(cts.current_text)-ll, cts)
self._update_mirrors(cts) self._update_mirrors(cts)
@ -226,11 +234,11 @@ class SnippetInstance(TextObject):
cts = self._tabstops[self._cts] cts = self._tabstops[self._cts]
if self._selected_tab is not None: if self._selected_tab is not None:
self._move_to_on_line(len(chars)-len(cts.current_text)) self._move_textobjects_behind(len(chars)-len(cts.current_text), cts)
cts.current_text = "" cts.current_text = ""
self._selected_tab = None self._selected_tab = None
else: else:
self._move_to_on_line(len(chars)) self._move_textobjects_behind(len(chars), cts)
cts.current_text += chars cts.current_text += chars
@ -261,8 +269,8 @@ class Snippet(object):
line_idx = val[:start].count('\n') line_idx = val[:start].count('\n')
line_start = val[:start].rfind('\n') + 1 line_start = val[:start].rfind('\n') + 1
start_in_line = start - line_start start_in_line = start - line_start
ts = TabStop(line_idx, (start_in_line,start_in_line+len(def_text)), ts = TabStop(line_idx,
def_text) (start_in_line,start_in_line+len(def_text)), def_text)
tabstops[no] = ts tabstops[no] = ts
@ -324,7 +332,7 @@ class Snippet(object):
lines[0] = before + lines[0] lines[0] = before + lines[0]
lines[-1] += after lines[-1] += after
vim.current.buffer[lineno-1:lineno-1+len(lines)] = lines vim.current.buffer[lineno-1:lineno-1+1] = lines
vim.current.window.cursor = newline, newcol vim.current.window.cursor = newline, newcol

211
test.py
View File

@ -8,6 +8,8 @@ import unittest
import time import time
class _VimTest(unittest.TestCase): class _VimTest(unittest.TestCase):
text_before = " --- some text before --- "
text_after = " --- some text after --- "
def send(self, s): def send(self, s):
os.system("screen -x %s -X stuff '%s'" % (self.session,s)) os.system("screen -x %s -X stuff '%s'" % (self.session,s))
@ -19,6 +21,11 @@ class _VimTest(unittest.TestCase):
for c in str: for c in str:
self.send(c) self.send(c)
def check_output(self):
wanted = self.text_before + '\n\n' + self.wanted + \
'\n\n' + self.text_after
self.assertEqual(self.output, wanted)
def escape(self): def escape(self):
self.type("\x1b") self.type("\x1b")
@ -43,9 +50,17 @@ EOF
# Enter insert mode # Enter insert mode
self.send("i") self.send("i")
self.send(self.text_before + '\n\n')
self.send('\n\n' + self.text_after)
# Go to the middle of the buffer
self.escape()
self.send("ggjji")
# Execute the command # Execute the command
self.cmd() self.cmd()
handle, fn = tempfile.mkstemp(prefix="PySnipEmuTest",suffix=".txt") handle, fn = tempfile.mkstemp(prefix="PySnipEmuTest",suffix=".txt")
os.close(handle) os.close(handle)
@ -53,11 +68,12 @@ EOF
self.send(":w! %s\n" % fn) self.send(":w! %s\n" % fn)
# Give screen a chance to send the cmd and vim to write the file # Give screen a chance to send the cmd and vim to write the file
time.sleep(.05) time.sleep(.10)
# Read the output, chop the trailing newline # Read the output, chop the trailing newline
self.output = open(fn,"r").read()[:-1] self.output = open(fn,"r").read()[:-1]
def cmd(self): def cmd(self):
"""Overwrite these in the children""" """Overwrite these in the children"""
pass pass
@ -70,133 +86,122 @@ class _SimpleExpands(_VimTest):
snippets = ("hallo", "Hallo Welt!") snippets = ("hallo", "Hallo Welt!")
class SimpleExpand_ExceptCorrectResult(_SimpleExpands): class SimpleExpand_ExceptCorrectResult(_SimpleExpands):
def cmd(self): wanted = "Hallo Welt!"
self.type("hallo\t") def cmd(self): self.type("hallo\t")
def runTest(self): self.check_output()
def runTest(self):
self.assertEqual(self.output,"Hallo Welt!")
class SimpleExpandTypeAfterExpand_ExceptCorrectResult(_SimpleExpands): class SimpleExpandTypeAfterExpand_ExceptCorrectResult(_SimpleExpands):
def cmd(self): wanted = "Hallo Welt!and again"
self.type("hallo\tand again") def cmd(self): self.type("hallo\tand again")
def runTest(self): self.check_output()
def runTest(self):
self.assertEqual(self.output,"Hallo Welt!and again")
class SimpleExpandTypeAfterExpand1_ExceptCorrectResult(_SimpleExpands): class SimpleExpandTypeAfterExpand1_ExceptCorrectResult(_SimpleExpands):
def cmd(self): wanted = "na du Hallo Welt!and again"
self.type("na du hallo\tand again") def cmd(self): self.type("na du hallo\tand again")
def runTest(self): self.check_output()
def runTest(self):
self.assertEqual(self.output,"na du Hallo Welt!and again")
class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands): class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands):
def cmd(self): wanted = "hallo "
self.type("hallo \t") def cmd(self): self.type("hallo \t")
def runTest(self): self.check_output()
def runTest(self):
self.assertEqual(self.output,"hallo ")
class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands): class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands):
wanted = "Wie Hallo Welt! gehts?"
def cmd(self): def cmd(self):
self.type("Wie hallo gehts?") self.type("Wie hallo gehts?")
self.escape() self.escape()
self.type("bhi\t") self.type("bhi\t")
def runTest(self): self.check_output()
def runTest(self):
self.assertEqual(self.output,"Wie Hallo Welt! gehts?")
class MultilineExpand_ExceptCorrectResult(_VimTest): class MultilineExpand_ExceptCorrectResult(_VimTest):
wanted = "Wie Hallo Welt!\nUnd Wie gehts? gehts?"
snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?") snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?")
def cmd(self): def cmd(self):
self.type("Wie hallo gehts?") self.type("Wie hallo gehts?")
self.escape() self.escape()
self.type("bhi\t") self.type("bhi\t")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output, "Wie Hallo Welt!\nUnd Wie gehts? gehts?")
class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest): class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?") snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?")
wanted = "Wie Hallo Welt!\nUnd Wie gehts?Huiui! gehts?"
def cmd(self): def cmd(self):
self.type("Wie hallo gehts?") self.type("Wie hallo gehts?")
self.escape() self.escape()
self.type("bhi\tHuiui!") self.type("bhi\tHuiui!")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,
"Wie Hallo Welt!\nUnd Wie gehts?Huiui! gehts?")
############ ############
# TabStops # # TabStops #
############ ############
class TabStopSimpleReplace_ExceptCorrectResult(_VimTest): class TabStopSimpleReplace_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo ${0:End} ${1:Beginning}") snippets = ("hallo", "hallo ${0:End} ${1:Beginning}")
wanted = "hallo Du Nase na"
def cmd(self): def cmd(self):
self.type("hallo\tna\tDu Nase") self.type("hallo\tna\tDu Nase")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo Du Nase na")
class TabStopSimpleReplaceSurrounded_ExceptCorrectResult(_VimTest): class TabStopSimpleReplaceSurrounded_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo ${0:End} a small feed") snippets = ("hallo", "hallo ${0:End} a small feed")
wanted = "hallo Nase a small feed"
def cmd(self): def cmd(self):
self.type("hallo\tNase") self.type("hallo\tNase")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo Nase a small feed")
class TabStopSimpleReplaceSurrounded1_ExceptCorrectResult(_VimTest): class TabStopSimpleReplaceSurrounded1_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo $0 a small feed") snippets = ("hallo", "hallo $0 a small feed")
wanted = "hallo Nase a small feed"
def cmd(self): def cmd(self):
self.type("hallo\tNase") self.type("hallo\tNase")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo Nase a small feed")
class ExitTabStop_ExceptCorrectResult(_VimTest): class ExitTabStop_ExceptCorrectResult(_VimTest):
snippets = ("echo", "$0 run") snippets = ("echo", "$0 run")
wanted = "test run"
def cmd(self): def cmd(self):
self.type("echo\ttest") self.type("echo\ttest")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"test run")
class TabStopNoReplace_ExceptCorrectResult(_VimTest): class TabStopNoReplace_ExceptCorrectResult(_VimTest):
snippets = ("echo", "echo ${1:Hallo}") snippets = ("echo", "echo ${1:Hallo}")
wanted = "echo Hallo"
def cmd(self): def cmd(self):
self.type("echo\t") self.type("echo\t")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"echo Hallo")
class TabStopTestJumping_ExceptCorrectResult(_VimTest): class TabStopTestJumping_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo ${0:End} mitte ${1:Beginning}") snippets = ("hallo", "hallo ${0:End} mitte ${1:Beginning}")
wanted = "hallo TestHi mitte Beginning"
def cmd(self): def cmd(self):
self.type("hallo\t\tTest\tHi") self.type("hallo\t\tTest\tHi")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo TestHi mitte Beginning")
class TabStopTestJumping2_ExceptCorrectResult(_VimTest): class TabStopTestJumping2_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo $0 $1") snippets = ("hallo", "hallo $0 $1")
wanted = "hallo TestHi "
def cmd(self): def cmd(self):
self.type("hallo\t\tTest\tHi") self.type("hallo\t\tTest\tHi")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo TestHi ")
class TabStopTestBackwardJumping_ExceptCorrectResult(_VimTest): class TabStopTestBackwardJumping_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo ${0:End} mitte${1:Beginning}") snippets = ("hallo", "hallo ${0:End} mitte${1:Beginning}")
wanted = "hallo Blah mitteLets replace it again"
def cmd(self): def cmd(self):
self.type("hallo\tSomelengthy Text\tHi+Lets replace it again\tBlah\t++\t") self.type("hallo\tSomelengthy Text\tHi+Lets replace it again\tBlah\t++\t")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo Blah mitteLets replace it again")
class TabStopTestBackwardJumping2_ExceptCorrectResult(_VimTest): class TabStopTestBackwardJumping2_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo $0 $1") snippets = ("hallo", "hallo $0 $1")
wanted = "hallo Blah Lets replace it again"
def cmd(self): def cmd(self):
self.type("hallo\tSomelengthy Text\tHi+Lets replace it again\tBlah\t++\t") self.type("hallo\tSomelengthy Text\tHi+Lets replace it again\tBlah\t++\t")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo Blah Lets replace it again")
class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest): class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo $0\nnice $1 work\n$3 $2\nSeem to work") snippets = ("hallo", "hallo $0\nnice $1 work\n$3 $2\nSeem to work")
wanted = "test hallo one more\nnice world work\ntest try\nSeem to work World"
def cmd(self): def cmd(self):
self.type("test hallo World") self.type("test hallo World")
self.escape() self.escape()
self.type("02f i\tworld\ttry\ttest\tone more\t\t") self.type("02f i\tworld\ttry\ttest\tone more\t\t")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,
"test hallo one more\nnice world work\ntest try\nSeem to work World")
# TODO: pasting with <C-R> while mirroring # TODO: pasting with <C-R> while mirroring
########### ###########
@ -204,137 +209,127 @@ class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest):
########### ###########
class TextTabStopTextAfterTab_ExceptCorrectResult(_VimTest): class TextTabStopTextAfterTab_ExceptCorrectResult(_VimTest):
snippets = ("test", "$1 Hinten\n$1") snippets = ("test", "$1 Hinten\n$1")
wanted = "hallo Hinten\nhallo"
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo Hinten\nhallo")
class TextTabStopTextBeforeTab_ExceptCorrectResult(_VimTest): class TextTabStopTextBeforeTab_ExceptCorrectResult(_VimTest):
snippets = ("test", "Vorne $1\n$1") snippets = ("test", "Vorne $1\n$1")
wanted = "Vorne hallo\nhallo"
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"Vorne hallo\nhallo")
class TextTabStopTextSurroundedTab_ExceptCorrectResult(_VimTest): class TextTabStopTextSurroundedTab_ExceptCorrectResult(_VimTest):
snippets = ("test", "Vorne $1 Hinten\n$1") snippets = ("test", "Vorne $1 Hinten\n$1")
wanted = "Vorne hallo test Hinten\nhallo test"
def cmd(self): def cmd(self):
self.type("test\thallo test") self.type("test\thallo test")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"Vorne hallo test Hinten\nhallo test")
class TextTabStopTextBeforeMirror_ExceptCorrectResult(_VimTest): class TextTabStopTextBeforeMirror_ExceptCorrectResult(_VimTest):
snippets = ("test", "$1\nVorne $1") snippets = ("test", "$1\nVorne $1")
wanted = "hallo\nVorne hallo"
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo\nVorne hallo")
class TextTabStopAfterMirror_ExceptCorrectResult(_VimTest): class TextTabStopAfterMirror_ExceptCorrectResult(_VimTest):
snippets = ("test", "$1\n$1 Hinten") snippets = ("test", "$1\n$1 Hinten")
wanted = "hallo\nhallo Hinten"
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo\nhallo Hinten")
class TextTabStopSurroundMirror_ExceptCorrectResult(_VimTest): class TextTabStopSurroundMirror_ExceptCorrectResult(_VimTest):
snippets = ("test", "$1\nVorne $1 Hinten") snippets = ("test", "$1\nVorne $1 Hinten")
wanted = "hallo welt\nVorne hallo welt Hinten"
def cmd(self): def cmd(self):
self.type("test\thallo welt") self.type("test\thallo welt")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo welt\nVorne hallo welt Hinten")
class TextTabStopAllSurrounded_ExceptCorrectResult(_VimTest): class TextTabStopAllSurrounded_ExceptCorrectResult(_VimTest):
snippets = ("test", "ObenVorne $1 ObenHinten\nVorne $1 Hinten") snippets = ("test", "ObenVorne $1 ObenHinten\nVorne $1 Hinten")
wanted = "ObenVorne hallo welt ObenHinten\nVorne hallo welt Hinten"
def cmd(self): def cmd(self):
self.type("test\thallo welt") self.type("test\thallo welt")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"ObenVorne hallo welt ObenHinten\nVorne hallo welt Hinten")
# TODO: mirror mit tabstop mit default variable # TODO: mirror mit tabstop mit default variable
# TODO: Mehrer tabs und mehrere mirrors # TODO: Mehrer tabs und mehrere mirrors
class TextTabStopSimpleMirrorMultiline_ExceptCorrectResult(_VimTest): class TextTabStopSimpleMirrorMultiline_ExceptCorrectResult(_VimTest):
snippets = ("test", "$1\n$1") snippets = ("test", "$1\n$1")
wanted = "hallo\nhallo"
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo\nhallo") class SimpleMirrorMultilineMany_ExceptCorrectResult(_VimTest):
class TextTabStopSimpleMirrorMultilineMany_ExceptCorrectResult(_VimTest):
snippets = ("test", " $1\n$1\na$1b\n$1\ntest $1 mich") snippets = ("test", " $1\n$1\na$1b\n$1\ntest $1 mich")
wanted = " hallo\nhallo\nahallob\nhallo\ntest hallo mich"
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output," hallo\nhallo\nahallob\nhallo\ntest hallo mich")
class TextTabStopSimpleMirrorDelete_ExceptCorrectResult(_VimTest): class SimpleMirrorDelete_ExceptCorrectResult(_VimTest):
snippets = ( snippets = ("test", "$1\n$1")
("test", "$1\n$1"), wanted = "hal\nhal"
)
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
self.type("\b\b") self.type("\b\b")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hal\nhal")
class TextTabStopSimpleMirrorSameLine_ExceptCorrectResult(_VimTest): class SimpleMirrorSameLine_ExceptCorrectResult(_VimTest):
snippets = ( snippets = ("test", "$1 $1")
("test", "$1 $1"), wanted = "hallo hallo"
)
def cmd(self): def cmd(self):
self.type("test\thallo") self.type("test\thallo")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo hallo") class SimpleMirrorSameLineMany_ExceptCorrectResult(_VimTest):
class TextTabStopSimpleMirrorSameLineMany_ExceptCorrectResult(_VimTest): snippets = ("test", "$1 $1 $1 $1")
snippets = ( wanted = "hallo du hallo du hallo du hallo du"
("test", "$1 $1 $1 $1"),
)
def cmd(self): def cmd(self):
self.type("test\thallo du") self.type("test\thallo du")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"hallo du hallo du hallo du hallo du") class SimpleMirrorDeleteSomeEnterSome_ExceptCorrectResult(_VimTest):
class TextTabStopSimpleMirrorDeleteSomeEnterSome_ExceptCorrectResult(_VimTest): snippets = ("test", "$1\n$1")
snippets = ( wanted = "halhups\nhalhups"
("test", "$1\n$1"),
)
def cmd(self): def cmd(self):
self.type("test\thallo\b\bhups") self.type("test\thallo\b\bhups")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,"halhups\nhalhups")
class TextTabStopSimpleTabstopWithDefaultSimpelType_ExceptCorrectResult(_VimTest): class SimpleTabstopWithDefaultSimpelType_ExceptCorrectResult(_VimTest):
snippets = ("test", "ha ${1:defa}\n$1") snippets = ("test", "ha ${1:defa}\n$1")
wanted = "ha world\nworld"
def cmd(self): def cmd(self):
self.type("test\tworld") self.type("test\tworld")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output, "ha world\nworld") class SimpleTabstopWithDefaultComplexType_ExceptCorrectResult(_VimTest):
class TextTabStopSimpleTabstopWithDefaultComplexType_ExceptCorrectResult(_VimTest):
snippets = ("test", "ha ${1:default value} $1\nanother: $1 mirror") snippets = ("test", "ha ${1:default value} $1\nanother: $1 mirror")
wanted = "ha world world\nanother: world mirror"
def cmd(self): def cmd(self):
self.type("test\tworld") self.type("test\tworld")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output, class SimpleTabstopWithDefaultSimpelKeep_ExceptCorrectResult(_VimTest):
"ha world world\nanother: world mirror")
class TextTabStopSimpleTabstopWithDefaultSimpelKeep_ExceptCorrectResult(_VimTest):
snippets = ("test", "ha ${1:defa}\n$1") snippets = ("test", "ha ${1:defa}\n$1")
wanted = "ha defa\ndefa"
def cmd(self): def cmd(self):
self.type("test\t") self.type("test\t")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output, "ha defa\ndefa") class SimpleTabstopWithDefaultComplexKeep_ExceptCorrectResult(_VimTest):
class TextTabStopSimpleTabstopWithDefaultComplexKeep_ExceptCorrectResult(_VimTest):
snippets = ("test", "ha ${1:default value} $1\nanother: $1 mirror") snippets = ("test", "ha ${1:default value} $1\nanother: $1 mirror")
wanted = "ha default value default value\nanother: default value mirror"
def cmd(self): def cmd(self):
self.type("test\t") self.type("test\t")
def runTest(self): def runTest(self): self.check_output()
self.assertEqual(self.output,
"ha default value default value\nanother: default value mirror")
# class TextTabStopMirrorMoreInvolved_ExceptCorrectResult(_VimTest): # class MirrorMoreInvolved_ExceptCorrectResult(_VimTest):
# snippets = ( # snippets = (
# ("for", "for(size_t ${2:i} = 0; $2 < ${1:count}; ${3:++$2})\n{\n\t${0:/* code */}\n}"), # ("for", "for(size_t ${2:i} = 0; $2 < ${1:count}; ${3:++$2})\n{\n\t${0:/* code */}\n}"),
# ) # )