Adapt unit test to Operator. Still have to includ fractions
This commit is contained in:
@@ -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)
|
||||
|
||||
|
@@ -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"""
|
||||
|
Reference in New Issue
Block a user