diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2008-01-12 01:56:00 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2008-01-12 01:56:00 (GMT) |
commit | 59bc20bb273055e2cd48a467524d21340c1771cc (patch) | |
tree | 5c56af6a822827d080e136a8f9ee819ee589d4af /Lib/test/test_decimal.py | |
parent | bed4dd459ddebec5bf43ef8c658ed4a194b518cb (diff) | |
download | cpython-59bc20bb273055e2cd48a467524d21340c1771cc.zip cpython-59bc20bb273055e2cd48a467524d21340c1771cc.tar.gz cpython-59bc20bb273055e2cd48a467524d21340c1771cc.tar.bz2 |
Issue 1780: Allow leading and trailing whitespace in Decimal constructor,
when constructing from a string. Disallow trailing newlines in
Context.create_decimal.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 03cff60..2135637 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -429,6 +429,10 @@ class DecimalExplicitConstructionTest(unittest.TestCase): #just not a number self.assertEqual(str(Decimal('ugly')), 'NaN') + #leading and trailing whitespace permitted + self.assertEqual(str(Decimal('1.3E4 \n')), '1.3E+4') + self.assertEqual(str(Decimal(' -7.89')), '-7.89') + def test_explicit_from_tuples(self): #zero @@ -517,6 +521,10 @@ class DecimalExplicitConstructionTest(unittest.TestCase): self.assertEqual(str(d), '456789') d = nc.create_decimal('456789') self.assertEqual(str(d), '4.57E+5') + # leading and trailing whitespace should result in a NaN; + # spaces are already checked in Cowlishaw's test-suite, so + # here we just check that a trailing newline results in a NaN + self.assertEqual(str(nc.create_decimal('3.14\n')), 'NaN') # from tuples d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) |