def __test__():
    from testing import __ok__, __report__

    print 'Testing basic math...'

    __ok__(equal(1.0, 1.0), True)
    __ok__(equal(1.0, 1.01), False)
    __ok__(equal(1.0, 1.0001), False)
    __ok__(equal(1.0, 0.9999), False)
    __ok__(equal(1.0, 1.0000001), False)
    __ok__(equal(1.0, 0.9999999), False)
    __ok__(equal(1.0, 1.0000000001), True)
    __ok__(equal(1.0, 0.9999999999), True)

    __ok__(equal(degrees(0), 0.0))
    __ok__(equal(degrees(math.pi/2), 90.0))
    __ok__(equal(degrees(math.pi), 180.0))
    __ok__(equal(radians(0.0), 0.0))
    __ok__(equal(radians(90.0), math.pi/2))
    __ok__(equal(radians(180.0), math.pi))

    print 'Testing V vector class...'

    # structural construction
    __ok__(V.O is not None, True)
    __ok__(V.O._v is not None, True)
    __ok__(V.O._v, (0., 0., 0.)) ; __ok__(V.O._l, 0.)
    __ok__(V.X._v, (1., 0., 0.)) ; __ok__(V.X._l, 1.)
    __ok__(V.Y._v, (0., 1., 0.)) ; __ok__(V.Y._l, 1.)
    __ok__(V.Z._v, (0., 0., 1.)) ; __ok__(V.Z._l, 1.)
    a = V(3., 2., 1.) ; __ok__(a._v, [3., 2., 1.])
    a = V((1., 2., 3.)) ; __ok__(a._v, [1., 2., 3.])
    a = V([1., 1., 1.]) ; __ok__(a._v, [1., 1., 1.])
    a = V(0.) ; __ok__(a._v, [0.]) ; __ok__(a._l, 0.)
    a = V(3.) ; __ok__(a._v, [3.]) ; __ok__(a._l, 3.)

    # constants and direct comparisons
    __ok__(V.O, V(0.,0.,0.))
    __ok__(V.X, V(1.,0.,0.))
    __ok__(V.Y, V(0.,1.,0.))
    __ok__(V.Z, V(0.,0.,1.))

    # formatting and elements
    __ok__(repr(V.X), 'V(1.0, 0.0, 0.0)')
    __ok__(V.X[0], 1.)
    __ok__(V.X[1], 0.)
    __ok__(V.X[2], 0.)

    # simple addition
    __ok__(V.X + V.Y, V(1.,1.,0.))
    __ok__(V.Y + V.Z, V(0.,1.,1.))
    __ok__(V.X + V.Z, V(1.,0.,1.))

    # didn't overwrite our constants, did we?
    __ok__(V.X, V(1.,0.,0.))
    __ok__(V.Y, V(0.,1.,0.))
    __ok__(V.Z, V(0.,0.,1.))

    a = V(3.,2.,1.)
    b = a.normalize()
    __ok__(a != b)
    __ok__(a == V(3.,2.,1.))
    __ok__(b.magnitude(), 1)
    b = a.magnitude(5)
    __ok__(a == V(3.,2.,1.))
    __ok__(b.magnitude(), 5)
    __ok__(equal(b.dsquared(V.O), 25))

    a = V(3.,2.,1.).normalize()
    __ok__(equal(a[0], 0.80178372573727319))
    b = V(1.,3.,2.).normalize()
    __ok__(equal(b[2], 0.53452248382484879))
    d = a.dot(b)
    __ok__(equal(d, 0.785714285714), True)

    __ok__(V(2., 2., 1.) * 3, V(6, 6, 3))
    __ok__(3 * V(2., 2., 1.), V(6, 6, 3))
    __ok__(V(2., 2., 1.) / 2, V(1, 1, 0.5))

    v = V(1,2,3)
    w = V(4,5,6)
    __ok__(v.cross(w), V(-3,6,-3))
    __ok__(v.cross(w), v*w)
    __ok__(v*w, -(w*v))
    __ok__(v.dot(w), 32)
    __ok__(v.dot(w), w.dot(v))

    __ok__(zero(angle(V(1,1,1), V(2,2,2))), True)
    __ok__(equal(90.0, degrees(angle(V(1,0,0), V(0,1,0)))), True)
    __ok__(equal(180.0, degrees(angle(V(1,0,0), V(-1,0,0)))), True)

    __ok__(equal(  0.0, degrees(track(V( 1, 0)))), True)
    __ok__(equal( 90.0, degrees(track(V( 0, 1)))), True)
    __ok__(equal(180.0, degrees(track(V(-1, 0)))), True)
    __ok__(equal(270.0, degrees(track(V( 0,-1)))), True)

    __ok__(equal( 45.0, degrees(track(V( 1, 1)))), True)
    __ok__(equal(135.0, degrees(track(V(-1, 1)))), True)
    __ok__(equal(225.0, degrees(track(V(-1,-1)))), True)
    __ok__(equal(315.0, degrees(track(V( 1,-1)))), True)

    print 'Testing C complex number class...'

    __ok__(C(1,2) is not None, True)
    __ok__(C(1,2)[0], 1.0)
    __ok__(C(1+2j)[0], 1.0)
    __ok__(C((1,2))[1], 2.0)
    __ok__(C(V([1,2]))[1], 2.0)

    __ok__(C(3+2j) * C(1+4j), C(-5+14j))

    try:
        __ok__(C(1,2,3) is not None, True)
    except __HOLE__: # takes exactly 2 elements
        __ok__(True, True)

    try:
        __ok__(C([1,2,3]) is not None, True)
    except TypeError: # takes exactly 2 elements
        __ok__(True, True)

    except TypeError: # takes exactly 2 elements
        __ok__(True, True)

    print 'Testing Q quaternion class...'

    __ok__(Q(1,2,3,4) is not None, True)
    __ok__(Q(1,2,3,4)[1], 2.0)
    __ok__(Q((1,2,3,4))[2], 3.0)
    __ok__(Q(V(1,2,3,4))[3], 4.0)

    __ok__(Q(), Q(0,0,0,1))
    __ok__(Q(1,2,3,4).conjugate(), Q(-1,-2,-3,4))

    print 'Testing M matrix class...'

    m = M()
    __ok__(V(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), m)
    __ok__(m.row(0), V(1,0,0,0))
    __ok__(m.row(2), V(0,0,1,0))
    __ok__(m.col(1), V(0,1,0,0))
    __ok__(m.col(3), V(0,0,0,1))
    __ok__(m[5], 1.0)
    __ok__(m[1,1], 1.0)
    __ok__(m[6], 0.0)
    __ok__(m[1,2], 0.0)
    __ok__(m * V(1,2,3,4), V(1,2,3,4))
    __ok__(V(1,2,3,4) * m, V(1,2,3,4))
    mm = m * m
    __ok__(mm.__class__, M)
    __ok__(mm, M.I)
    mm = m * 2
    __ok__(mm.__class__, M)
    __ok__(mm, 2.0 * m)
    __ok__(mm[3,3], 2)
    __ok__(mm[3,2], 0)

    __ok__(M.rotate('X',radians(90)),
           M.twist(Q.rotate('X',radians(90))))
    __ok__(M.twist(Q(0,0,0,1)), M.I)
    __ok__(M.twist(Q(.5,0,0,1)),
           M.twist(Q(.5,0,0,1).normalize()))
    __ok__(V.O * M.translate(V(1,2,3)),
           V(1,2,3,1))
    __ok__((V.X+V.Y+V.Z) * M.translate(V(1,2,3)),
           V(2,3,4,1))

    # need some tests on m.determinant()

    m = M()
    m = m.translate(V(1,2,3))
    __ok__(m.inverse(), M().translate(-V(1,2,3)))
    m = m.rotate('Y', radians(30))
    __ok__(m * m.inverse(), M.I)

    __report__()
dataset/ETHPy150Open hhatto/autopep8/test/vectors_example.py/__test__