Browse Source

fixed small but crucial cmp test bug when repopulating the stack

Josh Wilson 18 years ago
parent
commit
91b0e85f17
1 changed files with 14 additions and 13 deletions
  1. 14 13
      direct/src/showbase/LazySort.py

+ 14 - 13
direct/src/showbase/LazySort.py

@@ -103,24 +103,25 @@ def itersorted(iterable, cmp = cmp, key = lambda x: x, reverse = False):
             yield val
             pass
 
-def test():
-    import random
-    from itertools import islice
-
-    control = sorted(data, key = lambda x: x[0])
-    variable = itersorted(data, key = lambda x: x[0])
-        
-    print control[:10] == [x for x in islice(variable,10)]
-    print data
-    print control
-
-    variable = itersorted(data, key = lambda x: x[0])
-    print [x for x in islice(variable,10)]
 if __debug__:
     def P(i):
         for x in reversed(i):
             print x
 
+    def test():
+        import random
+        from itertools import islice
+
+        control = sorted(data, key = lambda x: x[0])
+        variable = itersorted(data, key = lambda x: x[0])
+        
+        print control[:10] == [x for x in islice(variable,10)]
+        print data
+        print control
+
+        variable = itersorted(data, key = lambda x: x[0])
+        print [x for x in islice(variable,10)]
+
     from unittest import TestCase, main
     from random import shuffle
     from itertools import islice