/usr/share/pyshared/simpleparse/tests/test_common_comments.py is in python-simpleparse 2.1.0a1-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | """Test the various common library comment productions"""
import unittest, string
from simpleparse.parser import Parser
from simpleparse.common import comments
from simpleparse import dispatchprocessor
parseTests = [
# each production should match the whole of all of the first,
# and not match any of the second...
("c_comment", [
"""/* this */""",
"""/* this \n\n*/""",
],[
"""// this""",
"""# this""",
"""# this\n""",
"""# this\r\n""",
]),
("c_nest_comment", [
"""/* this */""",
"""/* this \n\n*/""",
"""/* /* this */ */""",
"""/* /* this \n*/ */""",
],[
"""// this""",
"""# this""",
"""; this""",
]),
("hash_comment", [
"""# this""",
"""# this\n""",
"""# this\r\n""",
],[
"""// this""",
"""/* this */""",
"""/* /* this */ */""",
]),
("semicolon_comment", [
"""; this""",
"""; this\n""",
"""; this\r\n""",
],[
"""# this""",
"""// this""",
"""/* this */""",
"""/* /* this */ */""",
]),
("slashslash_comment", [
"""// this""",
"""// this\n""",
"""// this\r\n""",
],[
"""# this""",
"""/ this""",
"""/* this */""",
"""/* /* this */ */""",
]),
]
class CommonTests(unittest.TestCase):
def testBasic( self ):
for production, yestable, notable in parseTests:
p = Parser( "x := %s"%production, 'x')
for data in yestable:
success, results, next = p.parse( data)
assert success and (next == len(data)), """Did not parse comment %s as a %s result=%s"""%( repr(data), production, (success, results, next))
assert results, """Didn't get any results for comment %s as a %s result=%s"""%( repr(data), production, (success, results, next))
for data in notable:
success, results, next = p.parse( data)
assert not success, """Parsed %s of %s as a %s result=%s"""%(
next, repr(data), production, results
)
def getSuite():
return unittest.makeSuite(CommonTests, 'test')
if __name__ == "__main__":
unittest.main(defaultTest="getSuite")
|