summaryrefslogtreecommitdiff
path: root/tests/run
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2018-12-14 11:34:51 +0100
committerStefan Behnel <stefan_ml@behnel.de>2018-12-14 11:34:51 +0100
commit82190146c08d4e8076c323ac25a9f0ec9fc695b1 (patch)
tree9e47f9ec12080708eadc8954787a44550ebf3413 /tests/run
parent96578f803ab9037a129f64d4d55d56af7ee19c94 (diff)
parentc9682a3e9a018f9867116578c23afe74942a7142 (diff)
downloadcython-82190146c08d4e8076c323ac25a9f0ec9fc695b1.tar.gz
Merge branch '0.29.x'
Diffstat (limited to 'tests/run')
-rw-r--r--tests/run/for_in_iter.py31
-rw-r--r--tests/run/tuple_constants.pyx30
2 files changed, 59 insertions, 2 deletions
diff --git a/tests/run/for_in_iter.py b/tests/run/for_in_iter.py
index f41ed18d2..1b86de2a3 100644
--- a/tests/run/for_in_iter.py
+++ b/tests/run/for_in_iter.py
@@ -61,6 +61,37 @@ def for_in_literal_mult_list():
l.append(i)
return l
+
+def listcomp_over_multiplied_constant_tuple():
+ """
+ >>> listcomp_over_multiplied_constant_tuple()
+ [[], [1, 2, 3], [1, 2, 3, 1, 2, 3], [1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 2, 3, 1, 2, 3]]
+ """
+ return [
+ [i for i in (1, 2, 3) * 0],
+ [i for i in (1, 2, 3) * 1],
+ [i for i in (1, 2, 3) * 2],
+ [i for i in (1, 2, 3) * 3],
+ [i for i in (1, 2, 3) * 2],
+ ]
+
+
+@cython.test_assert_path_exists('//ReturnStatNode//ForInStatNode//TupleNode')
+@cython.test_fail_if_path_exists('//ReturnStatNode//ForInStatNode//ListNode')
+def listcomp_over_multiplied_constant_list():
+ """
+ >>> listcomp_over_multiplied_constant_list()
+ [[], [1, 2, 3], [1, 2, 3, 1, 2, 3], [1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 2, 3, 1, 2, 3]]
+ """
+ return [
+ [i for i in [1, 2, 3] * 0],
+ [i for i in [1, 2, 3] * 1],
+ [i for i in [1, 2, 3] * 2],
+ [i for i in [1, 2, 3] * 3],
+ [i for i in [1, 2, 3] * 2],
+ ]
+
+
class Iterable(object):
"""
>>> for_in_pyiter(Iterable(5))
diff --git a/tests/run/tuple_constants.pyx b/tests/run/tuple_constants.pyx
index 99829f8f1..ee9be342a 100644
--- a/tests/run/tuple_constants.pyx
+++ b/tests/run/tuple_constants.pyx
@@ -46,9 +46,9 @@ def return_folded_tuple():
def return_nested_tuple():
"""
>>> return_nested_tuple()
- (1, (2, 3), (3, (4, 5)))
+ (1, (2, 3), (3, (4, 5), (2, 3, 2, 3)))
"""
- return (1, (2, 3), (3, (4, 5)))
+ return (1, (2, 3), (3, (4, 5), (2, 3) * 2))
@cython.test_assert_path_exists("//TupleNode",
"//TupleNode[@is_literal = true]")
@@ -71,6 +71,32 @@ def return_constant_tuple2():
"""
return (1,2)
+
+def return_multiplied_constant_tuple(n):
+ """
+ >>> tuples = return_multiplied_constant_tuple(2)
+ >>> type(tuples) is tuple
+ True
+ >>> for t in tuples: print(t)
+ ()
+ (1, 2, 3)
+ (1, 2, 3, 1, 2, 3)
+ (1, 2, 3, 1, 2, 3, 1, 2, 3)
+ (1, 2, 3, 1, 2, 3)
+ (1, 2, 3, 1, 2, 3)
+ ((1, 2, 3, 1, 2, 3), (1, 2, 3), (1, 2, 3, 1, 2, 3))
+ """
+ return (
+ (1, 2, 3) * 0,
+ (1, 2, 3) * 1,
+ (1, 2, 3) * 2,
+ (1, 2, 3) * 3,
+ (1, 2, 3) * 2,
+ (1, 2, 3) * n,
+ ((1, 2, 3) * n, (1, 2, 3), (1, 2, 3) * n),
+ )
+
+
@cython.test_assert_path_exists("//TupleNode",
"//TupleNode[@is_literal = true]")
@cython.test_fail_if_path_exists("//TupleNode[@is_literal = false]")