Python Save() and SavedLiteral(). Split factory and matcher.

This commit is contained in:
Ian Gulliver
2014-08-03 11:25:29 -07:00
parent b11a659f0c
commit d0ab66a823
3 changed files with 76 additions and 19 deletions

16
test.py
View File

@@ -2,7 +2,7 @@
import recentrunes
parser = recentrunes.Parser.fromFile('static/grammars/mediawiki.js')
mediawiki = recentrunes.Parser.fromFile('static/grammars/mediawiki.js')
teststring = \
"""This is a paragraph with many text styles. This is ''italic'' and this
is '''bold'''; this is '''''both'''''. This is <u>underline</u> as is
@@ -38,7 +38,7 @@ shouldn't be visible --><blockquote>This is a blockquote</blockquote>
This line is pre-formatted and <del>not interpolated</del>
This line is also pre-formatted"""
result = str(parser.parseFromString(teststring))
result = str(mediawiki.parseFromString(teststring))
assert result == \
"""<wikidoc><p>This is a paragraph with many text styles. This is <i>italic</i> and this
is <b>bold</b>; this is <b><i>both</i></b>. This is <u>underline</u> as is
@@ -53,4 +53,14 @@ This line is also pre-formatted
</pre></p></wikidoc>""", result
parser = recentrunes.Parser.fromFile('static/grammars/badpenny.js')
badpenny = recentrunes.Parser.fromFile('static/grammars/badpenny.js')
teststring = \
"""foo{{value1}}bar
foo{{(container1}}contents{{)nottheend}}more contents{{)container1}}bar
foo{{[repeated1}}testing{{]notthis}}{{)repeated1}}zig{{]repeated1}}bar"""
result = str(badpenny.parseFromString(teststring))
assert result == \
"""<badpenny>foo<value name="value1"></value>bar
foo<container name="container1">contents{{)nottheend}}more contents</container>bar
foo<repeated name="repeated1">testing{{]notthis}}{{)repeated1}}zig</repeated>bar</badpenny>"""