Exemple #1
0
 def testEmptyString(self):
     seq = madlib.parse("")
     self.assertEquals(madlib.expand(seq), "")
Exemple #2
0
 def testAlternateLeftOpen(self):
     """TODO: this should fail to parse"""
     seq = madlib.parse("x{y|")
     chooser = lambda p: p[-1]
     self.assertEquals(madlib.expand(seq, chooser=chooser), "xy")
Exemple #3
0
 def testCrazyScenario1(self):
     seq = madlib.parse("{{a|b}|{|grot}}foo")
     chooser = lambda p: p[0]
     self.assertEquals(madlib.expand(seq, chooser=chooser), "afoo")
Exemple #4
0
 def testCrazyScenario2(self):
     seq = madlib.parse("{{a|{|{x|}b}}foo")
     chooser = lambda p: p[-1]
     self.assertEquals(madlib.expand(seq, chooser=chooser), "bfoo")
Exemple #5
0
 def testNestedSimpleAlternate(self):
     seq = madlib.parse("a{x{y}z}b")
     self.assertEquals(madlib.expand(seq), "axyzb")
Exemple #6
0
 def testNestedAlternates(self):
     seq = madlib.parse("a{x{y|y}z{q}")
     self.assertEquals(madlib.expand(seq), "axyzq")
Exemple #7
0
 def testAlternateMarkerOutsideOfAlternate(self):
     seq = madlib.parse("foo|bar")
     self.assertEquals(madlib.expand(seq), "foo|bar")
Exemple #8
0
 def testAlternate(self):
     seq = madlib.parse("a{x|x}b")
     self.assertEquals(madlib.expand(seq), "axb")
Exemple #9
0
 def testAlternateOfEmpty(self):
     seq = madlib.parse("foo{|}bar")
     self.assertEquals(madlib.expand(seq), "foobar")
Exemple #10
0
 def testSimpleStringWithEmptyAlternate(self):
     seq = madlib.parse("ab{}cd")
     self.assertEquals(madlib.expand(seq), "abcd")
Exemple #11
0
 def testSimpleAlternate(self):
     seq = madlib.parse("{x}")
     self.assertEquals(madlib.expand(seq), "x")
Exemple #12
0
 def testEmptyAlternative(self):
     seq = madlib.parse("{}")
     self.assertEquals(madlib.expand(seq), "")
Exemple #13
0
 def testSimpleString(self):
     seq = madlib.parse("hello")
     self.assertEquals(madlib.expand(seq), "hello")