Commit d6deccbc authored by Marius Wachtler's avatar Marius Wachtler

Fix reversing of > and < compare operations

parent d7bc5a98
......@@ -166,11 +166,11 @@ std::string getInplaceOpName(int op_type) {
// Calling it "reverse" because that's what I'm assuming the 'r' stands for in ex __radd__
std::string getReverseOpName(int op_type) {
if (op_type == AST_TYPE::Lt)
return getOpName(AST_TYPE::GtE);
return getOpName(AST_TYPE::Gt);
if (op_type == AST_TYPE::LtE)
return getOpName(AST_TYPE::Gt);
if (op_type == AST_TYPE::Gt)
return getOpName(AST_TYPE::LtE);
return getOpName(AST_TYPE::Lt);
if (op_type == AST_TYPE::GtE)
return getOpName(AST_TYPE::Lt);
if (op_type == AST_TYPE::NotEq)
......
......@@ -74,3 +74,17 @@ print (1, 2) < (1, 3)
print (1, 4) < (1, 3)
print [1, 2] < [1, 3]
print {1:2} < {1:3}
class Reverse(object):
def __init__(self, n):
self.n = n
def __lt__(self, rhs):
print "lt"
return self.n < rhs.n
def __le__(self, rhs):
print "le"
return self.n <= rhs.n
print Reverse(4) > Reverse(3), Reverse(4) > Reverse(4)
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