add some test for operators

This commit is contained in:
Lafrite
2015-04-03 14:49:55 +02:00
parent b0e506897a
commit 509fd6e409
2 changed files with 60 additions and 12 deletions

View File

@@ -3,6 +3,7 @@
from .generic import flatten_list, isNumber
from functools import wraps
import types
class Operator(str):
@@ -207,6 +208,7 @@ def operatorize(fun):
* "l_parenthesis": mechanism to add parenthesis for left operande
* "r_parenthesis": mechanism to add parenthesis for rigth operande
"""
@wraps(fun)
def mod_fun(self, *args):
ans = fun(self, *args)
@@ -271,17 +273,8 @@ class op(object):
def add(cls):
""" The operator +
>>> add = op.add
>>> add
'+'
>>> add(1, 2)
3
>>> add.__tex__('1','2')
'1 + 2'
>>> add.__txt__('1','2')
'1 + 2'
>>> add.__tex__('1','-2')
'1 - 2'
For doctest see test/test_operator.py
"""
def _render(self, link, *args):
@@ -337,7 +330,7 @@ class op(object):
>>> sub.__tex__('1','-2')
'1 - (-2)'
>>> sub.__tex__('-1','2')
'i-1 - 2'
'-1 - 2'
"""
def l_parenthesis(self, op, str_join=False):
return op