def test():
    '''\
    Test function for rat module.

    The expected output is (module some differences in floating
    precission):
    -1
    -1
    0 0L 0.1 (0.1+0j)
    [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)]
    [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)]
    0
    (11/10)
    (11/10)
    1.1
    OK
    2 1.5 (3/2) (1.5+1.5j) (15707963/5000000)
    2 2 2.0 (2+0j)

    4 0 4 1 4 0
    3.5 0.5 3.0 1.33333333333 2.82842712475 1
    (7/2) (1/2) 3 (4/3) 2.82842712475 1
    (3.5+1.5j) (0.5-1.5j) (3+3j) (0.666666666667-0.666666666667j) (1.43248815986+2.43884761145j) 1
    1.5 1 1.5 (1.5+0j)

    3.5 -0.5 3.0 0.75 2.25 -1
    3.0 0.0 2.25 1.0 1.83711730709 0
    3.0 0.0 2.25 1.0 1.83711730709 1
    (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1
    (3/2) 1 1.5 (1.5+0j)

    (7/2) (-1/2) 3 (3/4) (9/4) -1
    3.0 0.0 2.25 1.0 1.83711730709 -1
    3 0 (9/4) 1 1.83711730709 0
    (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1
    (1.5+1.5j) (1.5+1.5j)

    (3.5+1.5j) (-0.5+1.5j) (3+3j) (0.75+0.75j) 4.5j -1
    (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1
    (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1
    (3+3j) 0j 4.5j (1+0j) (-0.638110484918+0.705394566962j) 0
    '''
    print rat(-1L, 1)
    print rat(1, -1)
    a = rat(1, 10)
    print int(a), long(a), float(a), complex(a)
    b = rat(2, 5)
    l = [a+b, a-b, a*b, a/b]
    print l
    l.sort()
    print l
    print rat(0, 1)
    print a+1
    print a+1L
    print a+1.0
    try:
        print rat(1, 0)
        raise SystemError, 'should have been ZeroDivisionError'
    except ZeroDivisionError:
        print 'OK'
    print rat(2), rat(1.5), rat(3, 2), rat(1.5+1.5j), rat(31415926,10000000)
    list = [2, 1.5, rat(3,2), 1.5+1.5j]
    for i in list:
        print i,
        if not isinstance(i, complex):
            print int(i), float(i),
        print complex(i)
        print
        for j in list:
            print i + j, i - j, i * j, i / j, i ** j,
            if not (isinstance(i, complex) or
                    isinstance(j, complex)):
                print cmp(i, j)
            print
dataset/ETHPy150Open robmoggach/python-moshion/moshion/extractframes/Rat.py/test/original