Esempio n. 1
0
    def testStack(self):
        interp = interpreter.defaultInterpreter()
        env = interpreter.defaultEnvironment()

        errors = []

        def handle(interp):
            framenames = [x.name for x in interp.frames]
            errors.append(O.simplify(framenames))
            raise

        #First, let's muck up the stack:
        E.set(env, '*exc-handler*', None)
        self.assertRaises(ZeroDivisionError,
                          interp.evalString,
                          '''
                          (defun (ham) (eggs))
                          (defun (eggs) (/ 1 0))
                          (ham)
                          ''',
                          env)

        # Now, let's see if it was cleaned properly (and that our
        # handler can work):
        E.set(env, '*exc-handler*', handle)

        self.assertRaises(ZeroDivisionError,
                          interp.evalString,
                          '''
                          (defun (foo) (bar))
                          (defun (bar) (/ 1 0))
                          (foo)
                          ''',
                          env)
        self.assertEquals(errors, [['foo', 'bar']])