Commits

Anonymous committed 7bac03b

Add another list comprehension test

Comments (0)

Files changed (1)

Lib/test/parrot/listcomps.py

 if a == [ 4, 5 ]: print('success: list comp. with if')
 else: print('failure: list comp. with if')
 
-print('test: nested list comp.')
+print('test: complex list comp.')
 a = [ (i,10+j) for i in range(3) if i > 0 for j in range(4) if j < 3 if j > 0 ]
 if a == [(1, 11), (1, 12), (2, 11), (2, 12)]:
+    print('success: complex list comp.')
+else:
+    print('failure: complex list comp.')
+
+print('test: nested list comp.')
+a = [ [ i + 2 for i in range(j) ] for j in range(3) ]
+if a == [ [], [2], [2,3] ]:
     print('success: nested list comp.')
 else:
     print('failure: nested list comp.')