]> granicus.if.org Git - python/commitdiff
Revise tests to support str(<long int object>) not appending "L".
authorFred Drake <fdrake@acm.org>
Thu, 23 Dec 1999 15:36:42 +0000 (15:36 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 23 Dec 1999 15:36:42 +0000 (15:36 +0000)
Lib/test/test_b2.py
Lib/test/test_long.py
Lib/test/test_pow.py

index 3b322a590d31532d8e92c99935925824df762c89..1aff8374e1c5b2026ae3f407bb52e77cc547bf6b 100644 (file)
@@ -209,7 +209,7 @@ if sys.spam != 1: raise TestFailed, 'setattr(sys, \'spam\', 1)'
 print 'str'
 if str('') <> '': raise TestFailed, 'str(\'\')'
 if str(0) <> '0': raise TestFailed, 'str(0)'
-if str(0L) <> '0L': raise TestFailed, 'str(0L)'
+if str(0L) <> '0': raise TestFailed, 'str(0L)'
 if str(()) <> '()': raise TestFailed, 'str(())'
 if str([]) <> '[]': raise TestFailed, 'str([])'
 if str({}) <> '{}': raise TestFailed, 'str({})'
index f235d9c9d5a3f133e8df3e5a6b07761975ef0ed1..25abcc836584db34d0dd8b0c08692349b99c840a 100644 (file)
@@ -159,7 +159,7 @@ def test_bitop_identities(maxdigits=MAXDIGITS):
             test_bitop_identities_2(x, y)
             test_bitop_identities_3(x, y, getran((lenx + leny)/2))
 
-# ------------------------------------------------------ hex oct str atol
+# ------------------------------------------------- hex oct repr str atol
 
 def slow_format(x, base):
     if (x, base) == (0, 8):
@@ -181,12 +181,18 @@ def slow_format(x, base):
 
 def test_format_1(x):
     from string import atol
-    for base, mapper in (8, oct), (10, str), (16, hex):
+    for base, mapper in (8, oct), (10, repr), (16, hex):
         got = mapper(x)
         expected = slow_format(x, base)
         check(got == expected, mapper.__name__, "returned",
               got, "but expected", expected, "for", x)
         check(atol(got, 0) == x, 'atol("%s", 0) !=' % got, x)
+    # str() has to be checked a little differently since there's no
+    # trailing "L"
+    got = str(x)
+    expected = slow_format(x, 10)[:-1]
+    check(got == expected, mapper.__name__, "returned",
+          got, "but expected", expected, "for", x)
 
 def test_format(maxdigits=MAXDIGITS):
     print "long str/hex/oct/atol"
index ec17d53add664ee85ff312886c0d11f800d88d88..6e3dda7faed050bc5cde11ad7ef46445346eee77 100644 (file)
@@ -56,20 +56,20 @@ powtest(float)
 # Other tests-- not very systematic
 
 print 'The number in both columns should match.'
-print pow(3,3) % 8, pow(3,3,8)
-print pow(3,3) % -8, pow(3,3,-8)
-print pow(3,2) % -2, pow(3,2,-2)
-print pow(-3,3) % 8, pow(-3,3,8)
-print pow(-3,3) % -8, pow(-3,3,-8)
-print pow(5,2) % -8, pow(5,2,-8)
+print `pow(3,3) % 8`, `pow(3,3,8)`
+print `pow(3,3) % -8`, `pow(3,3,-8)`
+print `pow(3,2) % -2`, `pow(3,2,-2)`
+print `pow(-3,3) % 8`, `pow(-3,3,8)`
+print `pow(-3,3) % -8`, `pow(-3,3,-8)`
+print `pow(5,2) % -8`, `pow(5,2,-8)`
 print
 
-print pow(3L,3L) % 8, pow(3L,3L,8)
-print pow(3L,3L) % -8, pow(3L,3L,-8)
-print pow(3L,2) % -2, pow(3L,2,-2)
-print pow(-3L,3L) % 8, pow(-3L,3L,8)
-print pow(-3L,3L) % -8, pow(-3L,3L,-8)
-print pow(5L,2) % -8, pow(5L,2,-8)
+print `pow(3L,3L) % 8`, `pow(3L,3L,8)`
+print `pow(3L,3L) % -8`, `pow(3L,3L,-8)`
+print `pow(3L,2) % -2`, `pow(3L,2,-2)`
+print `pow(-3L,3L) % 8`, `pow(-3L,3L,8)`
+print `pow(-3L,3L) % -8`, `pow(-3L,3L,-8)`
+print `pow(5L,2) % -8`, `pow(5L,2,-8)`
 print
 
 print pow(3.0,3.0) % 8, pow(3.0,3.0,8)