Feat: test num and denom for fraction

This commit is contained in:
Bertrand Benjamin 2020-12-15 15:02:39 +01:00
parent a1608a20d1
commit 95fd12c430

View File

@ -18,7 +18,7 @@ from ...core.MO import MO, MOnumber
from ...core.MO.fraction import MOFraction
from random import random
__all__ = ["Integer", "Decimal"]
__all__ = ["Integer", "Decimal", "Fraction"]
class Integer(Token):
@ -237,11 +237,25 @@ class Fraction(Token):
@property
def numerator(self):
return self._mo.numerator
""" Get numerator of the fraction
:example:
>>> a = Fraction("3/4")
>>> a.numerator
<Integer 3>
"""
return Integer(self._mo.numerator)
@property
def denominator(self):
return self._mo.denominator
""" Get denominator of the fraction
:example:
>>> a = Fraction("3/4")
>>> a.denominator
<Integer 4>
"""
return Integer(self._mo.denominator)
@property
def decimal(self):