From: <zy...@us...> - 2010-07-20 05:20:18
|
Revision: 7081 http://jython.svn.sourceforge.net/jython/?rev=7081&view=rev Author: zyasoft Date: 2010-07-20 05:20:12 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Added test to verify that single method interface support does not break java.lang.Object methods like toString. (This was actually fixed by Tobias in r6982.) Modified Paths: -------------- trunk/jython/Lib/test/test_func_jy.py trunk/jython/NEWS Modified: trunk/jython/Lib/test/test_func_jy.py =================================================================== --- trunk/jython/Lib/test/test_func_jy.py 2010-07-20 04:28:59 UTC (rev 7080) +++ trunk/jython/Lib/test/test_func_jy.py 2010-07-20 05:20:12 UTC (rev 7081) @@ -4,6 +4,7 @@ """ import types import unittest +from java.lang import Object from test import test_support xyz = 123 @@ -48,9 +49,25 @@ self.assertNotEqual(hash(foo.bar), hash(Foo().bar)) +class SingleMethodInterfaceTestCase(unittest.TestCase): + + def test_java_lang_object_methods(self): + # Passing a PyFunction to Object.toString, .hashCode, etc + # should not result in the function itself being called + + def return42(): + return 42 + s = Object.toString(return42) + self.assertNotEqual(s, 42) + self.assert_(s.startswith('<function return42')) + + + + def test_main(): test_support.run_unittest(FunctionTypeTestCase, - MethodHashCodeTestCase) + MethodHashCodeTestCase, + SingleMethodInterfaceTestCase) if __name__ == '__main__': test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-07-20 04:28:59 UTC (rev 7080) +++ trunk/jython/NEWS 2010-07-20 05:20:12 UTC (rev 7081) @@ -5,6 +5,7 @@ - [ 1373 ] Jython ClassLoader getResource does not work - [ 1506 ] Jython applies PEP263 pattern for determining source-code encoding on noncomments - [ 1630 ] threading.Thread lacks __tojava__ method + - [ 1558 ] PyFunction to single method interface wrapping does not handle java.lang.Object methods Jython 2.5.2b1 Bugs Fixed @@ -98,6 +99,8 @@ - Fix pickling of collections.defaultdict objects - Fix the cmath module to accept objects implementing the __float__ method - Add google indexer (by Yin Wang and Steve Yegge) + - Python functions can be directly passed to Java methods that + take a single method interface (such as Callable or Runnable) Jython 2.5.1rc3 Bugs Fixed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |