11
return {"foo", "bar", "baz"}
18
@cython.test_fail_if_path_exists("//SimpleCallNode")
26
>>> sorted(generator())
28
>>> sorted(returns_set())
30
>>> sorted(returns_tuple())
33
Traceback (most recent call last):
34
TypeError: 'object' object is not iterable
39
@cython.test_assert_path_exists("//GeneralCallNode")
40
def sorted_arg_with_key(x):
43
>>> sorted_arg_with_key(a)
47
>>> sorted_arg_with_key(generator())
49
>>> sorted_arg_with_key(returns_tuple())
51
>>> sorted_arg_with_key(object())
52
Traceback (most recent call last):
53
TypeError: 'object' object is not iterable
55
return sorted(x, key=lambda x: -x)
58
@cython.test_fail_if_path_exists("//YieldExprNode",
60
@cython.test_assert_path_exists("//InlinedGeneratorExpressionNode")
64
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
66
return sorted(i*i for i in range(10,0,-1))
69
@cython.test_fail_if_path_exists("//SimpleCallNode//SimpleCallNode")
70
@cython.test_assert_path_exists("//SimpleCallNode/NameNode[@name = 'range']")
71
def sorted_list_of_range():
73
>>> sorted_list_of_range()
74
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
76
return sorted(list(range(10,0,-1)))
79
@cython.test_fail_if_path_exists("//SimpleCallNode")
80
def sorted_list_literal():
82
>>> sorted_list_literal()
85
return sorted([3, 1, 2] * 2)
88
@cython.test_fail_if_path_exists("//SimpleCallNode")
89
def sorted_tuple_literal():
91
>>> sorted_tuple_literal()
94
return sorted((1, 3, 2) * 2)