Skip to content

Commit

Permalink
Fix bug so that None does not equal 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariechatfield committed Aug 26, 2013
1 parent 755721f commit 9e6523f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/long.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,11 @@ Sk.builtin.lng.prototype.longCompare = function(other)
}

Sk.builtin.lng.prototype.__eq__ = function(me, other) {
return me.longCompare(other) == 0;
return me.longCompare(other) == 0 && !(other instanceof Sk.builtin.none);
};

Sk.builtin.lng.prototype.__ne__ = function(me, other) {
return me.longCompare(other) != 0;
return me.longCompare(other) != 0 || (other instanceof Sk.builtin.none);
};

Sk.builtin.lng.prototype.__lt__ = function(me, other) {
Expand Down
4 changes: 2 additions & 2 deletions src/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@ Sk.builtin.nmber.prototype.numberCompare = function(other)
}

Sk.builtin.nmber.prototype.__eq__ = function(me, other) {
return me.numberCompare(other) == 0;
return (me.numberCompare(other) == 0) && !(other instanceof Sk.builtin.none);
};

Sk.builtin.nmber.prototype.__ne__ = function(me, other) {
return me.numberCompare(other) != 0;
return (me.numberCompare(other) != 0) || (other instanceof Sk.builtin.none);
};

Sk.builtin.nmber.prototype.__lt__ = function(me, other) {
Expand Down
14 changes: 14 additions & 0 deletions test/run/t511.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
print 0 == None
print 0.0 == None
print 0L == None
print None == 0
print None == 0.0
print None == 0L

print
print 0 != None
print 0.0 != None
print 0L != None
print None != 0
print None != 0.0
print None != 0L
13 changes: 13 additions & 0 deletions test/run/t511.py.real
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
False
False
False
False
False
False

True
True
True
True
True
True

0 comments on commit 9e6523f

Please sign in to comment.