Commit 277fd813 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #96 from undingen/fix_comp

Fix reversing of >, <, <= and >= compare operations
parents d7bc5a98 8e556fc1
......@@ -166,13 +166,13 @@ 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);
if (op_type == AST_TYPE::LtE)
return getOpName(AST_TYPE::Gt);
if (op_type == AST_TYPE::LtE)
return getOpName(AST_TYPE::GtE);
if (op_type == AST_TYPE::Gt)
return getOpName(AST_TYPE::LtE);
if (op_type == AST_TYPE::GtE)
return getOpName(AST_TYPE::Lt);
if (op_type == AST_TYPE::GtE)
return getOpName(AST_TYPE::LtE);
if (op_type == AST_TYPE::NotEq)
return getOpName(AST_TYPE::NotEq);
if (op_type == AST_TYPE::Eq)
......
......@@ -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