summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/objint_longlong.c2
-rw-r--r--py/objint_mpz.c2
-rw-r--r--py/objlist.c2
-rw-r--r--py/objset.c2
-rw-r--r--py/objtuple.c2
-rw-r--r--tests/basics/equal.py75
6 files changed, 75 insertions, 10 deletions
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index 24435415fb..7dc0573bc6 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -106,8 +106,6 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return MP_BOOL(lhs_val >= rhs_val);
case MP_BINARY_OP_EQUAL:
return MP_BOOL(lhs_val == rhs_val);
- case MP_BINARY_OP_NOT_EQUAL:
- return MP_BOOL(lhs_val != rhs_val);
default:
// op not supported
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 583ce4cb78..2d10ed471b 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -205,8 +205,6 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return MP_BOOL(cmp >= 0);
case MP_BINARY_OP_EQUAL:
return MP_BOOL(cmp == 0);
- case MP_BINARY_OP_NOT_EQUAL:
- return MP_BOOL(cmp != 0);
default:
return MP_OBJ_NULL;
diff --git a/py/objlist.c b/py/objlist.c
index a3b7e79abb..531e4b85bb 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -138,8 +138,6 @@ STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_MORE:
case MP_BINARY_OP_MORE_EQUAL:
return MP_BOOL(list_cmp_helper(op, lhs, rhs));
- case MP_BINARY_OP_NOT_EQUAL:
- return MP_BOOL(!list_cmp_helper(MP_BINARY_OP_EQUAL, lhs, rhs));
default:
// op not supported
diff --git a/py/objset.c b/py/objset.c
index 448f484d5a..05d064a047 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -411,8 +411,6 @@ STATIC mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
return set_issubset(lhs, rhs);
case MP_BINARY_OP_MORE_EQUAL:
return set_issuperset(lhs, rhs);
- case MP_BINARY_OP_NOT_EQUAL:
- return MP_BOOL(set_equal(lhs, rhs) == mp_const_false);
case MP_BINARY_OP_IN:
{
mp_obj_set_t *o = lhs;
diff --git a/py/objtuple.c b/py/objtuple.c
index 21313f7f9e..63866e80de 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -137,8 +137,6 @@ mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
case MP_BINARY_OP_MORE:
case MP_BINARY_OP_MORE_EQUAL:
return MP_BOOL(tuple_cmp_helper(op, lhs, rhs));
- case MP_BINARY_OP_NOT_EQUAL:
- return MP_BOOL(!tuple_cmp_helper(MP_BINARY_OP_EQUAL, lhs, rhs));
default:
// op not supported
diff --git a/tests/basics/equal.py b/tests/basics/equal.py
new file mode 100644
index 0000000000..665d7fd8cb
--- /dev/null
+++ b/tests/basics/equal.py
@@ -0,0 +1,75 @@
+# test equality
+
+print(None == None)
+
+print(False == None)
+print(False == False)
+print(False == True)
+
+print(() == ())
+print(() == [])
+print([] == [])
+print(() == {})
+print({} == ())
+
+print(() == None)
+print(() == False)
+print(() == print)
+
+print([] == None)
+print([] == False)
+print([] == print)
+
+print({} == None)
+print({} == False)
+print({} == print)
+
+print(1 == 1)
+print(1 == 2)
+print(1 == ())
+print(1 == [])
+print(1 == {})
+print(1 == 'a')
+
+print('a' == 'a')
+print('a' == 'ab')
+print('a' == 1)
+print('a' == ())
+
+# same as above but with !=
+
+print(None != None)
+
+print(False != None)
+print(False != False)
+print(False != True)
+
+print(() != ())
+print(() != [])
+print([] != [])
+print(() != {})
+print({} != ())
+
+print(() != None)
+print(() != False)
+print(() != print)
+
+print([] != None)
+print([] != False)
+print([] != print)
+
+print({} != None)
+print({} != False)
+print({} != print)
+
+print(1 != 1)
+print(1 != 2)
+print(1 != ())
+print(1 != [])
+print(1 != {})
+print(1 != 'a')
+
+print('a' != 'a')
+print('a' != 'ab')
+print('a' != 1)
+print('a' != ())