Mercurial > pymonkey
comparison 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 |
comparison
equal
deleted
inserted
replaced
164:3fadba042201 | 165:1f9a5982db9c |
---|---|
230 cx = pymonkey.Runtime().new_context() | 230 cx = pymonkey.Runtime().new_context() |
231 jsfunc = cx.evaluate_script(cx.new_object(), | 231 jsfunc = cx.evaluate_script(cx.new_object(), |
232 '(function(){})', '<string>', 1) | 232 '(function(){})', '<string>', 1) |
233 self.assertEqual(cx.get_object_private(jsfunc), None) | 233 self.assertEqual(cx.get_object_private(jsfunc), None) |
234 | 234 |
235 def testThrowHookWorks(self): | |
236 timesCalled = [0] | |
237 def throwhook(cx): | |
238 timesCalled[0] += 1 | |
239 | |
240 cx = pymonkey.Runtime().new_context() | |
241 cx.set_throw_hook(throwhook) | |
242 self.assertRaises( | |
243 pymonkey.error, | |
244 cx.evaluate_script, | |
245 cx.new_object(), | |
246 '(function() { throw "hi"; })()', | |
247 '<string>', 1 | |
248 ) | |
249 self.assertEqual(timesCalled[0], 2) | |
250 | |
235 def testJsWrappedPythonFuncHasPrivate(self): | 251 def testJsWrappedPythonFuncHasPrivate(self): |
236 def foo(cx, this, args): | 252 def foo(cx, this, args): |
237 pass | 253 pass |
238 | 254 |
239 cx = pymonkey.Runtime().new_context() | 255 cx = pymonkey.Runtime().new_context() |