From: <cg...@us...> - 2009-06-29 02:23:58
|
Revision: 6500 http://jython.svn.sourceforge.net/jython/?rev=6500&view=rev Author: cgroves Date: 2009-06-29 02:23:57 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Adding a test for bug #1381 that doesn't actually cause the problem described Modified Paths: -------------- trunk/jython/Lib/test/test_java_visibility.py Added Paths: ----------- trunk/jython/tests/java/org/python/tests/DisagreeingInterfaceOverrides.java Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2009-06-23 07:50:56 UTC (rev 6499) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-06-29 02:23:57 UTC (rev 6500) @@ -3,10 +3,11 @@ import subprocess import sys from test import test_support -from java.lang import Byte, Class -from java.util import ArrayList, Collections, HashMap, Observable, Observer -from org.python.tests import (Coercions, HiddenSuper, InterfaceCombination, Invisible, Matryoshka, - OnlySubclassable, OtherSubVisible, SomePyMethods, SubVisible, Visible, VisibleOverride) +from java.lang import Byte, Class, Integer +from java.util import ArrayList, Collections, HashMap, LinkedList, Observable, Observer +from org.python.tests import (Coercions, DisagreeingInterfaceOverrides, HiddenSuper, + InterfaceCombination, Invisible, Matryoshka, OnlySubclassable, OtherSubVisible, + SomePyMethods, SubVisible, Visible, VisibleOverride) from org.python.tests import VisibilityResults as Results class VisibilityTest(unittest.TestCase): @@ -155,6 +156,16 @@ synchList.add("a string") self.assertEquals("a string", synchList.remove(0)) + def test_interface_methods_merged(self): + '''Checks that implementing interfaces that use the same method name are all reachable. + + Bug #1381''' + imp = DisagreeingInterfaceOverrides.Implementation() + self.assertEquals("String", imp.call("string argument")) + self.assertEquals("int", imp.call(Integer(7))) + self.assertEquals("List", imp.call(LinkedList())) + self.assertEquals("ArrayList", imp.call(ArrayList())) + class JavaClassTest(unittest.TestCase): def test_class_methods_visible(self): self.assertFalse(HashMap.isInterface(), Added: trunk/jython/tests/java/org/python/tests/DisagreeingInterfaceOverrides.java =================================================================== --- trunk/jython/tests/java/org/python/tests/DisagreeingInterfaceOverrides.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/DisagreeingInterfaceOverrides.java 2009-06-29 02:23:57 UTC (rev 6500) @@ -0,0 +1,51 @@ +package org.python.tests; + +import java.util.ArrayList; +import java.util.List; + +/** + * Part of a test for issue #1381. It checks that Jython finds the proper overridden method when + * dealing with several interfaces. The test itself is in + * Lib/test_java_visibility.py#test_interface_methods_merged + */ +public class DisagreeingInterfaceOverrides { + + public interface StringArg { + + String call(String arg); + } + + public interface IntArg { + + String call(int arg); + } + + public interface ListArg { + + String call(List<Object> arg); + } + + public interface ArrayListArg { + + String call(List<Object> arg); + } + + public static class Implementation implements StringArg, IntArg, ListArg, ArrayListArg { + + public String call(String arg) { + return "String"; + } + + public String call(int arg) { + return "int"; + } + + public String call(List<Object> arg) { + return "List"; + } + + public String call(ArrayList<Object> arg) { + return "ArrayList"; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |