local test = require('minunit').test local geom = require 'geometry' -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- geom.point tests -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test( 'create point object', function() local pt = geom.point(1, 5.5) assert(pt.x == 1) assert(pt.y == 5.5) local mt = getmetatable(pt) assert(mt.__index == geom.point) end ) test( 'point distances', function() local a = geom.point(1, 3) local b = geom.point(4, 7) assert(a:distance_to(b) == 5) assert(a:distance_to(a) == 0) end ) -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- geom.square tests -- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test( 'create square object', function() local s = geom.square(geom.point(0, 0), 1) assert(s.center.x == 0) assert(s.center.y == 0) assert(s.span == 1) assert(s.x.min == -0.5) assert(s.x.max == 0.5) assert(s.y.min == -0.5) assert(s.y.max == 0.5) end )