File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
graalpython/com.oracle.graal.python.test/src/tests/cpyext Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,38 @@ def test_int(self):
109
109
tester = TestInt ()
110
110
assert int (tester ) == 42
111
111
112
+ def test_float_binops (self ):
113
+ TestFloatBinop = CPyExtType ("TestFloatBinop" ,
114
+ """
115
+ PyObject* test_float(PyObject* self) {
116
+ PyErr_SetString(PyExc_RuntimeError, "Should not call __float__");
117
+ return NULL;
118
+ }
119
+ PyObject* test_add(PyObject* a, PyObject* b) {
120
+ return PyLong_FromLong(42);
121
+ }
122
+ PyObject* test_sub(PyObject* a, PyObject* b) {
123
+ return PyLong_FromLong(4242);
124
+ }
125
+ PyObject* test_mul(PyObject* a, PyObject* b) {
126
+ return PyLong_FromLong(424242);
127
+ }
128
+ PyObject* test_pow(PyObject* a, PyObject* b, PyObject* c) {
129
+ return PyLong_FromLong(42424242);
130
+ }
131
+ """ ,
132
+ nb_float = "test_float" ,
133
+ nb_add = "test_add" ,
134
+ nb_subtract = "test_sub" ,
135
+ nb_multiply = "test_mul" ,
136
+ nb_power = "test_pow"
137
+ )
138
+ x = TestFloatBinop ()
139
+ assert 10.0 + x == 42
140
+ assert 10.0 - x == 4242
141
+ assert 10.0 * x == 424242
142
+ assert 10.0 ** x == 42424242
143
+
112
144
def test_index (self ):
113
145
TestIndex = CPyExtType ("TestIndex" ,
114
146
"""
You can’t perform that action at this time.
0 commit comments