Cython has moved to github.
cython-devel
view tests/run/dict.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | 95312b19ee49 |
| children | 82d312a9f1fc |
line source
1 __doc__ = u"""
2 >>> empty()
3 {}
4 >>> keyvalue(1, 2)
5 {1: 2}
7 >>> keyvalues(1, 2, 3, 4)
8 {1: 2, 3: 4}
9 >>> keyvalues2(1, 2, 3, 4)
10 {1: 2, 3: 4}
12 >>> len(constant())
13 2
14 >>> print(constant()['parrot'])
15 resting
16 >>> print(constant()['answer'])
17 42
19 >>> print(dict_call()['parrot'])
20 resting
21 >>> print(dict_call()['answer'])
22 42
24 >>> print(dict_call_dict()['parrot'])
25 resting
26 >>> print(dict_call_dict()['answer'])
27 42
29 >>> print(dict_call_kwargs()['parrot1'])
30 resting
31 >>> print(dict_call_kwargs()['parrot2'])
32 resting
33 >>> print(dict_call_kwargs()['answer1'])
34 42
35 >>> print(dict_call_kwargs()['answer2'])
36 42
37 """
39 def empty():
40 d = {}
41 return d
43 def keyvalue(key, value):
44 d = {key:value}
45 return d
47 def keyvalues(key1, value1, key2, value2):
48 d = {key1:value1, key2:value2}
49 return d
51 def keyvalues2(key1, value1, key2, value2):
52 d = {key1:value1, key2:value2,}
53 return d
55 def constant():
56 d = {u"parrot":u"resting", u"answer":42}
57 return d
59 def dict_call():
60 d = dict(parrot=u"resting", answer=42)
61 return d
63 def dict_call_dict():
64 d = dict(dict(parrot=u"resting", answer=42))
65 return d
67 def dict_call_kwargs():
68 kwargs = dict(parrot1=u"resting", answer1=42)
69 d = dict(parrot2=u"resting", answer2=42, **kwargs)
70 return d
