def test_GIVEN_exeunt_statement_WHEN_parsing_stage_control_THEN_no_parse_error(
            self):
        tokens = [
            Token(TokenTypes.OpenSqBracket),
            Token(TokenTypes.Exeunt),
            Token(TokenTypes.CloseSqBracket),
            Token(TokenTypes.Eof),
        ]

        parser = Parser(t for t in tokens)

        parser.stagecontrol()
    def test_GIVEN_enter_statement_with_one_character_WHEN_parsing_stage_control_THEN_no_parse_error(
            self):
        tokens = [
            Token(TokenTypes.OpenSqBracket),
            Token(TokenTypes.Enter),
            Token(TokenTypes.Name, "A"),
            Token(TokenTypes.CloseSqBracket),
            Token(TokenTypes.Eof),
        ]

        parser = Parser(t for t in tokens)

        parser.stagecontrol()
    def test_GIVEN_enter_statement_with_no_characters_WHEN_parsing_stage_control_THEN_parse_error(
            self):
        tokens = [
            Token(TokenTypes.OpenSqBracket),
            Token(TokenTypes.Enter),
            Token(TokenTypes.CloseSqBracket),
            Token(TokenTypes.Eof),
        ]

        parser = Parser(t for t in tokens)

        with self.assertRaises(SPLSyntaxError):
            parser.stagecontrol()
    def test_GIVEN_a_character_not_on_stage_WHEN_that_character_leaves_THEN_parse_error(
            self):
        tokens = [
            Token(TokenTypes.OpenSqBracket),
            Token(TokenTypes.Exit),
            Token(TokenTypes.Name, "A"),
            Token(TokenTypes.CloseSqBracket),
            Token(TokenTypes.Eof),
        ]

        parser = Parser(t for t in tokens)

        with self.assertRaises(SPLSyntaxError):
            parser.stagecontrol()
    def test_GIVEN_a_character_on_stage_WHEN_that_character_leaves_THEN_no_parse_error(
            self):
        tokens = [
            Token(TokenTypes.OpenSqBracket),
            Token(TokenTypes.Exit),
            Token(TokenTypes.Name, "A"),
            Token(TokenTypes.CloseSqBracket),
            Token(TokenTypes.Eof),
        ]

        parser = Parser(t for t in tokens)
        parser.onstage = ["A"]

        parser.stagecontrol()
    def test_GIVEN_many_characters_on_stage_WHEN_exeunt_THEN_noone_left_on_stage(
            self):
        tokens = [
            Token(TokenTypes.OpenSqBracket),
            Token(TokenTypes.Exeunt),
            Token(TokenTypes.CloseSqBracket),
            Token(TokenTypes.Eof),
        ]

        parser = Parser(t for t in tokens)

        parser.onstage = ["A", "B", "C", "D"]

        parser.stagecontrol()

        self.assertEqual(parser.onstage, [])