Mercurial > pymonkey
diff test_pymonkey.py @ 61:1506350991d4
JS Wrapped python functions are now only GC'd by python once they've first been GC'd by JS.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sat, 25 Jul 2009 16:14:03 -0700 |
parents | fb97bed55789 |
children | 2b5696b91b01 |
line wrap: on
line diff
--- a/test_pymonkey.py Sat Jul 25 16:10:21 2009 -0700 +++ b/test_pymonkey.py Sat Jul 25 16:14:03 2009 -0700 @@ -34,21 +34,28 @@ "pymonkey.undefined") def testJsWrappedPythonFuncIsNotGCd(self): - # TODO: Make this test pass. def define(cx, obj): def func(cx, this, args): return u'func was called' jsfunc = cx.new_function(func, func.__name__) cx.define_property(obj, func.__name__, jsfunc) return weakref.ref(func) - cx = pymonkey.Runtime().new_context() + rt = pymonkey.Runtime() + cx = rt.new_context() obj = cx.new_object() cx.init_standard_classes(obj) ref = define(cx, obj) + cx.gc() self.assertNotEqual(ref(), None) result = cx.evaluate_script(obj, 'func()', '<string>', 1) self.assertEqual(result, u'func was called') + # Now ensure that the wrapped function is GC'd when it's + # no longer reachable from JS space. + cx.define_property(obj, 'func', 0) + cx.gc() + self.assertEqual(ref(), None) + def testJsWrappedPythonFuncPassesContext(self): contexts = []