[Jython-checkins] jython: Verify compaction of array.array occurs when converting to Object (#1745)

jim.baker jython-checkins at python.org
Wed Jan 6 17:23:21 EST 2016


https://hg.python.org/jython/rev/837c14575b65
changeset:   7852:837c14575b65
user:        Jim Baker <jim.baker at rackspace.com>
date:        Wed Jan 06 15:23:16 2016 -0700
summary:
  Verify compaction of array.array occurs when converting to Object (#1745)

files:
  tests/java/org/python/core/PyArrayTest.java |  13 ++++++++++
  1 files changed, 13 insertions(+), 0 deletions(-)


diff --git a/tests/java/org/python/core/PyArrayTest.java b/tests/java/org/python/core/PyArrayTest.java
--- a/tests/java/org/python/core/PyArrayTest.java
+++ b/tests/java/org/python/core/PyArrayTest.java
@@ -1,6 +1,7 @@
 package org.python.core;
 
 import junit.framework.TestCase;
+import org.python.util.PythonInterpreter;
 
 /**
  * Tests for PyArray.
@@ -50,4 +51,16 @@
         assertEquals(new PyArray(PyString.class, new String[] {"x", "b", "y", "d"}), arrayToModify);
 
     }
+
+    public void testCompactArray() {
+        // tests http://bugs.jython.org/issue1745
+        PythonInterpreter interp = new PythonInterpreter();
+        interp.set("arr", new double[3]);
+        interp.exec("arr.append(3.0)\n\n");
+        Object o = interp.get("arr", Object.class);
+        double[] a = (double[])o;
+        assertEquals(4, a.length);
+        assertEquals(0.0, a[0]);
+        assertEquals(3.0, a[3]);
+    }
 }

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list