示例#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"