From deaf0712aa46315e51700adf3b24366c338a5504 Mon Sep 17 00:00:00 2001 From: Mark Anthony Palomer Date: Mon, 6 Jun 2016 11:55:07 -0700 Subject: [PATCH] tests: Add testcase for OrderedDict equality. There's a need for .exp file because CPython renders OrderedDict's as: OrderedDict([('b', 2)]) while MicroPython as: OrderedDict({'b': 2}) --- tests/basics/ordereddict_eq.py | 44 ++++++++++++++++++++++++++++++ tests/basics/ordereddict_eq.py.exp | 15 ++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/basics/ordereddict_eq.py create mode 100644 tests/basics/ordereddict_eq.py.exp diff --git a/tests/basics/ordereddict_eq.py b/tests/basics/ordereddict_eq.py new file mode 100644 index 0000000000..2746608772 --- /dev/null +++ b/tests/basics/ordereddict_eq.py @@ -0,0 +1,44 @@ +try: + from collections import OrderedDict +except ImportError: + try: + from ucollections import OrderedDict + except ImportError: + print("SKIP") + import sys + sys.exit() + +x = OrderedDict() +y = OrderedDict() +x['a'] = 1 +x['b'] = 2 +y['a'] = 1 +y['b'] = 2 +print(x) +print(y) +print(x == y) + +z = OrderedDict() +z['b'] = 2 +z['a'] = 1 +print(y) +print(z) +print(y == z) + +del z['b'] +z['b'] = 2 +print(y) +print(z) +print(y == z) + +del x['a'] +del y['a'] +print(x) +print(y) +print(x == y) + +del z['b'] +del y['b'] +print(y) +print(z) +print(y == z) diff --git a/tests/basics/ordereddict_eq.py.exp b/tests/basics/ordereddict_eq.py.exp new file mode 100644 index 0000000000..892ba0e3bd --- /dev/null +++ b/tests/basics/ordereddict_eq.py.exp @@ -0,0 +1,15 @@ +OrderedDict({'a': 1, 'b': 2}) +OrderedDict({'a': 1, 'b': 2}) +True +OrderedDict({'a': 1, 'b': 2}) +OrderedDict({'b': 2, 'a': 1}) +False +OrderedDict({'a': 1, 'b': 2}) +OrderedDict({'a': 1, 'b': 2}) +True +OrderedDict({'b': 2}) +OrderedDict({'b': 2}) +True +OrderedDict({}) +OrderedDict({'a': 1}) +False