예제 #1
0
 def test_value_or_more(self):
     assert ValueOrMore(4).quantify(String("1")) == "1111"
예제 #2
0
 def test_value_or_less(self):
     assert ValueOrLess(4).quantify(String("1")) == ""
예제 #3
0
파일: compose.py 프로젝트: rinslow/regene
 def stringify(self, string_expression):
     return String(str(string_expression))
예제 #4
0
 def test_group_within_a_group(self):
     assert Quantified(Quantified(String("A"), Exactly(1)),
                       Exactly(1)) == "A"
예제 #5
0
 def test_value_or_more(self):
     quantifier = QuantifierFactory.get(RegularExpression("{4,}"))
     assert quantifier.quantify(String("4")) == "4444"
예제 #6
0
 def test_plus(self):
     quantifier = QuantifierFactory.get(RegularExpression("+"))
     assert quantifier.quantify(String("4")) == "4"
예제 #7
0
 def test_group_with_multiple_items_multiplication(self):
     assert Group([String("abc"),
                   Quantified(String("def"), Exactly(2))
                   ]) * 2 == "abcdefdefabcdefdef"
예제 #8
0
 def test_exactly(self):
     quantifier = QuantifierFactory.get(RegularExpression("{3}"))
     assert quantifier.quantify(String("4")) == "444"
예제 #9
0
 def test_group_within_a_group(self):
     assert Group([Group([String("abc")])]) == "abc"
예제 #10
0
 def test_group_with_a_single_item_multiplication(self):
     assert Group([String("abc")]) * 2 == "abcabc"
예제 #11
0
 def test_group_with_a_single_item(self):
     assert Group([String("abc")]) == "abc"
예제 #12
0
 def test_str(self):
     assert Quantified(String("1"), Exactly(1)) == "1"
예제 #13
0
 def test_multiplication(self):
     assert (Quantified(String("1"), Exactly(1)) * 2) * 2 == "1111"
예제 #14
0
 def test_between(self):
     assert Between(1, 4).quantify(String("f")) == "f"
     assert Between(0, 4).quantify(String("f")) == ""
     assert Between(2, 4).quantify(String("f")) == "ff"
예제 #15
0
 def test_group_within_a_group_multiplication(self):
     assert Group([Group([String("abc")])]) * 2 == "abcabc"
예제 #16
0
 def test_question_mark(self):
     quantifier = QuantifierFactory.get(RegularExpression("?"))
     assert quantifier.quantify(String("4")) == ""
예제 #17
0
 def test_exactly(self):
     assert Exactly(1).quantify(String("1")) == "1"
     assert Exactly(0).quantify(String("1")) == ""
     assert Exactly(2).quantify(String("1")) == "11"
예제 #18
0
 def test_between(self):
     quantifier = QuantifierFactory.get(RegularExpression("{5,6}"))
     assert quantifier.quantify(String("4")) == "44444"
예제 #19
0
 def test_one_or_more(self):
     assert OneOrMore().quantify(String("111")) == "111"
예제 #20
0
 def test_value_or_less(self):
     quantifier = QuantifierFactory.get(RegularExpression("{,4}"))
     assert quantifier.quantify(String("4")) == ""
예제 #21
0
 def test_zero_or_more(self):
     assert ZeroOrMore().quantify(String("1")) == ""
예제 #22
0
 def test_string_multiplication(self):
     assert String("F") * 4 == "FFFF"
예제 #23
0
 def test_zero_or_one(self):
     assert ZeroOrOne().quantify(String("1")) == ""
예제 #24
0
 def __mul__(self, other):
     return String(str(self)) * other
예제 #25
0
 def test_quantifiers(self):
     assert Quantified(String("A"), Exactly(2)) == "AA"