diff options
Diffstat (limited to 'examples/sexpParser.py')
| -rw-r--r-- | examples/sexpParser.py | 140 |
1 files changed, 73 insertions, 67 deletions
diff --git a/examples/sexpParser.py b/examples/sexpParser.py index 2a0f2c7..179e10a 100644 --- a/examples/sexpParser.py +++ b/examples/sexpParser.py @@ -97,74 +97,80 @@ sexpList = pp.Group(LPAR + sexp[...] + RPAR) sexp <<= string_ | sexpList -# Test data - -test00 = """(snicker "abc" (#03# |YWJj|))""" -test01 = """(certificate - (issuer - (name - (public-key - rsa-with-md5 - (e 15 |NFGq/E3wh9f4rJIQVXhS|) - (n |d738/4ghP9rFZ0gAIYZ5q9y6iskDJwASi5rEQpEQq8ZyMZeIZzIAR2I5iGE=|)) - aid-committee)) - (subject - (ref - (public-key - rsa-with-md5 - (e |NFGq/E3wh9f4rJIQVXhS|) - (n |d738/4ghP9rFZ0gAIYZ5q9y6iskDJwASi5rEQpEQq8ZyMZeIZzIAR2I5iGE=|)) - tom - mother)) - (not-before "1997-01-01_09:00:00") - (not-after "1998-01-01_09:00:00") - (tag - (spend (account "12345678") (* numeric range "1" "1000")))) -""" -test02 = """(lambda (x) (* x x))""" -test03 = """(def length - (lambda (x) - (cond - ((not x) 0) - ( t (+ 1 (length (cdr x)))) - ) - ) -) -""" -test04 = """(2:XX "abc" (#03# |YWJj|))""" -test05 = """(if (is (window_name) "XMMS") (set_workspace 2))""" -test06 = """(if - (and - (is (application_name) "Firefox") - (or - (contains (window_name) "Enter name of file to save to") - (contains (window_name) "Save As") - (contains (window_name) "Save Image") - () +def main(): + # Test data + + test00 = """(snicker "abc" (#03# |YWJj|))""" + test01 = """(certificate + (issuer + (name + (public-key + rsa-with-md5 + (e 15 |NFGq/E3wh9f4rJIQVXhS|) + (n |d738/4ghP9rFZ0gAIYZ5q9y6iskDJwASi5rEQpEQq8ZyMZeIZzIAR2I5iGE=|)) + aid-committee)) + (subject + (ref + (public-key + rsa-with-md5 + (e |NFGq/E3wh9f4rJIQVXhS|) + (n |d738/4ghP9rFZ0gAIYZ5q9y6iskDJwASi5rEQpEQq8ZyMZeIZzIAR2I5iGE=|)) + tom + mother)) + (not-before "1997-01-01_09:00:00") + (not-after "1998-01-01_09:00:00") + (tag + (spend (account "12345678") (* numeric range "1" "1000")))) + """ + test02 = """(lambda (x) (* x x))""" + test03 = """(def length + (lambda (x) + (cond + ((not x) 0) + ( t (+ 1 (length (cdr x)))) + ) + ) ) - ) - (geometry "+140+122") -) -""" -test07 = """(defun factorial (x) - (if (zerop x) 1 - (* x (factorial (- x 1))))) - """ -test51 = """(2:XX "abc" (#03# |YWJj|))""" -test51error = """(3:XX "abc" (#03# |YWJj|))""" - -test52 = """ - (and - (or (> uid 1000) - (!= gid 20) + """ + test04 = """(2:XX "abc" (#03# |YWJj|))""" + test05 = """(if (is (window_name) "XMMS") (set_workspace 2))""" + test06 = """(if + (and + (is (application_name) "Firefox") + (or + (contains (window_name) "Enter name of file to save to") + (contains (window_name) "Save As") + (contains (window_name) "Save Image") + () + ) ) - (> quota 5.0e+03) + (geometry "+140+122") ) """ - -# Run tests -alltests = [ - globals()[testname] for testname in sorted(locals()) if testname.startswith("test") -] - -sexp.runTests(alltests, fullDump=False) + test07 = """(defun factorial (x) + (if (zerop x) 1 + (* x (factorial (- x 1))))) + """ + test51 = """(2:XX "abc" (#03# |YWJj|))""" + test51error = """(3:XX "abc" (#03# |YWJj|))""" + + test52 = """ + (and + (or (> uid 1000) + (!= gid 20) + ) + (> quota 5.0e+03) + ) + """ + + # Run tests + local_vars = sorted(locals().items()) + alltests = [ + test_fn for testname, test_fn in local_vars if testname.startswith("test") + ] + + sexp.runTests(alltests, fullDump=False) + + +if __name__ == "__main__": + main() |
