예제 #1
0
    def test_basic_grammar_with_booleans_dg(self):
        """ Tests that basic grammar with booleans is correctly generated """
        self.config.use_boolean_features = True
        grammar = bnf.dynamic_generator(self.samples)

        super().assertIn(IS_ASCII, grammar.keys())
        super().assertIn(IS_UPPER, grammar.keys())
예제 #2
0
    def test_basic_grammar_with_token_wildcard_dg(self):
        """ Tests grammar is generated with token wildcard """
        self.config.use_token_wildcard = True

        grammar = bnf.dynamic_generator(self.samples)

        super().assertIn(TOKEN_WILDCARD, grammar[T])
예제 #3
0
    def test_basic_grammar_dg(self):
        """ Tests that basic grammar is correctly generated """
        grammar = bnf.dynamic_generator(self.samples)

        super().assertIn(P, grammar.keys())
        super().assertIn(S, grammar.keys())
        super().assertIn(T, grammar.keys())
        super().assertIn(F, grammar.keys())
        super().assertEqual(len(grammar[SHAPE]), 7)
        super().assertEqual(len(grammar[F]), 9)
예제 #4
0
    def test_basic_grammar_with_booleans_and_custom_attributes_dg(self):
        """ Tests that basic grammar with boolean features and custom attributes is correctly generated  """
        self.config.use_boolean_features = True
        self.config.use_custom_attributes = True

        grammar = bnf.dynamic_generator(self.samples)

        super().assertIn(IS_ASCII, grammar.keys())
        super().assertIn(IS_UPPER, grammar.keys())
        super().assertIn(UNDERSCORE, grammar.keys())
        # super().assertIn(IS_SENT_START, grammar.keys())
        super().assertIn(HAS_VECTOR, grammar.keys())
예제 #5
0
    def test_basic_grammar_with_booleans_and_extended_pattern_syntax_dg(self):
        """ Tests that basic grammar with boolean features and extended pattern syntax is correctly generated """
        self.config.use_boolean_features = True
        self.config.use_extended_pattern_syntax = True

        grammar = bnf.dynamic_generator(self.samples)

        super().assertIn(IS_ASCII, grammar.keys())
        super().assertIn(IS_UPPER, grammar.keys())
        super().assertIn(XPS, grammar.keys())
        super().assertListEqual(grammar[XPS],
                                [IN, NOT_IN, EQQ, GEQ, LEQ, GTH, LTH])
예제 #6
0
    def test_basic_grammar_with_booleans_and_operators_dg(self):
        """ Tests that basic grammar with boolean features and operators is correctly generated """
        self.config.use_boolean_features = True
        self.config.use_grammar_operators = True

        grammar = bnf.dynamic_generator(self.samples)

        super().assertIn(IS_ASCII, grammar.keys())
        super().assertIn(IS_UPPER, grammar.keys())
        super().assertIn(OP, grammar.keys())
        super().assertListEqual(
            grammar[OP], [NEGATION, ZERO_OR_ONE, ONE_OR_MORE, ZERO_OR_MORE])
예제 #7
0
    def test_basic_grammar_without_uniques_dg(self):
        """ Tests that basic grammar is correctly generated when use uniques is false """
        self.config.use_uniques = False
        grammar = bnf.dynamic_generator(self.samples)

        super().assertEqual(len(grammar[SHAPE]), 11)