[Python-3000-checkins] r55491 - in python/branches/py3k-struni: Include/rangeobject.h Lib/test/test_range.py Lib/test/test_xrange.py Objects/rangeobject.c

walter.doerwald python-3000-checkins at python.org
Mon May 21 20:01:24 CEST 2007


Author: walter.doerwald
Date: Mon May 21 20:01:17 2007
New Revision: 55491

Added:
   python/branches/py3k-struni/Lib/test/test_range.py
      - copied, changed from r55490, python/branches/py3k-struni/Lib/test/test_xrange.py
Removed:
   python/branches/py3k-struni/Lib/test/test_xrange.py
Modified:
   python/branches/py3k-struni/Include/rangeobject.h
   python/branches/py3k-struni/Objects/rangeobject.c
Log:
Rename test_xrange.py to test_range.py and fix the
type name in various spots.


Modified: python/branches/py3k-struni/Include/rangeobject.h
==============================================================================
--- python/branches/py3k-struni/Include/rangeobject.h	(original)
+++ python/branches/py3k-struni/Include/rangeobject.h	Mon May 21 20:01:17 2007
@@ -7,9 +7,6 @@
 extern "C" {
 #endif
 
-/* This is about the type 'xrange', not the built-in function range(), which
-   returns regular lists. */
-
 /*
 A range object represents an integer range.  This is an immutable object;
 a range cannot change its value after creation.

Copied: python/branches/py3k-struni/Lib/test/test_range.py (from r55490, python/branches/py3k-struni/Lib/test/test_xrange.py)
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_xrange.py	(original)
+++ python/branches/py3k-struni/Lib/test/test_range.py	Mon May 21 20:01:17 2007
@@ -7,8 +7,8 @@
 warnings.filterwarnings("ignore", "integer argument expected",
                         DeprecationWarning, "unittest")
 
-class XrangeTest(unittest.TestCase):
-    def test_xrange(self):
+class RangeTest(unittest.TestCase):
+    def test_range(self):
         self.assertEqual(list(range(3)), [0, 1, 2])
         self.assertEqual(list(range(1, 5)), [1, 2, 3, 4])
         self.assertEqual(list(range(0)), [])

Deleted: /python/branches/py3k-struni/Lib/test/test_xrange.py
==============================================================================
--- /python/branches/py3k-struni/Lib/test/test_xrange.py	Mon May 21 20:01:17 2007
+++ (empty file)
@@ -1,68 +0,0 @@
-# Python test set -- built-in functions
-
-import test.test_support, unittest
-import sys
-
-import warnings
-warnings.filterwarnings("ignore", "integer argument expected",
-                        DeprecationWarning, "unittest")
-
-class XrangeTest(unittest.TestCase):
-    def test_xrange(self):
-        self.assertEqual(list(range(3)), [0, 1, 2])
-        self.assertEqual(list(range(1, 5)), [1, 2, 3, 4])
-        self.assertEqual(list(range(0)), [])
-        self.assertEqual(list(range(-3)), [])
-        self.assertEqual(list(range(1, 10, 3)), [1, 4, 7])
-        self.assertEqual(list(range(5, -5, -3)), [5, 2, -1, -4])
-
-        a = 10
-        b = 100
-        c = 50
-
-        self.assertEqual(list(range(a, a+2)), [a, a+1])
-        self.assertEqual(list(range(a+2, a, -1)), [a+2, a+1])
-        self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
-
-        seq = list(range(a, b, c))
-        self.assert_(a in seq)
-        self.assert_(b not in seq)
-        self.assertEqual(len(seq), 2)
-
-        seq = list(range(b, a, -c))
-        self.assert_(b in seq)
-        self.assert_(a not in seq)
-        self.assertEqual(len(seq), 2)
-
-        seq = list(range(-a, -b, -c))
-        self.assert_(-a in seq)
-        self.assert_(-b not in seq)
-        self.assertEqual(len(seq), 2)
-
-        self.assertRaises(TypeError, range)
-        self.assertRaises(TypeError, range, 1, 2, 3, 4)
-        self.assertRaises(ValueError, range, 1, 2, 0)
-
-        self.assertRaises(TypeError, range, 0.0, 2, 1)
-        self.assertRaises(TypeError, range, 1, 2.0, 1)
-        self.assertRaises(TypeError, range, 1, 2, 1.0)
-        self.assertRaises(TypeError, range, 1e100, 1e101, 1e101)
-
-        self.assertRaises(TypeError, range, 0, "spam")
-        self.assertRaises(TypeError, range, 0, 42, "spam")
-
-        self.assertEqual(len(range(0, sys.maxint, sys.maxint-1)), 2)
-
-        r = range(-sys.maxint, sys.maxint, 2)
-        self.assertEqual(len(r), sys.maxint)
-
-    def test_repr(self):
-        self.assertEqual(repr(range(1)), 'range(0, 1)')
-        self.assertEqual(repr(range(1, 2)), 'range(1, 2)')
-        self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)')
-
-def test_main():
-    test.test_support.run_unittest(XrangeTest)
-
-if __name__ == "__main__":
-    test_main()

Modified: python/branches/py3k-struni/Objects/rangeobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/rangeobject.c	(original)
+++ python/branches/py3k-struni/Objects/rangeobject.c	Mon May 21 20:01:17 2007
@@ -214,7 +214,7 @@
     if (i < 0 || i >= len) {
         if (!PyErr_Occurred())
             PyErr_SetString(PyExc_IndexError,
-                            "xrange object index out of range");
+                            "range object index out of range");
             return NULL;
         }
 
@@ -313,7 +313,7 @@
 	range_new,		/* tp_new */
 };
 
-/*********************** Xrange Iterator **************************/
+/*********************** range Iterator **************************/
 
 /* There are 2 types of iterators, one for C longs, the other for
    Python longs (ie, PyObjects).  This should make iteration fast


More information about the Python-3000-checkins mailing list