Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
 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)
Beispiel #4
0
    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)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
 def testCanParseRedirection(self):
     scanner = Scanner("w>>")
     tokens = list(scanner.scan())
     params = {'++': '', 'file_name': '', '>>': True, 'cmd': ''}
     self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)
Beispiel #8
0
 def testCanInstantiateAlias(self):
     scanner = Scanner("w")
     tokens = list(scanner.scan())
     params = {'++': '', 'file_name': '', '>>': False, 'cmd': ''}
     self.assertEqual([TokenCommandWrite(params), TokenEof()], tokens)