Lichen

tests/numbers.py

934:2989aab1b4f7
7 months ago Paul Boddie Renamed the utf8string class to unicode, eliminating the unicode function. This means that the simple case of merely returning an object if it is already a Unicode object no longer occurs when using the unicode callable, but such behaviour might be better supported with more general customised instantiation functionality.
     1 # -*- coding: ISO-8859-1 -*-     2      3 import sys     4      5 print "# sys.maxint:",     6 print sys.maxint     7 print "# sys.minint:",     8 print sys.minint     9     10 print "# sys.maxint + sys.minint:",    11 print sys.maxint + sys.minint    12     13 i = 2 ** 29    14 print i                                 # 536870912    15 print hex(i)                            # 0x20000000    16 print oct(i)                            # 04000000000    17     18 j = -2 ** 29    19 print j                                 # -536870912    20 print hex(j)                            # -0x20000000    21 print oct(j)                            # -05000000000    22     23 print i + j                             # 0    24     25 try:    26     print i - j    27 except OverflowError:    28     print "i - j: overflow occurred"    29     30 print i / i                             # 1    31 print i / j                             # -1    32 print j / j                             # 1    33 print j / i                             # -1    34     35 try:    36     print i * j    37 except OverflowError:    38     print "i * j: overflow occurred"    39     40 print i - i                             # 0    41 print j - j                             # 0    42 print ~j                                # 536870911    43 print i & ~j                            # 0    44 print i - 1 & ~j                        # 536870911    45     46 print hex(31)                           # 0x1f    47 print oct(31)                           # 037    48     49 print "# hash(sys.maxint):",    50 print hash(sys.maxint)    51     52 print "# hash((sys.maxint, 0)):",    53 print hash((sys.maxint, 0))    54     55 print "# hash((sys.maxint - 1, 0)):",    56 print hash((sys.maxint - 1, 0))    57     58 # Test combining numbers with strings.    59     60 s = "Number is " + str(123)    61 s2 = "??? -> " + str(123)    62 print s.__class__    63 print s2.__class__    64 print s    65 print s2    66     67 sys.stdout.encoding = "UTF-8"    68 print s2