Mercurial > pymonkey
diff test_pymonkey.py @ 86:16a3e99e9b77
JS-wrapped Python functions that have had their Python functions cleared by context.clear_object_private() now throw appropriate JS exceptions when called.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 09 Aug 2009 15:46:40 -0700 |
parents | 10205d88f6ff |
children | 345d4c0e3dd3 |
line wrap: on
line diff
--- a/test_pymonkey.py Sun Aug 09 15:37:29 2009 -0700 +++ b/test_pymonkey.py Sun Aug 09 15:46:40 2009 -0700 @@ -153,6 +153,25 @@ del obj self.assertEqual(ref(), None) + def testJsWrappedPythonFuncThrowsExcIfPrivateCleared(self): + def func(cx, this, args): + return True + + code = "func()" + cx = pymonkey.Runtime().new_context() + obj = cx.new_object() + cx.init_standard_classes(obj) + jsfunc = cx.new_function(func, func.__name__) + cx.define_property(obj, func.__name__, jsfunc) + cx.clear_object_private(jsfunc) + self.assertRaises(pymonkey.error, + cx.evaluate_script, + obj, code, '<string>', 1) + self.assertEqual( + self._tostring(cx, self.last_exception.message), + "Error: Wrapped Python function no longer exists" + ) + def testJsWrappedPythonFuncPassesContext(self): contexts = []