Back to index

python3.2  3.2.2
Public Member Functions
py3_test_grammar.TokenTests Class Reference

List of all members.

Public Member Functions

def testBackslash
def testPlainIntegers
def testLongIntegers
def testFloats
def testStringLiterals
def testEllipsis

Detailed Description

Definition at line 17 of file py3_test_grammar.py.


Member Function Documentation

Definition at line 19 of file py3_test_grammar.py.

00019 
00020     def testBackslash(self):
00021         # Backslash means line continuation:
00022         x = 1 \
00023         + 1
00024         self.assertEquals(x, 2, 'backslash for line continuation')
00025 
00026         # Backslash does not means continuation in comments :\
00027         x = 0
00028         self.assertEquals(x, 0, 'backslash ending comment')

Definition at line 129 of file py3_test_grammar.py.

00129 
00130     def testEllipsis(self):
00131         x = ...
00132         self.assert_(x is Ellipsis)
00133         self.assertRaises(SyntaxError, eval, ".. .")

Here is the call graph for this function:

Definition at line 75 of file py3_test_grammar.py.

00075 
00076     def testFloats(self):
00077         x = 3.14
00078         x = 314.
00079         x = 0.314
00080         # XXX x = 000.314
00081         x = .314
00082         x = 3e14
00083         x = 3E14
00084         x = 3e-14
00085         x = 3e+14
00086         x = 3.e14
00087         x = .3e14
00088         x = 3.1e4

Definition at line 65 of file py3_test_grammar.py.

00065 
00066     def testLongIntegers(self):
00067         x = 0
00068         x = 0xffffffffffffffff
00069         x = 0Xffffffffffffffff
00070         x = 0o77777777777777777
00071         x = 0O77777777777777777
00072         x = 123456789012345678901234567890
00073         x = 0b100000000000000000000000000000000000000000000000000000000000000000000
00074         x = 0B111111111111111111111111111111111111111111111111111111111111111111111

Definition at line 29 of file py3_test_grammar.py.

00029 
00030     def testPlainIntegers(self):
00031         self.assertEquals(type(000), type(0))
00032         self.assertEquals(0xff, 255)
00033         self.assertEquals(0o377, 255)
00034         self.assertEquals(2147483647, 0o17777777777)
00035         self.assertEquals(0b1001, 9)
00036         # "0x" is not a valid literal
00037         self.assertRaises(SyntaxError, eval, "0x")
00038         from sys import maxsize
00039         if maxsize == 2147483647:
00040             self.assertEquals(-2147483647-1, -0o20000000000)
00041             # XXX -2147483648
00042             self.assert_(0o37777777777 > 0)
00043             self.assert_(0xffffffff > 0)
00044             self.assert_(0b1111111111111111111111111111111 > 0)
00045             for s in ('2147483648', '0o40000000000', '0x100000000',
00046                       '0b10000000000000000000000000000000'):
00047                 try:
00048                     x = eval(s)
00049                 except OverflowError:
00050                     self.fail("OverflowError on huge integer literal %r" % s)
00051         elif maxsize == 9223372036854775807:
00052             self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000)
00053             self.assert_(0o1777777777777777777777 > 0)
00054             self.assert_(0xffffffffffffffff > 0)
00055             self.assert_(0b11111111111111111111111111111111111111111111111111111111111111 > 0)
00056             for s in '9223372036854775808', '0o2000000000000000000000', \
00057                      '0x10000000000000000', \
00058                      '0b100000000000000000000000000000000000000000000000000000000000000':
00059                 try:
00060                     x = eval(s)
00061                 except OverflowError:
00062                     self.fail("OverflowError on huge integer literal %r" % s)
00063         else:
00064             self.fail('Weird maxsize value %r' % maxsize)

Here is the call graph for this function:

Definition at line 89 of file py3_test_grammar.py.

00089 
00090     def testStringLiterals(self):
00091         x = ''; y = ""; self.assert_(len(x) == 0 and x == y)
00092         x = '\''; y = "'"; self.assert_(len(x) == 1 and x == y and ord(x) == 39)
00093         x = '"'; y = "\""; self.assert_(len(x) == 1 and x == y and ord(x) == 34)
00094         x = "doesn't \"shrink\" does it"
00095         y = 'doesn\'t "shrink" does it'
00096         self.assert_(len(x) == 24 and x == y)
00097         x = "does \"shrink\" doesn't it"
00098         y = 'does "shrink" doesn\'t it'
00099         self.assert_(len(x) == 24 and x == y)
00100         x = """
00101 The "quick"
00102 brown fox
00103 jumps over
00104 the 'lazy' dog.
00105 """
00106         y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n'
00107         self.assertEquals(x, y)
00108         y = '''
00109 The "quick"
00110 brown fox
00111 jumps over
00112 the 'lazy' dog.
00113 '''
00114         self.assertEquals(x, y)
00115         y = "\n\
00116 The \"quick\"\n\
00117 brown fox\n\
00118 jumps over\n\
00119 the 'lazy' dog.\n\
00120 "
00121         self.assertEquals(x, y)
00122         y = '\n\
00123 The \"quick\"\n\
00124 brown fox\n\
00125 jumps over\n\
00126 the \'lazy\' dog.\n\
00127 '
00128         self.assertEquals(x, y)

Here is the call graph for this function:


The documentation for this class was generated from the following file: