Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.assertEqual(read.first, 1)
self.assertEqual(read.rest.first, 2)
self.assertEqual(str(read), 'Reader(1@0)')
self.assertEqual(str(read.rest.rest.rest), 'Reader(finished)')
read = StringReader('a b')
self.assertEqual(read.first, 'a')
self.assertEqual(read.rest.first, ' ')
self.assertEqual(str(read), 'StringReader(a@0)')
self.assertEqual(str(read.rest.rest.rest), 'StringReader(finished)')
cont = Continue(read, 40)
self.assertEqual(cont.value, 40)
self.assertEqual(str(cont), 'Continue(40, StringReader(a@0))')
back = Backtrack(read, lambda: 'no further')
self.assertEqual(back.expected[0](), 'no further')
self.assertEqual(str(back), "Backtrack(StringReader(a@0), ['no further'])")
error = ParseError('Expected a but found b at index 0')
self.assertEqual(str(error), 'Expected a but found b at index 0')
self.assertEqual(repr(error), "ParseError('Expected a but found b at index 0')")