From 72cf1a6171060d24ced6e296bea23937d80b3629 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 27 May 2010 00:20:15 +0200 Subject: [PATCH] test for min/max builtins --- tests/run/builtin_min_max.pyx | 92 +++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tests/run/builtin_min_max.pyx diff --git a/tests/run/builtin_min_max.pyx b/tests/run/builtin_min_max.pyx new file mode 100644 index 00000000..b05b2d08 --- /dev/null +++ b/tests/run/builtin_min_max.pyx @@ -0,0 +1,92 @@ + +cimport cython + +# min() + +@cython.test_assert_path_exists("//IfStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode") +def min3(a,b,c): + """ + >>> min3(1,2,3) + 1 + >>> min3(2,3,1) + 1 + >>> min3(2,1,3) + 1 + >>> min3(3,1,2) + 1 + >>> min3(3,2,1) + 1 + """ + return min(a,b,c) + +@cython.test_assert_path_exists("//IfStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode") +def min3_typed(int a, int b, int c): + """ + >>> min3_typed(1,2,3) + 1 + >>> min3_typed(2,3,1) + 1 + >>> min3_typed(2,1,3) + 1 + >>> min3_typed(3,1,2) + 1 + >>> min3_typed(3,2,1) + 1 + """ + return min(a,b,c) + +@cython.test_assert_path_exists("//IfStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode") +def literal_min3(): + """ + >>> literal_min3() + (1, 1, 1, 1, 1) + """ + return min(1,2,3), min(2,1,3), min(2,3,1), min(3,1,2), min(3,2,1) + +# max() + +@cython.test_assert_path_exists("//IfStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode") +def max3(a,b,c): + """ + >>> max3(1,2,3) + 3 + >>> max3(2,3,1) + 3 + >>> max3(2,1,3) + 3 + >>> max3(3,1,2) + 3 + >>> max3(3,2,1) + 3 + """ + return max(a,b,c) + +@cython.test_assert_path_exists("//IfStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode") +def max3_typed(int a, int b, int c): + """ + >>> max3_typed(1,2,3) + 3 + >>> max3_typed(2,3,1) + 3 + >>> max3_typed(2,1,3) + 3 + >>> max3_typed(3,1,2) + 3 + >>> max3_typed(3,2,1) + 3 + """ + return max(a,b,c) + +@cython.test_assert_path_exists("//IfStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode") +def literal_max3(): + """ + >>> literal_max3() + (3, 3, 3, 3, 3) + """ + return max(1,2,3), max(2,1,3), max(2,3,1), max(3,1,2), max(3,2,1) -- 2.26.2