def test_parse_lowercases(self):
     # Arrange
     txt_succ = 'abcABC'
     txt_fail = 'ABC'
     parser = stp.parse_lowercases()
     parser_label = stp.parse_lowercases('spam')
     # Act
     res_succ = parser(txt_succ)
     res_fail = parser(txt_fail)
     exp_succ = res.Success.unit(("abc", "ABC"))
     exp_fail = res.Failure.unit("error")
     # Assert
     self.assertEqual(res_succ, exp_succ)
     self.assertEqual(res_fail, exp_fail)
     self.assertEqual(parser.label, '[a-z]+')
     self.assertEqual(parser_label.label, 'spam')
 def test_FailureCase(self):
     # Arrange
     txt1 = 'ABC'
     sep = bpr.LParser(",")
     item = stp.parse_lowercases()
     parser = cmb.sep_by(item, sep)
     # Act
     result1 = parser(txt1)
     expected1 = res.Failure('error')
     # Assert
     self.assertEqual(result1, expected1)
 def test_FailureCase(self):
     # Arrange
     txt = '123abc lorem ipsum'
     parser_l = stp.parse_lowercases()
     parser_r = stp.parse_digits()
     parser = cmb.rightparser(parser_l, parser_r)
     # Act
     result = parser(txt)
     expected = res.Failure('error')
     # Assert
     self.assertEqual(result, expected)
 def test_SuccessCase(self):
     # Arrange
     txt = 'abc123 lorem ipsum'
     parser_l = stp.parse_lowercases()
     parser_r = stp.parse_digits()
     parser = cmb.rightparser(parser_l, parser_r)
     # Act
     result = parser(txt)
     expected = res.Success(('123', ' lorem ipsum'))
     # Assert
     self.assertEqual(result, expected)
 def test_FailureCase(self):
     # Arrange
     txt = 'ABCabc123 lorem ipsum'
     parser_l = stp.parse_uppercases()
     parser_m = stp.parse_digits()
     parser_r = stp.parse_lowercases()
     parser = cmb.betweenparsers(parser_l, parser_m, parser_r)
     # Act
     result = parser(txt)
     expected = res.Failure('error')
     # Assert
     self.assertEqual(result, expected)
 def test_SuccessCase(self):
     # Arrange
     txt = 'ABCabc123 lorem ipsum'
     parser_l = stp.parse_uppercases()
     parser_m = stp.parse_lowercases()
     parser_r = stp.parse_digits()
     parser = cmb.betweenparsers(parser_l, parser_m, parser_r)
     # Act
     result = parser(txt)
     expected = res.Success(('abc', ' lorem ipsum'))
     # Assert
     self.assertEqual(result, expected)
 def test_SuccessCase(self):
     # Arrange
     txt1 = 'abc,def,ghi'
     txt2 = 'abc'
     txt3 = 'abc,def,ghi2132'
     sep = bpr.LParser(",")
     item = stp.parse_lowercases()
     parser = cmb.sep_by1(item, sep)
     # Act
     result1 = parser(txt1)
     expected1 = res.Success(('abc,def,ghi', ''))
     result2 = parser(txt2)
     expected2 = res.Success(('abc', ''))
     result3 = parser(txt3)
     expected3 = res.Success(('abc,def,ghi', '2132'))
     # Assert
     self.assertEqual(result1, expected1)
     self.assertEqual(result2, expected2)
     self.assertEqual(result3, expected3)