From 0cb6983c79eeee684f33d25024724eb735e12b5f Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Fri, 12 Nov 2010 01:19:21 -0800 Subject: [PATCH] Inplace cdivision tests. (#591) --- tests/run/inplace.pyx | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/tests/run/inplace.pyx b/tests/run/inplace.pyx index 99acc351..5bdc256f 100644 --- a/tests/run/inplace.pyx +++ b/tests/run/inplace.pyx @@ -1,10 +1,10 @@ -__doc__ = u""" - >>> str(f(5, 7)) - '29509034655744' - -""" +cimport cython def f(a,b): + """ + >>> str(f(5, 7)) + '29509034655744' + """ a += b a *= b a **= b @@ -117,3 +117,33 @@ def test_side_effects(): b[side_effect(3)] += 10 b[c_side_effect(4)] += 100 return a, [b[i] for i from 0 <= i < 5] + +@cython.cdivision(True) +def test_inplace_cdivision(int a, int b): + """ + >>> test_inplace_cdivision(13, 10) + 3 + >>> test_inplace_cdivision(13, -10) + 3 + >>> test_inplace_cdivision(-13, 10) + -3 + >>> test_inplace_cdivision(-13, -10) + -3 + """ + a %= b + return a + +@cython.cdivision(False) +def test_inplace_pydivision(int a, int b): + """ + >>> test_inplace_pydivision(13, 10) + 3 + >>> test_inplace_pydivision(13, -10) + -7 + >>> test_inplace_pydivision(-13, 10) + 7 + >>> test_inplace_pydivision(-13, -10) + -3 + """ + a %= b + return a -- 2.26.2