Mercurial > pymonkey
changeset 123:08a012e96f62
Added another test and fixed a bug it revealed.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Wed, 19 Aug 2009 01:00:35 -0700 |
parents | 5eda03c8e756 |
children | 3613bc5dba3f |
files | src/utils.cpp tests/test_pymonkey.py |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/utils.cpp Wed Aug 19 00:47:46 2009 -0700 +++ b/src/utils.cpp Wed Aug 19 01:00:35 2009 -0700 @@ -233,6 +233,8 @@ jsval val; if (JS_GetPendingException(context->cx, &val)) { + JS_ClearPendingException(context->cx); + PyObject *pyStr = NULL; PyObject *tuple = NULL; PyObject *obj = PYM_jsvalToPyObject(context, val);
--- a/tests/test_pymonkey.py Wed Aug 19 00:47:46 2009 -0700 +++ b/tests/test_pymonkey.py Wed Aug 19 01:00:35 2009 -0700 @@ -451,6 +451,17 @@ self.last_exception.args[0]), 'ReferenceError: hai2u is not defined') + def testThrowingObjWithBadToStringWorks(self): + self.assertRaises( + pymonkey.error, + self._evaljs, + "throw {toString: function() { throw 'dujg' }}" + ) + self.assertEqual( + self.last_exception.args[1], + "<string conversion failed>" + ) + def testEvaluateTakesUnicodeCode(self): self.assertEqual(self._evaljs(u"'foo\u2026'"), u"foo\u2026")