Commit a4515f93 authored by Boxiang Sun's avatar Boxiang Sun

adjust old style class test, add __index__ test

parent 8a87d9d5
...@@ -79,10 +79,6 @@ class E(): ...@@ -79,10 +79,6 @@ class E():
print "invert" print "invert"
return ~self.n return ~self.n
def __complex__(self):
print "complex"
return complex(self.n)
def __int__(self): def __int__(self):
print "int" print "int"
return int(self.n) return int(self.n)
...@@ -107,16 +103,9 @@ class E(): ...@@ -107,16 +103,9 @@ class E():
print "coerce" print "coerce"
return (int(self.n), other) return (int(self.n), other)
def __enter__(self): def __index__(self):
print 'enter' print "index"
return 'something' return self.n
def __exit__(self, type, value, traceback):
print 'exit'
return False
def __reversed__(self):
print "reversed"
e = E(1) e = E(1)
print e print e
...@@ -138,10 +127,8 @@ print float(e) ...@@ -138,10 +127,8 @@ print float(e)
print oct(e) print oct(e)
print hex(e) print hex(e)
print coerce(e, 10) print coerce(e, 10)
reversed(e) test_list = ["abc", "efg", "hij"]
print test_list[e]
with e as s:
print s
def str2(): def str2():
return "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