Well that's the basic func load test. Slight complication in handling entity codes, and some mucking about to get the indentation right. Still this passes now.
#
# a little utility func to interpolate different strings
# into the comment of the test func
#
def junkify(junk):
return """
function lua_func()
print "lua stuff"
end
--
-- let's put some funky stuff in this comment
-- ${junk}
--
lua_func()
"""
[Test]
def save_func():
#
# ok - I'm going to put some reserved chars
# in this - they should appear in the save
# file as entity codes
#
# so let's have two versions of the junk string
# one with the codes that we use to set up the Func
# and one with entities that we use to check the saved data
#
junk = """<>[]'"7;--"""
junk_ent = """<>[]'"7;--"""
#
# we set up the target string using the entity version
#
target = detab("""
<func>
${junkify(junk_ent)}
</func>
""")
#
# and initialise the func with vanilla junk
#
f = Func()
f.code = junkify(junk)
sw = StringWriter()
xs = XmlWriterSettings()
xs.Indent = true
xs.IndentChars = " "
xs.NewLineChars = "\n"
xs.OmitXmlDeclaration = true
using r = XmlWriter.Create(sw, xs):
f.save(r)
I am feeling sorely tempted to go back to writing the app for a bit. I have plenty of test cases written in advance, and they're making my head hurt. Let's write some more actual code until I hit something that needs testing...
No comments:
Post a Comment