Home | History | Annotate | Download | only in tests
      1 import os
      2 import sys
      3 import antlr3
      4 import testbase
      5 import unittest
      6 from io import StringIO
      7 
      8 class t020fuzzy(testbase.ANTLRTest):
      9     def setUp(self):
     10         self.compileGrammar('t020fuzzyLexer.g')
     11         
     12 
     13     def testValid(self):
     14         inputPath = os.path.splitext(__file__)[0] + '.input'
     15         with open(inputPath) as f:
     16             stream = antlr3.StringStream(f.read())
     17         lexer = self.getLexer(stream)
     18 
     19         while True:
     20             token = lexer.nextToken()
     21             if token.type == antlr3.EOF:
     22                 break
     23 
     24 
     25         output = lexer.output.getvalue()
     26 
     27         outputPath = os.path.splitext(__file__)[0] + '.output'
     28         with open(outputPath) as f:
     29             testOutput = f.read()
     30 
     31         self.assertEqual(output, testOutput)
     32 
     33 
     34 if __name__ == '__main__':
     35     unittest.main()
     36