Example #1
0
    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()
Example #2
0
    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")
Example #3
0
    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")