diff options
author | Eric Smith <eric@trueblade.com> | 2008-03-17 17:32:20 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-03-17 17:32:20 (GMT) |
commit | 9ff19b54346d39d15cdcf75e9d66ab46ea6064d6 (patch) | |
tree | e4a83605262567c9c9abff7a7afa3edc1bd61681 /Lib/test/test_compile.py | |
parent | 7cfbf0c421137dfac5d9d2e4c879302ba5f80d88 (diff) | |
download | cpython-9ff19b54346d39d15cdcf75e9d66ab46ea6064d6.zip cpython-9ff19b54346d39d15cdcf75e9d66ab46ea6064d6.tar.gz cpython-9ff19b54346d39d15cdcf75e9d66ab46ea6064d6.tar.bz2 |
Finished backporting PEP 3127, Integer Literal Support and Syntax.
Added 0b and 0o literals to tokenizer.
Modified PyOS_strtoul to support 0b and 0o inputs.
Modified PyLong_FromString to support guessing 0b and 0o inputs.
Renamed test_hexoct.py to test_int_literal.py and added binary tests.
Added upper and lower case 0b, 0O, and 0X tests to test_int_literal.py
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r-- | Lib/test/test_compile.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 367a694..465a90c 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -180,7 +180,9 @@ if 1: def test_literals_with_leading_zeroes(self): for arg in ["077787", "0xj", "0x.", "0e", "090000000000000", - "080000000000000", "000000000000009", "000000000000008"]: + "080000000000000", "000000000000009", "000000000000008", + "0b42", "0BADCAFE", "0o123456789", "0b1.1", "0o4.2", + "0b101j2", "0o153j2", "0b100e1", "0o777e1"]: self.assertRaises(SyntaxError, eval, arg) self.assertEqual(eval("0777"), 511) @@ -208,6 +210,10 @@ if 1: self.assertEqual(eval("000000000000007"), 7) self.assertEqual(eval("000000000000008."), 8.) self.assertEqual(eval("000000000000009."), 9.) + self.assertEqual(eval("0b101010"), 42) + self.assertEqual(eval("-0b000000000010"), -2) + self.assertEqual(eval("0o777"), 511) + self.assertEqual(eval("-0o0000010"), -8) def test_unary_minus(self): # Verify treatment of unary minus on negative numbers SF bug #660455 |