示例#1
0
    def test_concatenation(self):
        assert parse_regex(" foo bar ") == Concatenation(
            Symbol("foo"),
            Symbol("bar"),
        )

        assert parse_regex(" foo bar baz ") == Concatenation(
            Symbol("foo"),
            Concatenation(
                Symbol("bar"),
                Symbol("baz"),
            ),
        )
示例#2
0
 def test_parentheses(self):
     assert parse_regex(" (foo) (bar baz) * (qux quo)") == Concatenation(
         Symbol("foo"),
         Concatenation(
             Star(Concatenation(
                 Symbol("bar"),
                 Symbol("baz"),
             ), ),
             Concatenation(
                 Symbol("qux"),
                 Symbol("quo"),
             ),
         ),
     )
示例#3
0
    def test_union(self):
        assert parse_regex(" foo | ") == Union(
            Symbol("foo"),
            None,
        )

        assert parse_regex(" foo | bar ") == Union(
            Symbol("foo"),
            Symbol("bar"),
        )

        assert parse_regex(" foo | bar | baz ") == Union(
            Union(
                Symbol("foo"),
                Symbol("bar"),
            ),
            Symbol("baz"),
        )
示例#4
0
 def test_wildcard(self):
     assert parse_regex(" . ") == Symbol(".")
示例#5
0
 def test_symbol(self):
     assert parse_regex(" foo ") == Symbol("foo")
示例#6
0
 def test_query(self):
     assert parse_regex(" foo ? ") == Union(Symbol("foo"), None)
示例#7
0
 def test_plus(self):
     assert parse_regex(" foo + ") == Concatenation(
         Symbol("foo"),
         Star(Symbol("foo")),
     )
示例#8
0
 def test_star(self):
     assert parse_regex(" foo * ") == Star(Symbol("foo"))