Commit 2a800180 authored by Boxiang Sun's avatar Boxiang Sun

add test for new added function to oldstyle class

parent 5b9e5151
......@@ -63,6 +63,61 @@ class E():
print "ne"
return self.n != other.n
def __neg__(self):
print "neg"
return -self.n
def __pos__(self):
print "pos"
return +self.n
def __abs__(self):
print "abs"
return abs(self.n)
def __invert__(self):
print "invert"
return ~self.n
def __complex__(self):
print "complex"
return complex(self.n)
def __int__(self):
print "int"
return int(self.n)
def __long__(self):
print "long"
return long(self.n)
def __float__(self):
print "float"
return float(self.n)
def __oct__(self):
print "oct"
return oct(self.n)
def __hex__(self):
print "hex"
return hex(self.n)
def __coerce__(self, other):
print "coerce"
return (int(self.n), other)
def __enter__(self):
print 'enter'
return 'something'
def __exit__(self, type, value, traceback):
print 'exit'
return False
def __reversed__(self):
print "reversed"
e = E(1)
print e
print e.n
......@@ -73,6 +128,20 @@ print len(e)
print e()("test")
print e == E(1)
print e != E(1)
print -e
print +e
print abs(e)
print ~e
print int(e)
print long(e)
print float(e)
print oct(e)
print hex(e)
print coerce(e, 10)
reversed(e)
with e as s:
print s
def str2():
return "str2"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment