new test case for locals()
authorStefan Behnel <scoder@users.berlios.de>
Wed, 21 Oct 2009 18:47:08 +0000 (20:47 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 21 Oct 2009 18:47:08 +0000 (20:47 +0200)
tests/bugs.txt
tests/run/locals_expressions_T430.pyx [new file with mode: 0644]

index 7a0f2b197153f1f7bf68441d7e2394c84f26887b..dc8b81d016c6cd9285dedd30f6421045750a94d1 100644 (file)
@@ -9,3 +9,4 @@ bad_c_struct_T252
 missing_baseclass_in_predecl_T262
 extended_unpacking_T409
 locals_rebind_T429
+locals_expressions_T430
diff --git a/tests/run/locals_expressions_T430.pyx b/tests/run/locals_expressions_T430.pyx
new file mode 100644 (file)
index 0000000..9bb445b
--- /dev/null
@@ -0,0 +1,30 @@
+__doc__ = u"""
+>>> sorted( get_locals(1,2,3, k=5) .items())
+[('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)]
+
+>>> sorted(get_locals_items())
+[('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)]
+
+>>> sorted(get_locals_items_listcomp())
+[('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)]
+"""
+
+def get_locals(x, *args, **kwds):
+    cdef int z = 5
+    y = "hi"
+    return locals()
+
+def get_locals_items(x, *args, **kwds):
+    cdef int z = 5
+    y = "hi"
+    return locals().items()
+
+def get_locals_items_listcomp(x, *args, **kwds):
+    cdef int z = 5
+    y = "hi"
+    return [ item for item in locals().items() ]
+
+def sorted(it):
+    l = list(it)
+    l.sort()
+    return l