]> granicus.if.org Git - python/commitdiff
Add simple test of list comprehension that uses a name that isn't
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 23 Jan 2001 01:51:40 +0000 (01:51 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 23 Jan 2001 01:51:40 +0000 (01:51 +0000)
otherwise used in the same code block.  (Not sure this is the right
place, but there is no test_list_comprehensions.py.)

Lib/test/output/test_grammar
Lib/test/test_grammar.py

index 739d0c5fc1882b199672f9bae4deea763d52e705..8ca7c33e32fb360f6ef95007431ce9f90118d254 100644 (file)
@@ -55,6 +55,7 @@ classdef
 [3, 4, 5]
 [(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')]
 [(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')]
+[0, 0, 0]
 good: got a SyntaxError as expected
 good: got a SyntaxError as expected
 [('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')]
index b64fcdf8ca819754ce29835e8e5eb5a986e69da2..3e7318a036e97825c37898828e585ff3b52480be 100644 (file)
@@ -612,6 +612,12 @@ print [3 * x for x in nums]
 print [x for x in nums if x > 2]
 print [(i, s) for i in nums for s in strs]
 print [(i, s) for i in nums for s in [f for f in strs if "n" in f]]
+
+def test_in_func(l):
+    return [None < x < 3 for x in l if x > 2]
+
+print test_in_func(nums)
+
 try:
     eval("[i, s for i in nums for s in strs]")
     print "FAIL: should have raised a SyntaxError!"