def testCanParsePlusPlusEdit(self): scanner = Scanner("w ++edit") tokens = list(scanner.scan()) params = {'++': 'edit', 'file_name': '', '>>': False, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens) scanner = Scanner("w ++fileformat") tokens = list(scanner.scan()) params = {'++': 'fileformat', 'file_name': '', '>>': False, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
def testCanParsePlusPlusNobin(self): scanner = Scanner("w ++nobinary") tokens = list(scanner.scan()) params = {'++': 'nobinary', 'file_name': '', '>>': False, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens) scanner = Scanner("w ++nobin") tokens = list(scanner.scan()) params = {'++': 'nobinary', 'file_name': '', '>>': False, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
def testCanParseCommandAbsorbsEveryThing(self): scanner = Scanner("w !dostuff here") tokens = list(scanner.scan()) params = { '++': '', 'file_name': '', '>>': False, 'cmd': 'dostuff here' } self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
def testCanParsePlusPlusFileencoding(self): scanner = Scanner("w ++fileencoding") tokens = list(scanner.scan()) params = { '++': 'fileencoding', 'file_name': '', '>>': False, 'cmd': '' } self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens) scanner = Scanner("w ++enc") tokens = list(scanner.scan()) params = { '++': 'fileencoding', 'file_name': '', '>>': False, 'cmd': '' } self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
def testCanParseCommandAndDetectFileName(self): scanner = Scanner("w foo.txt") tokens = list(scanner.scan()) params = {'++': '', 'file_name': 'foo.txt', '>>': False, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
def testCanParseRedirectionFollowedByFilenameSeparated(self): scanner = Scanner("w>> foo.txt") tokens = list(scanner.scan()) params = {'++': '', 'file_name': 'foo.txt', '>>': True, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
def testCanParseRedirection(self): scanner = Scanner("w>>") tokens = list(scanner.scan()) params = {'++': '', 'file_name': '', '>>': True, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
def testCanInstantiateAlias(self): scanner = Scanner("w") tokens = list(scanner.scan()) params = {'++': '', 'file_name': '', '>>': False, 'cmd': ''} self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)