Mercurial > pymonkey
diff tests/test_pymonkey.py @ 165:1f9a5982db9c
Added a context.set_throw_hook() method.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 30 Aug 2009 19:03:46 -0700 |
parents | d1606a6cf1c0 |
children | 2eaae00d5e30 |
line wrap: on
line diff
--- a/tests/test_pymonkey.py Sun Aug 30 17:07:38 2009 -0700 +++ b/tests/test_pymonkey.py Sun Aug 30 19:03:46 2009 -0700 @@ -232,6 +232,22 @@ '(function(){})', '<string>', 1) self.assertEqual(cx.get_object_private(jsfunc), None) + def testThrowHookWorks(self): + timesCalled = [0] + def throwhook(cx): + timesCalled[0] += 1 + + cx = pymonkey.Runtime().new_context() + cx.set_throw_hook(throwhook) + self.assertRaises( + pymonkey.error, + cx.evaluate_script, + cx.new_object(), + '(function() { throw "hi"; })()', + '<string>', 1 + ) + self.assertEqual(timesCalled[0], 2) + def testJsWrappedPythonFuncHasPrivate(self): def foo(cx, this, args): pass