From 9b364b3fe82ec1e3caa5e6cf6a7aea967f135598 Mon Sep 17 00:00:00 2001 From: HyeockJinKim Date: Mon, 30 Sep 2019 18:05:46 +0900 Subject: [PATCH 1/2] __ne__ of dict return NotImplemented if type of other is not dict, return NotImplemented Fixes #108 --- py/dict.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/dict.go b/py/dict.go index 94974a00..25bdd3b2 100644 --- a/py/dict.go +++ b/py/dict.go @@ -169,6 +169,9 @@ func (a StringDict) M__ne__(other Object) (Object, error) { if err != nil { return nil, err } + if res == NotImplemented { + return res, nil + } if res == True { return False, nil } From fb48d32d24958e8024b3a182ccd5dc2bef358d35 Mon Sep 17 00:00:00 2001 From: HyeockJinKim Date: Mon, 30 Sep 2019 18:12:47 +0900 Subject: [PATCH 2/2] Add tests for dict.__ne__ and dict.__eq__ --- py/tests/dict.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/py/tests/dict.py b/py/tests/dict.py index 418792a4..c63e8a4a 100644 --- a/py/tests/dict.py +++ b/py/tests/dict.py @@ -33,4 +33,15 @@ assert a.__contains__('hello') assert not a.__contains__('world') +doc="__eq__, __ne__" +a = {'a': 'b'} +assert a.__eq__(3) != True +assert a.__ne__(3) != False +assert a.__ne__(3) != True +assert a.__ne__(3) != False + +assert a.__ne__({}) == True +assert a.__eq__({'a': 'b'}) == True +assert a.__ne__({'a': 'b'}) == False + doc="finished"