#!/usr/bin/env python
from coral import kernel as coral
DI = coral.lang.XMIDI20

M = coral.loadModel("floating_points.xmi")
assert M

edge = M.contained[0]
#
# This is due to Coral's behaviour of creating three Points
# instead of 1 BezierPoint
#
print "Points:"
s = 5
assert len(edge.waypoints) == s
for i in range(s):
    assert edge.waypoints[i].__type__() == DI.Point
    print edge.waypoints[i].x, edge.waypoints[i].y
    
assert edge.waypoints[0].x == 100.20
assert edge.waypoints[0].y == 20.345

#
# Python doesn't have this constants builtin?
#
bignum = 1.0e300000
posinf = bignum / 1
neginf = -bignum / 1
plainnan = bignum / bignum

assert float(edge.waypoints[1].x) == posinf
assert float(edge.waypoints[1].y) == plainnan

assert float(edge.waypoints[2].x) == plainnan
assert float(edge.waypoints[2].y) == neginf

assert float(edge.waypoints[3].x) == plainnan
assert float(edge.waypoints[3].y) == neginf


#
# Also test scientific notation
# 
assert edge.waypoints[4].x == 10020.0
assert edge.waypoints[4].y == 0.20345
