File: test_long_jy.py

package info (click to toggle)
jython 2.7.2%2Brepack1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 62,676 kB
  • sloc: python: 640,908; java: 306,458; xml: 1,984; sh: 522; ansic: 126; makefile: 76
file content (40 lines) | stat: -rw-r--r-- 975 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Misc long tests

Made for Jython.
"""
from test import test_support
import unittest

class MyLong(long):
    pass


class LongTestCase(unittest.TestCase):

    def _test_long_repr(self, type2test):
        val = type2test(42)
        self.assertEqual(str(val), '42')
        self.assertEqual(repr(val), '42L')

    def test_long_repr(self):
        self._test_long_repr(long)

    def test_long_subclass_repr(self):
        self._test_long_repr(MyLong)

    def test_subclass_bool(self):
        # http://bugs.jython.org/issue1828
        self.assertTrue(bool(MyLong(42)))

    def test_long_pow(self):
        self.assertEquals(pow(10L, 10L, None), 10000000000L)
        self.assertEquals(long.__pow__(10L, 10L, None), 10000000000L)
        self.assertEquals((10L).__pow__(10L, None), 10000000000L)
        self.assertEquals((10L).__pow__(10, None), 10000000000L)


def test_main():
    test_support.run_unittest(LongTestCase)

if __name__ == '__main__':
    test_main()