def testConsumingReachesEof(self): state = ScannerState("f") state.consume() eof = state.consume() self.assertEqual(EOF, eof) self.assertEqual(1, state.position)
def testConsumingReachesEof(self): state = ScannerState("f") state.consume() eof = state.consume() self.assertEqual(EOF, eof) self.assertEqual(1, state.position)
def test_match_CanSucceed(self): state = ScannerState('foo123') state.consume() state.consume() state.consume() self.assertTrue(state.match(r'\d{3}')) self.assertEqual(6, state.position) self.assertEqual(EOF, state.consume())
def test_match_CanSucceed(self): state = ScannerState("foo123") state.consume() state.consume() state.consume() self.assertTrue(state.match(r"\d{3}")) self.assertEqual(6, state.position) self.assertEqual(EOF, state.consume())
def testConsumingStopsAtEof(self): state = ScannerState("f") state.consume() a = state.consume() b = state.consume() c = state.consume() self.assertEqual([EOF, EOF, EOF], [a, b, c]) self.assertEqual(1, state.position) self.assertEqual(0, state.start)
def testConsumingStopsAtEof(self): state = ScannerState("f") state.consume() a = state.consume() b = state.consume() c = state.consume() self.assertEqual([EOF, EOF, EOF], [a, b, c]) self.assertEqual(1, state.position) self.assertEqual(0, state.start)
def testCanConsume(self): state = ScannerState("foo") c = state.consume() self.assertEqual('f', c) self.assertEqual(1, state.position) self.assertEqual(0, state.start)
def testCanConsume(self): state = ScannerState("foo") c = state.consume() self.assertEqual("f", c) self.assertEqual(1, state.position) self.assertEqual(0, state.start)
def test_skip_run_StopsAtEof(self): state = ScannerState("aaf") state.skip_run("af") self.assertEqual(3, state.position) self.assertEqual(EOF, state.consume())
def test_skip_run_Works(self): state = ScannerState("aafoo") state.skip_run("af") self.assertEqual(3, state.position) self.assertEqual('o', state.consume())
def test_skip_Works(self): state = ScannerState("aafoo") state.skip("a") self.assertEqual(2, state.position) self.assertEqual('f', state.consume())
def test_backup_Works(self): state = ScannerState("foo") state.consume() state.consume() state.backup()
def test_skip_run_StopsAtEof(self): state = ScannerState("aaf") state.skip_run("af") self.assertEqual(3, state.position) self.assertEqual(EOF, state.consume())
def test_skip_run_Works(self): state = ScannerState("aafoo") state.skip_run("af") self.assertEqual(3, state.position) self.assertEqual("o", state.consume())
def test_skip_Works(self): state = ScannerState("aafoo") state.skip("a") self.assertEqual(2, state.position) self.assertEqual("f", state.consume())
def test_backup_Works(self): state = ScannerState("foo") state.consume() state.consume() state.backup()