Skip to content

Commit 48ca607

Browse files
committed
Test hash for native float subtype
1 parent 8cf60ac commit 48ca607

File tree

1 file changed

+6
-5
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests/cpyext

1 file changed

+6
-5
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_object.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,13 @@ def test_float_subclass(self):
326326
TestFloatSubclass = CPyExtType("TestFloatSubclass",
327327
"""
328328
static PyTypeObject* testFloatSubclassPtr = NULL;
329-
329+
330330
static PyObject* new_fp(double val) {
331331
PyFloatObject* fp = PyObject_New(PyFloatObject, testFloatSubclassPtr);
332332
fp->ob_fval = val;
333333
return (PyObject*)fp;
334334
}
335-
335+
336336
static PyObject* fp_tpnew(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
337337
double dval = 0.0;
338338
Py_XINCREF(args);
@@ -341,7 +341,7 @@ def test_float_subclass(self):
341341
}}
342342
return new_fp(dval);
343343
}
344-
344+
345345
static PyObject* fp_add(PyObject* l, PyObject* r) {
346346
if (PyFloat_Check(l)) {
347347
if (PyFloat_Check(r)) {
@@ -360,15 +360,16 @@ def test_float_subclass(self):
360360
}
361361
""",
362362
cmembers="PyFloatObject base;",
363-
tp_base="&PyFloat_Type",
363+
tp_base="&PyFloat_Type",
364364
nb_add="fp_add",
365365
tp_new="fp_tpnew",
366366
post_ready_code="testFloatSubclassPtr = &TestFloatSubclassType; Py_INCREF(testFloatSubclassPtr);"
367367
)
368368
tester = TestFloatSubclass(41.0)
369369
res = tester + 1
370370
assert res == 42.0, "expected 42.0 but was %s" % res
371-
371+
assert hash(tester) != 0
372+
372373
def test_custom_basicsize(self):
373374
TestCustomBasicsize = CPyExtType("TestCustomBasicsize",
374375
'''

0 commit comments

Comments
 (0)