From: <cg...@us...> - 2008-12-25 00:49:37
|
Revision: 5799 http://jython.svn.sourceforge.net/jython/?rev=5799&view=rev Author: cgroves Date: 2008-12-25 00:49:33 +0000 (Thu, 25 Dec 2008) Log Message: ----------- test_091 - moved to test_java_visibility.py test_092 - deleted; not testing anything test_093 - deleted; check of a jythonc hack test_094 - deleted; tested by test_import_jy test_100 - deleted; tested by test_userdict test_101 - deleted; tested by test_jser2 test_104 - moved to test_java_integration.py test_114 - deleted; testing importing Tkinter from someone's i:\ drive test_116 - moved to test_java_integration.py Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_java_visibility.py Added Paths: ----------- trunk/jython/tests/java/org/python/tests/Coercions.java Removed Paths: ------------- trunk/jython/bugtests/test091.py trunk/jython/bugtests/test091j.java trunk/jython/bugtests/test092.py trunk/jython/bugtests/test093.py trunk/jython/bugtests/test094.py trunk/jython/bugtests/test100.py trunk/jython/bugtests/test100j.java trunk/jython/bugtests/test101.py trunk/jython/bugtests/test104.py trunk/jython/bugtests/test114.py trunk/jython/bugtests/test116.py Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/Lib/test/test_java_integration.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -5,11 +5,13 @@ from test import test_support from java.awt import (Dimension, Component, Rectangle, Button, Color, - HeadlessException) + HeadlessException) from java.util import ArrayList, HashMap, Hashtable, StringTokenizer, Vector from java.io import FileOutputStream, FileWriter, OutputStreamWriter -from java.lang import Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte +from java.lang import (Boolean, Integer, Object, String, Runnable, + Thread, ThreadGroup, System, Runtime, Math, Byte) +from javax.swing.table import AbstractTableModel from javax.swing.tree import TreePath from java.math import BigDecimal @@ -150,22 +152,22 @@ v.indexOf(X()) class IOTest(unittest.TestCase): - def test_io_errors(self): "Check that IOException isn't mangled into an IOError" from java.io import UnsupportedEncodingException - self.assertRaises(UnsupportedEncodingException, OutputStreamWriter, - System.out, "garbage") - + self.assertRaises(UnsupportedEncodingException, OutputStreamWriter, System.out, "garbage") + self.assertRaises(IOError, OutputStreamWriter, System.out, "garbage") + def test_fileio_error(self): from java.io import FileInputStream, FileNotFoundException self.assertRaises(FileNotFoundException, FileInputStream, "garbage") - def test_unsupported(self): + def test_unsupported_tell(self): from org.python.core.util import FileUtil fp = FileUtil.wrap(System.out) self.assertRaises(IOError, fp.tell) + class VectorTest(unittest.TestCase): def test_looping(self): @@ -354,7 +356,34 @@ treePath = TreePath([1,2,3]) 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 TableModelTest(unittest.TestCase): + def test_column_classes(self): + class TableModel(AbstractTableModel): + columnNames = "First Name", "Last Name","Sport","# of Years","Vegetarian" + data = [("Mary", "Campione", "Snowboarding", 5, False)] + + def getColumnCount(self): + return len(self.columnNames) + + def getRowCount(self): + return len(self.data) + + def getColumnName(self, col): + return self.columnNames[col] + + def getValueAt(self, row, col): + return self.data[row][col] + + def getColumnClass(self, c): + return Object.getClass(self.getValueAt(0, c)) + + def isCellEditable(self, row, col): + return col >= 2 + model = TableModel() + for i, expectedClass in enumerate([String, String, String, Integer, Boolean]): + self.assertEquals(expectedClass, model.getColumnClass(i)) + class BigDecimalTest(unittest.TestCase): def test_coerced_bigdecimal(self): @@ -460,6 +489,7 @@ PyReservedNamesTest, ImportTest, ColorTest, + TableModelTest, TreePathTest, BigDecimalTest, MethodInvTest, Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/Lib/test/test_java_visibility.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -91,9 +91,18 @@ 'java.lang.Class bean methods should be visible on instances') self.assertEquals(3, len(HashMap.getInterfaces())) +class NumberCoercionTest(unittest.TestCase): + def test_int_coercion(self): + from org.python.tests import Coercions + c = Coercions() + self.assertEquals("5", c.takeInt(5)) + self.assertEquals("15", c.takeInteger(15)) + self.assertEquals("150", c.takeNumber(150)) + def test_main(): test_support.run_unittest(VisibilityTest, - JavaClassTest) + JavaClassTest, + NumberCoercionTest) if __name__ == "__main__": test_main() Deleted: trunk/jython/bugtests/test091.py =================================================================== --- trunk/jython/bugtests/test091.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test091.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,18 +0,0 @@ -""" -Coercion of Integer and Number. -""" - -import support - -support.compileJava("test091j.java") - -import test091j - -r = test091j.takeInt(12) -support.compare(r, "takeInt") - -r = test091j.takeInteger(12) -support.compare(r, "takeInteger") - -r = test091j.takeNumber(12) -support.compare(r, "takeNumber") Deleted: trunk/jython/bugtests/test091j.java =================================================================== --- trunk/jython/bugtests/test091j.java 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test091j.java 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,11 +0,0 @@ -public class test091j { - public static String takeInt(int num) { - return "takeInt"; - } - public static String takeInteger(Integer num) { - return "takeInteger"; - } - public static String takeNumber(Number num) { - return "takeNumber"; - } -} \ No newline at end of file Deleted: trunk/jython/bugtests/test092.py =================================================================== --- trunk/jython/bugtests/test092.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test092.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,64 +0,0 @@ -""" -Check reload a java package (not a java class) (properly shouldn't work). -""" - -import support - -j1file = """ -package test092m; -public class test092j1 { - final static String j1_Version = "j1 Version %s"; - public String getJ1Version() { - return j1_Version; - } -} -""" - -j2file = """ -package test092m; -public class test092j2 extends test092j1 { - final static String j2_Version = "j2 Version %s"; - public String getJ2Version() { - return j2_Version; - } -} -""" - -def mkj1(v): - f = open("classes/test092m/test092j1.java", "w") - f.write(j1file % v) - f.close() - support.compileJava("classes/test092m/test092j1.java") - -def mkj2(v): - f = open("classes/test092m/test092j2.java", "w") - f.write(j2file % v); - f.close(); - support.compileJava("classes/test092m/test092j2.java") - -import sys - -mkj1("1") -mkj2("2") - -import test092m - -foo = test092m.test092j2() - -support.compare(foo.j1Version, "j1 Version 1") -support.compare(foo.j2Version, "j2 Version 2") - -mkj1("3") -mkj2("4") - -# -# Removed. Reloading java packages is not supposed to work -# -#reload(test092m) -# -#foo = test092m.test092j2() -#support.compare(foo.j1Version, "j1 Version 3") -#support.compare(foo.j2Version, "j2 Version 4") - - - Deleted: trunk/jython/bugtests/test093.py =================================================================== --- trunk/jython/bugtests/test093.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test093.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,14 +0,0 @@ -""" -Check name of the pawt.swing package. -""" - -import support - -from pawt import swing - - -support.compare(swing, "java package") -support.compare(swing.__name__, "javax.swing") -support.compare(swing.__jpythonc_name__, "pawt.swing") -#support.compare(swing.__file__, r"Lib\\pawt\\swing.py") - Deleted: trunk/jython/bugtests/test094.py =================================================================== --- trunk/jython/bugtests/test094.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test094.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,13 +0,0 @@ -""" -Check simple __import__ call with 4 args. -""" - -import support - -mod = __import__("pawt", globals(), locals(), "swing") - -import pawt - -if pawt != mod: - raise support.TestError("__import__ returned wrong module") - Deleted: trunk/jython/bugtests/test100.py =================================================================== --- trunk/jython/bugtests/test100.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test100.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,14 +0,0 @@ -""" -Iterate over the "keys" sequence. -""" - -import support - -support.compileJava("test100j.java") - -import test100j - -r = test100j().iterate({'a':'1', 'b':'2', 3:'c'}) - -if len(r) != 6: - raise support.TestError("len should be 6, %d" % len(r)) Deleted: trunk/jython/bugtests/test100j.java =================================================================== --- trunk/jython/bugtests/test100j.java 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test100j.java 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,16 +0,0 @@ - -import java.util.*; -import org.python.core.*; - -public class test100j { - public Vector iterate(PyObject dict) { - Vector v = new Vector(); - PyObject keys = dict.invoke("keys"); - PyObject key; - for (int i = 0; (key = keys.__finditem__(i)) != null; i++) { - v.addElement(key); - v.addElement(dict.__getitem__(key)); - } - return v; - } -} Deleted: trunk/jython/bugtests/test101.py =================================================================== --- trunk/jython/bugtests/test101.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test101.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,41 +0,0 @@ -""" -Serialization test. -#unitcheck -""" - -import support - - -class Data: - data = "Hello World" - -class Test: - text = Data() - -class Factory: - def createTest(x): - return Test() - -factory = Factory() -foo = factory.createTest() - - -from java import io -import sys - -filename = "test101.out" - -fout = io.ObjectOutputStream(io.FileOutputStream(filename)) -fout.writeObject(foo) -fout.close() - -fin = io.ObjectInputStream(io.FileInputStream(filename)) -foo = fin.readObject() -fin.close() - - -support.compare(foo, "<(__main__|test101).Test instance") -support.compare(foo.text, "<(__main__|test101).Data instance") -support.compare(foo.text.data, "Hello World") - - Deleted: trunk/jython/bugtests/test104.py =================================================================== --- trunk/jython/bugtests/test104.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test104.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,38 +0,0 @@ -""" - -""" - -import support - - -import java -from pawt import swing, test - -class TableModel0(swing.table.AbstractTableModel): - columnNames = "First Name", "Last Name","Sport","# of Years","Vegetarian" - data = [("Mary", "Campione", "Snowboarding", 5, java.lang.Boolean(0))] - - def getColumnCount(self): - return len(self.columnNames) - - def getRowCount(self): - return len(self.data) - - def getColumnName(self, col): - return self.columnNames[col] - - def getValueAt(self, row, col): - return self.data[row][col] - - def getColumnClass(self, c): - return java.lang.Class.getClass(self.getValueAt(0, c)) - - def isCellEditable(self, row, col): - return col >= 2 - -model0 = TableModel0() -support.compare(model0.getColumnClass(0), "java.lang.String") -support.compare(model0.getColumnClass(1), "java.lang.String") -support.compare(model0.getColumnClass(2), "java.lang.String") -support.compare(model0.getColumnClass(3), "java.lang.Integer") -support.compare(model0.getColumnClass(4), "java.lang.Boolean") Deleted: trunk/jython/bugtests/test114.py =================================================================== --- trunk/jython/bugtests/test114.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test114.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,14 +0,0 @@ -""" -Check sane error when importing TKinter. -""" - -import support - - -import sys -sys.path.append(r"i:\Python-1.5.2\Lib\lib-tk") - -try: - from Tkinter import * -except ImportError, e: - support.compare(e, "_tkinter|Tkinter") Deleted: trunk/jython/bugtests/test116.py =================================================================== --- trunk/jython/bugtests/test116.py 2008-12-25 00:05:29 UTC (rev 5798) +++ trunk/jython/bugtests/test116.py 2008-12-25 00:49:33 UTC (rev 5799) @@ -1,23 +0,0 @@ -""" -Check that UEE also matches IOError. -""" - -import support - - -import java - -try: - x = java.io.OutputStreamWriter(java.lang.System.out, "garbage") -except java.io.UnsupportedEncodingException, e: - pass -else: - raise support.TestError("Should raise an exception") - - -try: - x = java.io.OutputStreamWriter(java.lang.System.out, "garbage") -except IOError, e: - pass -else: - raise support.TestError("Should raise an exception") Added: trunk/jython/tests/java/org/python/tests/Coercions.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Coercions.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/Coercions.java 2008-12-25 00:49:33 UTC (rev 5799) @@ -0,0 +1,16 @@ +package org.python.tests; + +public class Coercions { + + public String takeInt(int i) { + return "" + i; + } + + public String takeInteger(Integer i) { + return "" + i; + } + + public String takeNumber(Number n) { + return "" + n; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |