Adapt unit test to Operator. Still have to includ fractions

This commit is contained in:
Lafrite
2014-11-02 11:12:47 +01:00
parent 6e99dadd39
commit 9b1ad5c14a
3 changed files with 16 additions and 11 deletions

View File

@@ -123,9 +123,7 @@ class Expression(object):
if len(steps[:-1]) > 0:
self.steps += [flatten_list(s) for s in steps[:-1]]
print("self.steps -> ", self.steps)
self.child = Expression(steps[-1])
print("self.child -> ", self.child)
## ---------------------
## String parsing
@@ -359,8 +357,7 @@ def test(exp):
print("\n")
if __name__ == '__main__':
#Expression.STR_RENDER = txt
Expression.STR_RENDER = lambda x: str(x)
Expression.STR_RENDER = txt
exp = "2 ^ 3 * 5"
test(exp)

View File

@@ -3,6 +3,7 @@
from .generic import Stack,flatten_list
from .fraction import Fraction
from .operator import Operator
__all__ = ['Render']
@@ -195,7 +196,7 @@ class Render(object):
:returns: boolean
"""
return (type(exp) == str and exp in self.operators)
return (type(exp) == Operator and str(exp) in self.operators)
class flist(list):
"""Fake list- they are used to stock the main operation of an rendered expression"""