Commit 5c99f654 authored by Travis Hance's avatar Travis Hance

implement numerator and denominator for int and long

parent b0e3fbaa
# expected: fail
"""Unit tests for numbers.py."""
import math
......
......@@ -1076,6 +1076,10 @@ static Box* int0(Box*, void*) {
return boxInt(0);
}
static Box* int1(Box*, void*) {
return boxInt(1);
}
void setupInt() {
for (int i = 0; i < NUM_INTERNED_INTS; i++) {
interned_ints[i] = new BoxedInt(i);
......@@ -1128,6 +1132,8 @@ void setupInt() {
int_cls->giveAttr("real", new (pyston_getset_cls) BoxedGetsetDescriptor(intInt, NULL, NULL));
int_cls->giveAttr("imag", new (pyston_getset_cls) BoxedGetsetDescriptor(int0, NULL, NULL));
int_cls->giveAttr("conjugate", new BoxedFunction(boxRTFunction((void*)intInt, BOXED_INT, 1)));
int_cls->giveAttr("numerator", new (pyston_getset_cls) BoxedGetsetDescriptor(intInt, NULL, NULL));
int_cls->giveAttr("denominator", new (pyston_getset_cls) BoxedGetsetDescriptor(int1, NULL, NULL));
int_cls->freeze();
}
......
......@@ -1311,6 +1311,10 @@ static Box* long0(Box* b, void*) {
return boxLong(0);
}
static Box* long1(Box* b, void*) {
return boxLong(1);
}
void setupLong() {
mp_set_memory_functions(customised_allocation, customised_realloc, customised_free);
......@@ -1374,6 +1378,8 @@ void setupLong() {
long_cls->giveAttr("real", new (pyston_getset_cls) BoxedGetsetDescriptor(longLong, NULL, NULL));
long_cls->giveAttr("imag", new (pyston_getset_cls) BoxedGetsetDescriptor(long0, NULL, NULL));
long_cls->giveAttr("conjugate", new BoxedFunction(boxRTFunction((void*)longLong, UNKNOWN, 1)));
long_cls->giveAttr("numerator", new (pyston_getset_cls) BoxedGetsetDescriptor(longLong, NULL, NULL));
long_cls->giveAttr("denominator", new (pyston_getset_cls) BoxedGetsetDescriptor(long1, NULL, NULL));
long_cls->freeze();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment