Test for inplace fix.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 14 Nov 2010 07:57:49 +0000 (23:57 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 14 Nov 2010 07:57:49 +0000 (23:57 -0800)
tests/run/inplace.pyx

index a734913ca55d981aef6673168d94983dabb3a563..a5606f6a0738863f0b9db9d6b199fdedcb671d04 100644 (file)
@@ -244,3 +244,13 @@ def double_deref_and_increment(o, key1, key2):
     v __setitem__ a 11
     """
     o[side_effect(key1)][side_effect(key2)] += 1
+
+def conditional_inplace(value, a, condition, b):
+    """
+    >>> conditional_inplace([1, 2, 3], [100], True, [200])
+    [1, 2, 3, 100]
+    >>> conditional_inplace([1, 2, 3], [100], False, [200])
+    [1, 2, 3, 200]
+    """
+    value += a if condition else b
+    return value