def testGoodParse(self):
        tokens = lex(util.source('''
            print 'blah'
                print '1!'
                print '2!'
            un_indent_ahoy_and_something_fish'''
        ))

        preamble = PrintStatement.parse(tokens)
        assert isinstance(preamble, PrintStatement)
        assert tokens.getNext() is END_OF_STATEMENT

        assert tokens.peek() is BEGIN_BLOCK, tokens.peek()

        block = BlockStatement.parse(tokens)
        assert block is not None, tokens
Exemple #2
0
    def testBadParse(self):
        list = lex("print 'blah")

        self.failUnlessRaises(Exception, lambda: PrintStatement.parse(list))
Exemple #3
0
 def testFailedParse(self):
     list = lex("pint 'blah'")
     result = PrintStatement.parse(list)
     self.failUnless(result is None)
Exemple #4
0
 def testGoodParse2(self):
     list = lex("print 42")
     result = PrintStatement.parse(list)
     self.failUnless(isinstance(result, PrintStatement))
 def testPrintAdd(self):
     s = lex("print 1 + 2")
     result = PrintStatement.parse(s)
     self.failUnless(isinstance(result, PrintStatement))