Exemplo n.º 1
0
 def test_value_or_more(self):
     assert ValueOrMore(4).quantify(String("1")) == "1111"
Exemplo n.º 2
0
 def test_value_or_less(self):
     assert ValueOrLess(4).quantify(String("1")) == ""
Exemplo n.º 3
0
 def stringify(self, string_expression):
     return String(str(string_expression))
Exemplo n.º 4
0
 def test_group_within_a_group(self):
     assert Quantified(Quantified(String("A"), Exactly(1)),
                       Exactly(1)) == "A"
Exemplo n.º 5
0
 def test_value_or_more(self):
     quantifier = QuantifierFactory.get(RegularExpression("{4,}"))
     assert quantifier.quantify(String("4")) == "4444"
Exemplo n.º 6
0
 def test_plus(self):
     quantifier = QuantifierFactory.get(RegularExpression("+"))
     assert quantifier.quantify(String("4")) == "4"
Exemplo n.º 7
0
 def test_group_with_multiple_items_multiplication(self):
     assert Group([String("abc"),
                   Quantified(String("def"), Exactly(2))
                   ]) * 2 == "abcdefdefabcdefdef"
Exemplo n.º 8
0
 def test_exactly(self):
     quantifier = QuantifierFactory.get(RegularExpression("{3}"))
     assert quantifier.quantify(String("4")) == "444"
Exemplo n.º 9
0
 def test_group_within_a_group(self):
     assert Group([Group([String("abc")])]) == "abc"
Exemplo n.º 10
0
 def test_group_with_a_single_item_multiplication(self):
     assert Group([String("abc")]) * 2 == "abcabc"
Exemplo n.º 11
0
 def test_group_with_a_single_item(self):
     assert Group([String("abc")]) == "abc"
Exemplo n.º 12
0
 def test_str(self):
     assert Quantified(String("1"), Exactly(1)) == "1"
Exemplo n.º 13
0
 def test_multiplication(self):
     assert (Quantified(String("1"), Exactly(1)) * 2) * 2 == "1111"
Exemplo n.º 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"
Exemplo n.º 15
0
 def test_group_within_a_group_multiplication(self):
     assert Group([Group([String("abc")])]) * 2 == "abcabc"
Exemplo n.º 16
0
 def test_question_mark(self):
     quantifier = QuantifierFactory.get(RegularExpression("?"))
     assert quantifier.quantify(String("4")) == ""
Exemplo n.º 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"
Exemplo n.º 18
0
 def test_between(self):
     quantifier = QuantifierFactory.get(RegularExpression("{5,6}"))
     assert quantifier.quantify(String("4")) == "44444"
Exemplo n.º 19
0
 def test_one_or_more(self):
     assert OneOrMore().quantify(String("111")) == "111"
Exemplo n.º 20
0
 def test_value_or_less(self):
     quantifier = QuantifierFactory.get(RegularExpression("{,4}"))
     assert quantifier.quantify(String("4")) == ""
Exemplo n.º 21
0
 def test_zero_or_more(self):
     assert ZeroOrMore().quantify(String("1")) == ""
Exemplo n.º 22
0
 def test_string_multiplication(self):
     assert String("F") * 4 == "FFFF"
Exemplo n.º 23
0
 def test_zero_or_one(self):
     assert ZeroOrOne().quantify(String("1")) == ""
Exemplo n.º 24
0
 def __mul__(self, other):
     return String(str(self)) * other
Exemplo n.º 25
0
 def test_quantifiers(self):
     assert Quantified(String("A"), Exactly(2)) == "AA"