Skip to content

Commit

Permalink
Add tests for Python 2 long type (closes #5298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malcolm Smith committed Dec 28, 2017
1 parent bb48b92 commit f1eba0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public boolean methodParamsZBCSIJFD(boolean x1, byte x2, char x3, short x4,
public float fieldF = 42;
public double fieldD = 42;

public Object fieldObject = 42;
public Object fieldObject = "42";

public Number fieldNumber = 42;
public Byte fieldByte = 42;
Expand All @@ -55,7 +55,7 @@ public boolean methodParamsZBCSIJFD(boolean x1, byte x2, char x3, short x4,
public float[] fieldFArray = {42};
public double[] fieldDArray = {42};

public Object[] fieldObjectArray = {42};
public Object[] fieldObjectArray = {"42"};

public Number[] fieldNumberArray = {42};
public Byte[] fieldByteArray = {42};
Expand Down Expand Up @@ -428,7 +428,7 @@ public void setKlassArray(Class[] fieldKlassArray) {
public static float fieldStaticF = 42;
public static double fieldStaticD = 42;

public static Object fieldStaticObject = 42;
public static Object fieldStaticObject = "42";

public static Number fieldStaticNumber = 42;
public static Byte fieldStaticByte = 42;
Expand All @@ -454,7 +454,7 @@ public void setKlassArray(Class[] fieldKlassArray) {
public static float[] fieldStaticFArray = {42};
public static double[] fieldStaticDArray = {42};

public static Object[] fieldStaticObjectArray = {42};
public static Object[] fieldStaticObjectArray = {"42"};

public static Number[] fieldStaticNumberArray = {42};
public static Byte[] fieldStaticByteArray = {42};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from math import isnan
from java import jarray, jboolean, jbyte, jchar, jclass, jdouble, jfloat, jint, jlong, jshort
import sys

from .test_utils import FilterWarningsCase

Expand Down Expand Up @@ -71,6 +72,8 @@ def verify_int(self, obj, name, bits, wrapper=None, allow_bool=False, allow_floa

self.verify_value(obj, name, min_val, wrapper=wrapper)
self.verify_value(obj, name, max_val, wrapper=wrapper)
if sys.version_info[0] < 3:
self.verify_value(obj, name, long(123), wrapper=wrapper) # noqa: F821

# Wrapper type and bounds checks are tested in test_signatures.
self.verify_value(obj, name, True, context=self.conv_error_unless(allow_bool))
Expand Down Expand Up @@ -106,6 +109,8 @@ def verify_float(self, obj, name, exponent_bits, wrapper=None, allow_bool=False,
for val in [123, # Floating-point types always accept an int.
min_val, max_val, float("inf"), float("-inf")]:
self.verify_value(obj, name, val, wrapper=wrapper)
if sys.version_info[0] < 3:
self.verify_value(obj, name, long(123), wrapper=wrapper) # noqa: F821

self.verify_value(obj, name, float("nan"), # NaN is unequal to everything including itself.
wrapper=wrapper,
Expand Down Expand Up @@ -241,7 +246,7 @@ def verify_value_2(self, obj, name, input, output, context, verify):

# If the original and test values are the same then the test is pointless.
original = getattr(obj, field)
with self.assertRaises(AssertionError, msg="{} is already {}".format(field, original)):
with self.assertRaises(Exception, msg="{} is already {}".format(field, original)):
verify(output, original)

with context:
Expand Down

0 comments on commit f1eba0d

Please sign in to comment.