def testDeclarationSet2(self): '''Just tries to parse and sees that everything was parsed, doesn't predict the result''' parser = SPGenerator.buildParser("declarationset") result = TextTools.tag(declaration, parser) assert result[-1] == len( declaration ), '''Didn't complete parse of the simpleparse declaration, only got %s chars, should have %s''' % ( result[-1], len(declaration))
def doBasicTest( self, parserName, testValue, expected, ): parser = SPGenerator.buildParser(parserName) result = TextTools.tag(testValue, parser) assert result == expected, '''\nexpected:%s\n got:%s\n''' % ( pprint.pformat(expected), pprint.pformat(result))
"""Tests that simpleparsegrammar does parse SimpleParse grammars """ import unittest, pprint from simpleparse.simpleparsegrammar import SPGenerator, declaration from simpleparse.parser import Parser from simpleparse.stt.TextTools import TextTools from .genericvalues import NullResult, AnyInt from simpleparse.stt.TextTools import print_tagtable print_tagtable(SPGenerator.buildParser('range')) class SimpleParseGrammarTests(unittest.TestCase): """Test parsing of the the simpleparse grammar elements""" def doBasicTest( self, parserName, testValue, expected, ): parser = SPGenerator.buildParser(parserName) result = TextTools.tag(testValue, parser) assert result == expected, '''\nexpected:%s\n got:%s\n''' % ( pprint.pformat(expected), pprint.pformat(result)) def testChar1(self): self.doBasicTest( "CHARNODBLQUOTE", 'test\\""', (1, [], 4), )
def testDeclarationSet2( self ): '''Just tries to parse and sees that everything was parsed, doesn't predict the result''' parser = SPGenerator.buildParser( "declarationset" ) result = TextTools.tag( declaration, parser ) assert result[-1] == len(declaration), '''Didn't complete parse of the simpleparse declaration, only got %s chars, should have %s'''%(result[-1], len(declaration))
def doBasicTest(self, parserName, testValue, expected, ): parser = SPGenerator.buildParser( parserName ) result = TextTools.tag( testValue, parser ) assert result == expected, '''\nexpected:%s\n got:%s\n'''%( pprint.pformat(expected), pprint.pformat(result))
"""Tests that simpleparsegrammar does parse SimpleParse grammars """ import unittest,pprint from simpleparse.simpleparsegrammar import SPGenerator, declaration from simpleparse.parser import Parser from simpleparse.stt.TextTools import TextTools from .genericvalues import NullResult, AnyInt from simpleparse.stt.TextTools import print_tagtable print_tagtable( SPGenerator.buildParser( 'range' ) ) class SimpleParseGrammarTests(unittest.TestCase): """Test parsing of the the simpleparse grammar elements""" def doBasicTest(self, parserName, testValue, expected, ): parser = SPGenerator.buildParser( parserName ) result = TextTools.tag( testValue, parser ) assert result == expected, '''\nexpected:%s\n got:%s\n'''%( pprint.pformat(expected), pprint.pformat(result)) def testChar1( self ): self.doBasicTest( "CHARNODBLQUOTE", 'test\\""', (1, [], 4), ) def testChar2( self ): self.doBasicTest( "ESCAPEDCHAR", '\\n"', (1, [('SPECIALESCAPEDCHAR', 1, 2, NullResult)], 2),