Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: json-decoder-maps
Changeset: r97571:22fe436a1585
Date: 2019-09-20 16:40 +0200
http://bitbucket.org/pypy/pypy/changeset/22fe436a1585/

Log:    a test that devolving doesn't change the order

diff --git a/pypy/objspace/std/test/test_jsondict.py 
b/pypy/objspace/std/test/test_jsondict.py
--- a/pypy/objspace/std/test/test_jsondict.py
+++ b/pypy/objspace/std/test/test_jsondict.py
@@ -71,7 +71,6 @@
             assert d == {u"a": 1}
 
     def test_keys_value_items(self):
-        import __pypy__
         import _pypyjson
 
         d = _pypyjson.loads('{"a": 1, "b": "x"}')
@@ -80,10 +79,19 @@
         assert d.items() == [(u"a", 1), (u"b", u"x")]
 
     def test_iter_keys_value_items(self):
-        import __pypy__
         import _pypyjson
 
         d = _pypyjson.loads('{"a": 1, "b": "x"}')
         assert list(d.iterkeys()) == [u"a", u"b"]
         assert list(d.itervalues()) == [1, u"x"]
         assert list(d.iteritems()) == [(u"a", 1), (u"b", u"x")]
+
+    def test_dict_order_retained_when_switching_strategies(self):
+        import _pypyjson
+        import __pypy__
+        d = _pypyjson.loads('{"a": 1, "b": "x"}')
+        assert list(d) == [u"a", u"b"]
+        # devolve
+        assert not 1 in d
+        assert __pypy__.strategy(d) == "UnicodeDictStrategy"
+        assert list(d) == [u"a", u"b"]
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to