moved 'nonlocal' generator test over to generator test module to make all nonlocal...
authorStefan Behnel <scoder@users.berlios.de>
Fri, 17 Dec 2010 00:23:45 +0000 (01:23 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 17 Dec 2010 00:23:45 +0000 (01:23 +0100)
tests/run/generators.pyx
tests/run/nonlocal_T490.pyx

index f2243afc994bf2cce9acacabcc047fe8dc809acd..13fc7a6c7091e9a05d9ac38c93f39a58e71dc39c 100644 (file)
@@ -187,3 +187,18 @@ class Foo(object):
     def simple(self, *args):
         for i in args:
             yield i
+
+def generator_nonlocal():
+    """
+    >>> g = generator_nonlocal()
+    >>> list(g(5))
+    [2, 3, 4, 5, 6]
+    """
+    def f(x):
+        def g(y):
+            nonlocal x
+            for i in range(y):
+                x += 1
+                yield x
+        return g
+    return f(1)
index eb7f6610c77d54fa75272882a8ea021c1b6afc87..0a5a80dfd2a054df12791fb9c8df84274e8f26d2 100644 (file)
@@ -139,21 +139,6 @@ def class_body(int x, y):
         z = x,y
     return c()
 
-def generator():
-    """
-    >>> g = generator()
-    >>> list(g(5))
-    [2, 3, 4, 5, 6]
-    """
-    def f(x):
-        def g(y):
-            nonlocal x
-            for i in range(y):
-                x += 1
-                yield x
-        return g
-    return f(1)
-
 def nested_nonlocals(x):
     """
     >>> g = nested_nonlocals(1)