t = require('luaunit') local phys = require('phys') function TestUpdate() local actor = { x = 0, y = 0, speed = 1, angle = math.pi } phys.update(actor, 0.1) t.assertAlmostEquals( actor, { x = -0.1, y = 0, speed = 1, angle = math.pi }) end function TestApply() local actor = { x = 0, y = 0, speed = 1, angle = math.pi } phys.apply(actor, { speed = 1, angle = 0 }) t.assertAlmostEquals( { x = actor.x, y = actor.y, speed = actor.speed }, { x = 0, y = 0, speed = 0 }) phys.apply(actor, { speed = 1, angle = math.pi }) t.assertAlmostEquals( actor, { x = 0, y = 0, speed = 1, angle = math.pi } ) phys.apply(actor, { speed = 1, angle = math.pi / 2 }) t.assertAlmostEquals( actor, { x = 0, y = 0, speed = math.sqrt(2), angle = math.pi * 3 / 4 } ) end os.exit(t.LuaUnit.run())