From: <cg...@us...> - 2009-01-11 22:26:43
|
Revision: 5920 http://jython.svn.sourceforge.net/jython/?rev=5920&view=rev Author: cgroves Date: 2009-01-11 22:26:38 +0000 (Sun, 11 Jan 2009) Log Message: ----------- test320 - Moved to test_traceback_jy test366,373 - Moved to test_java_integration test391 - Moved to test_java_visibility test395 - Tested by test_java_visibility test396 - Tested by test_java_subclasses Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_java_visibility.py trunk/jython/Lib/test/test_traceback_jy.py trunk/jython/src/org/python/compiler/ProxyMaker.java trunk/jython/src/org/python/core/PyLong.java Added Paths: ----------- trunk/jython/Lib/test/except_in_raising_code.py Removed Paths: ------------- trunk/jython/bugtests/classes/test395j1.java trunk/jython/bugtests/classes/test395j2.java trunk/jython/bugtests/classes/test396j.java trunk/jython/bugtests/test320.py trunk/jython/bugtests/test366.py trunk/jython/bugtests/test373.py trunk/jython/bugtests/test391.py trunk/jython/bugtests/test395.py trunk/jython/bugtests/test396.py Added: trunk/jython/Lib/test/except_in_raising_code.py =================================================================== --- trunk/jython/Lib/test/except_in_raising_code.py (rev 0) +++ trunk/jython/Lib/test/except_in_raising_code.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -0,0 +1,8 @@ +def test(): + print noname + +def foo(): + try: + test() + except ValueError: + raise RuntimeError("Accessing a undefined name should raise a NameError") Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -7,7 +7,7 @@ from test import test_support from java.lang import (ExceptionInInitializerError, String, Runnable, System, Runtime, Math, Byte) -from java.math import BigDecimal +from java.math import BigDecimal, BigInteger from java.io import (FileInputStream, FileNotFoundException, FileOutputStream, FileWriter, OutputStreamWriter, UnsupportedEncodingException) from java.util import ArrayList, Date, HashMap, Hashtable, StringTokenizer, Vector @@ -56,6 +56,11 @@ b = BeanImplementation() self.assertEquals("name", b.getName()) self.assertEquals("name", b.name) + # Tests for #610576 + class SubBean(BeanImplementation): + def __init__(bself): + self.assertEquals("name", bself.getName()) + SubBean() class SysIntegrationTest(unittest.TestCase): @@ -262,7 +267,7 @@ self.assertEquals(len(treePath.path), 3, "Object[] not passed correctly") self.assertEquals(TreePath(treePath.path).path, treePath.path, "Object[] not passed and returned correctly") -class BigDecimalTest(unittest.TestCase): +class BigNumberTest(unittest.TestCase): def test_coerced_bigdecimal(self): from javatests import BigDecimalTest x = BigDecimal("123.4321") @@ -271,6 +276,11 @@ self.assertEqual(type(x), type(y), "BigDecimal coerced") self.assertEqual(x, y, "coerced BigDecimal not equal to directly created version") + def test_biginteger_in_long(self): + '''Checks for #608628, that long can take a BigInteger in its constructor''' + ns = '10000000000' + self.assertEquals(ns, str(long(BigInteger(ns)))) + class JavaStringTest(unittest.TestCase): def test_string_not_iterable(self): x = String('test') @@ -338,7 +348,7 @@ ImportTest, ColorTest, TreePathTest, - BigDecimalTest, + BigNumberTest, JavaStringTest, JavaDelegationTest, SecurityManagerTest) Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -4,7 +4,7 @@ import sys from test import test_support from java.lang import Byte, Class -from java.util import HashMap, Observable, Observer +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 org.python.tests import VisibilityResults as Results @@ -142,6 +142,14 @@ """Bug #452947 - Class of innerclass inst <> innerclass""" self.assertEquals(id(Matryoshka.Outermost), id(Matryoshka.makeOutermost().__class__)) + def test_super_methods_merged(self): + '''Checks that all signatures on a class' methods are found, not just the first for a name + + Bug #628315''' + synchList = Collections.synchronizedList(ArrayList()) + synchList.add("a string") + self.assertEquals("a string", synchList.remove(0)) + class JavaClassTest(unittest.TestCase): def test_class_methods_visible(self): self.assertFalse(HashMap.isInterface(), Modified: trunk/jython/Lib/test/test_traceback_jy.py =================================================================== --- trunk/jython/Lib/test/test_traceback_jy.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/Lib/test/test_traceback_jy.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -50,8 +50,17 @@ # http://bugs.jython.org/issue437809 traceback.extract_stack() + def test_except_around_raising_call(self): + """[ #452526 ] traceback lineno is the except line""" + from test import except_in_raising_code + try: + except_in_raising_code.foo() + except NameError: + tb = sys.exc_info()[2] + self.assertEquals(6, tb.tb_next.tb_lineno) + else: + self.fail("Should've raised a NameError") - try: raise Exception('foo') except Exception: Deleted: trunk/jython/bugtests/classes/test395j1.java =================================================================== --- trunk/jython/bugtests/classes/test395j1.java 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/classes/test395j1.java 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,4 +0,0 @@ -public class test395j1 { - protected test395j1() { - } -} Deleted: trunk/jython/bugtests/classes/test395j2.java =================================================================== --- trunk/jython/bugtests/classes/test395j2.java 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/classes/test395j2.java 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,5 +0,0 @@ -public class test395j2 extends test395j1 { - private test395j2() { - super(); - } -} Deleted: trunk/jython/bugtests/classes/test396j.java =================================================================== --- trunk/jython/bugtests/classes/test396j.java 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/classes/test396j.java 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,8 +0,0 @@ -public abstract class test396j { - public test396j() { - abstractMethod(); - } - - public abstract void abstractMethod(); - -} Deleted: trunk/jython/bugtests/test320.py =================================================================== --- trunk/jython/bugtests/test320.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/test320.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,28 +0,0 @@ -""" -[ #452526 ] traceback lineno is the except line -""" - -import support -import sys, traceback - -def test(): - print noname - -def foo(): - try: - - - test() - - - except ValueError: - print "shouldn't happen." - -try: - foo() -except: - tb = sys.exc_info()[2] - #print tb.tb_lineno - #traceback.print_tb(tb) - assert tb.tb_next.tb_lineno == 15 - Deleted: trunk/jython/bugtests/test366.py =================================================================== --- trunk/jython/bugtests/test366.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/test366.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,17 +0,0 @@ -""" -[ 610576 ] Impl of abstract method not found -""" - -import support - -support.compileJava("test366i.java"); -support.compileJava("test366j.java"); - -import test366i, test366j - -class MyCls(test366j, test366i): - def __init__(self): - self.foo(); - -MyCls() - Deleted: trunk/jython/bugtests/test373.py =================================================================== --- trunk/jython/bugtests/test373.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/test373.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,14 +0,0 @@ -""" -Test for bug [608628] long(java.math.BigInteger) does not work. -""" - -import support - -# local name bugtests/test381.py -ns = '10000000000' -import java -ns2 = str(long(java.math.BigInteger(ns))) -assert ns == ns2, ns2 - - - Deleted: trunk/jython/bugtests/test391.py =================================================================== --- trunk/jython/bugtests/test391.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/test391.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,14 +0,0 @@ -''' -Checks that all methods on a class are found, not just the first interface that has a method of the same name. - -Reported in bug 628315. -''' -import support -import java - -synchList = java.util.Collections.synchronizedList(java.util.ArrayList()) -synchList.add("a string") - -if not synchList.remove(0) == 'a string': - raise support.TestError, "'a string' should've been returned by the call to remove. The object version of remove was probably called instead of the int version" - Deleted: trunk/jython/bugtests/test395.py =================================================================== --- trunk/jython/bugtests/test395.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/test395.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,20 +0,0 @@ -""" -Classes with greater a protected constructor can be subclassed and instantiated -Tests bug #649582 -""" - -import support - -support.compileJava("classes/test395j1.java") -support.compileJava("classes/test395j2.java") - -import test395j2 - -class Subclass(test395j2): - def __init__(self): - test395j2.__init__(self) - -try: - Subclass() -except AttributeError: - raise support.TestWarning('Unable to access protected superclass constructor') Deleted: trunk/jython/bugtests/test396.py =================================================================== --- trunk/jython/bugtests/test396.py 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/bugtests/test396.py 2009-01-11 22:26:38 UTC (rev 5920) @@ -1,19 +0,0 @@ -''' -Checks for bug 663592. Used to be that if an abstract Java class called an -abstract method implemented by a Python subclass in its constructor, an -AttributeError would be thrown. -''' -import support - -support.compileJava("classes/test396j.java") - -import test396j - -class Subclass(test396j): - def __init__(self): - test396j.__init__(self) - - def abstractMethod(self): - pass - -x = Subclass() Modified: trunk/jython/src/org/python/compiler/ProxyMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-01-11 22:26:38 UTC (rev 5920) @@ -703,9 +703,7 @@ addMethods(superclass, seenmethods); for (Class<?> iface : interfaces) { if (iface.isAssignableFrom(superclass)) { - Py.writeWarning("compiler", - "discarding redundant interface: "+ - iface.getName()); + Py.writeWarning("compiler", "discarding redundant interface: " + iface.getName()); continue; } classfile.addInterface(mapClass(iface)); Modified: trunk/jython/src/org/python/core/PyLong.java =================================================================== --- trunk/jython/src/org/python/core/PyLong.java 2009-01-11 14:49:43 UTC (rev 5919) +++ trunk/jython/src/org/python/core/PyLong.java 2009-01-11 22:26:38 UTC (rev 5920) @@ -18,7 +18,7 @@ public class PyLong extends PyObject { public static final PyType TYPE = PyType.fromClass(PyLong.class); - + public static final BigInteger minLong = BigInteger.valueOf(Long.MIN_VALUE); public static final BigInteger maxLong = BigInteger.valueOf(Long.MAX_VALUE); public static final BigInteger maxULong = @@ -35,6 +35,9 @@ ArgParser ap = new ArgParser("long", args, keywords, new String[] {"x", "base"}, 0); PyObject x = ap.getPyObject(0, null); + if (x != null && x.getJavaProxy() instanceof BigInteger) { + return new PyLong((BigInteger)x.getJavaProxy()); + } int base = ap.getInt(1, -909); if (x == null) { @@ -74,7 +77,7 @@ return new PyLongDerived(subtype, ((PyLong)tmp).value); } } - + public PyLong(PyType subType, BigInteger v) { super(subType); value = v; @@ -264,10 +267,10 @@ return adaptToCoerceTuple(long___coerce_ex__(other)); } - /** + /** * Coercion logic for long. Implemented as a final method to avoid - * invocation of virtual methods from the exposed coerce. - */ + * invocation of virtual methods from the exposed coerce. + */ final Object long___coerce_ex__(PyObject other) { if (other instanceof PyLong) return other; @@ -535,7 +538,7 @@ public PyObject __pow__(PyObject right, PyObject modulo) { return long___pow__(right, modulo); } - + @ExposedMethod(type = MethodType.BINARY, defaults = {"null"}, doc = BuiltinDocs.long___pow___doc) final PyObject long___pow__(PyObject right, PyObject modulo) { if (!canCoerce(right)) @@ -744,7 +747,7 @@ public PyObject __abs__() { return long___abs__(); } - + @ExposedMethod(doc = BuiltinDocs.long___abs___doc) final PyObject long___abs__() { return Py.newLong(value.abs()); @@ -830,7 +833,7 @@ public PyString __str__() { return Py.newString(value.toString()); } - + public PyUnicode __unicode__() { return new PyUnicode(value.toString()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |