From 678b2296b98f2428465b4fe1d6699f3e3369cc01 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 28 Nov 2008 12:09:28 +0100 Subject: [PATCH] extended test cases --- tests/run/dict.pyx | 32 ++++++++++++++++++++++++++++++++ tests/run/listcomp.pyx | 12 ++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/tests/run/dict.pyx b/tests/run/dict.pyx index 360d77cc..05bea96a 100644 --- a/tests/run/dict.pyx +++ b/tests/run/dict.pyx @@ -15,6 +15,25 @@ __doc__ = u""" resting >>> print(constant()['answer']) 42 + + >>> print(dict_call()['parrot']) + resting + >>> print(dict_call()['answer']) + 42 + + >>> print(dict_call_dict()['parrot']) + resting + >>> print(dict_call_dict()['answer']) + 42 + + >>> print(dict_call_kwargs()['parrot1']) + resting + >>> print(dict_call_kwargs()['parrot2']) + resting + >>> print(dict_call_kwargs()['answer1']) + 42 + >>> print(dict_call_kwargs()['answer2']) + 42 """ def empty(): @@ -36,3 +55,16 @@ def keyvalues2(key1, value1, key2, value2): def constant(): d = {u"parrot":u"resting", u"answer":42} return d + +def dict_call(): + d = dict(parrot=u"resting", answer=42) + return d + +def dict_call_dict(): + d = dict(dict(parrot=u"resting", answer=42)) + return d + +def dict_call_kwargs(): + kwargs = dict(parrot1=u"resting", answer1=42) + d = dict(parrot2=u"resting", answer2=42, **kwargs) + return d diff --git a/tests/run/listcomp.pyx b/tests/run/listcomp.pyx index a63521fe..d7c0ae0b 100644 --- a/tests/run/listcomp.pyx +++ b/tests/run/listcomp.pyx @@ -3,14 +3,22 @@ u""" [0, 4, 8] >>> typed() [A, A, A] +>>> iterdict() +[1, 2, 3] """ def smoketest(): print [x*2 for x in range(5) if x % 2 == 0] cdef class A: - def __repr__(self): return "A" + def __repr__(self): return u"A" def typed(): cdef A obj - print [obj for obj in [A(), A(), A()]] \ No newline at end of file + print [obj for obj in [A(), A(), A()]] + +def iterdict(): + cdef dict d = dict(a=1,b=2,c=3) + l = [d[key] for key in d] + l.sort() + print l -- 2.26.2