Beispiel #1
0
 def testEmptyString(self):
     seq = madlib.parse("")
     self.assertEquals(madlib.expand(seq), "")
Beispiel #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")
Beispiel #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")
Beispiel #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")
Beispiel #5
0
 def testNestedSimpleAlternate(self):
     seq = madlib.parse("a{x{y}z}b")
     self.assertEquals(madlib.expand(seq), "axyzb")
Beispiel #6
0
 def testNestedAlternates(self):
     seq = madlib.parse("a{x{y|y}z{q}")
     self.assertEquals(madlib.expand(seq), "axyzq")
Beispiel #7
0
 def testAlternateMarkerOutsideOfAlternate(self):
     seq = madlib.parse("foo|bar")
     self.assertEquals(madlib.expand(seq), "foo|bar")
Beispiel #8
0
 def testAlternate(self):
     seq = madlib.parse("a{x|x}b")
     self.assertEquals(madlib.expand(seq), "axb")
Beispiel #9
0
 def testAlternateOfEmpty(self):
     seq = madlib.parse("foo{|}bar")
     self.assertEquals(madlib.expand(seq), "foobar")
Beispiel #10
0
 def testSimpleStringWithEmptyAlternate(self):
     seq = madlib.parse("ab{}cd")
     self.assertEquals(madlib.expand(seq), "abcd")
Beispiel #11
0
 def testSimpleAlternate(self):
     seq = madlib.parse("{x}")
     self.assertEquals(madlib.expand(seq), "x")
Beispiel #12
0
 def testEmptyAlternative(self):
     seq = madlib.parse("{}")
     self.assertEquals(madlib.expand(seq), "")
Beispiel #13
0
 def testSimpleString(self):
     seq = madlib.parse("hello")
     self.assertEquals(madlib.expand(seq), "hello")