Feat: doctest for operation between Token and str

This commit is contained in:
Bertrand Benjamin 2019-10-13 22:18:44 +02:00
parent 6b353d2dd0
commit 510f6a1fa2

View File

@ -122,6 +122,10 @@ class Token(object):
... print(i) ... print(i)
3 + 7 3 + 7
10 10
>>> a = Integer(3)
>>> c = a + "x"
>>> c
<Linear x + 3>
>>> from .number import Fraction >>> from .number import Fraction
>>> a = Fraction("4/3") >>> a = Fraction("4/3")
>>> b = Integer(7) >>> b = Integer(7)
@ -156,6 +160,9 @@ class Token(object):
>>> c = a * 7 >>> c = a * 7
>>> c >>> c
<Integer 21> <Integer 21>
>>> c = a * "x"
>>> c
<Linear 3x>
>>> from .number import Fraction >>> from .number import Fraction
>>> a = Fraction("4/3") >>> a = Fraction("4/3")
>>> b = Integer(7) >>> b = Integer(7)
@ -227,6 +234,9 @@ class Token(object):
>>> c = 7 + a >>> c = 7 + a
>>> c >>> c
<Integer 10> <Integer 10>
>>> c = "x" + a
>>> c
<Linear x + 3>
""" """
return self._roperate(other, "+") return self._roperate(other, "+")
@ -239,6 +249,9 @@ class Token(object):
>>> c = 7 * a >>> c = 7 * a
>>> c >>> c
<Integer 21> <Integer 21>
>>> c = "x" * a
>>> c
<Linear 3x>
""" """
return self._roperate(other, "*") return self._roperate(other, "*")