def test_GIVEN_two_characters_on_stage_WHEN_get_character_by_name_THEN_can_get_that_character( self): tokens = [Token(TokenTypes.Name, "C"), Token(TokenTypes.Eof)] parser = Parser(t for t in tokens) parser.onstage = ["A", "B"] parser.speaking = "A" self.assertEqual(parser.character_name(), "C")
def test_GIVEN_two_characters_on_stage_WHEN_one_speaking_THEN_2nd_person_pronoun_gets_not_speaking_character( self): tokens = [Token(TokenTypes.SecondPronoun), Token(TokenTypes.Eof)] parser = Parser(t for t in tokens) parser.onstage = ["A", "B"] parser.speaking = "A" self.assertEqual(parser.character_name(), "B")
def test_GIVEN_nonsense_token_WHEN_get_character_by_name_THEN_parse_error( self): tokens = [Token(TokenTypes.Numeral), Token(TokenTypes.Eof)] parser = Parser(t for t in tokens) parser.onstage = ["A", "B"] parser.speaking = "A" with self.assertRaises(SPLSyntaxError): parser.character_name()