Browse Source

finish physics module coverage

- love.physics.World:rayCastAny()
- love.physics.World:rayCastClosest()
- love.physics.World:getShapesInArea()
- love.physics.Body:getShapes()
- love.physics.Body:getShape()
- love.physics.Body:hasCustomMassData()
ell 1 year ago
parent
commit
7cc3816bec
2 changed files with 15 additions and 10 deletions
  1. 13 0
      testing/tests/physics.lua
  2. 2 10
      testing/todo.md

+ 13 - 0
testing/tests/physics.lua

@@ -19,6 +19,12 @@ love.test.physics.Body = function(test)
   love.physics.newRectangleShape(body2, 5, 5, 10, 10)
   love.physics.newRectangleShape(body2, 5, 5, 10, 10)
   test:assertObject(body1)
   test:assertObject(body1)
 
 
+  -- check shapes
+  test:assertEquals(1, #body1:getShapes(), 'check shapes total 1')
+  test:assertEquals(1, #body2:getShapes(), 'check shapes total 2')
+  test:assertNotEquals(nil, body1:getShape(), 'check shape 1')
+  test:assertNotEquals(nil, body2:getShape(), 'check shape 2')
+
   -- check body active
   -- check body active
   test:assertTrue(body1:isActive(), 'check active by def')
   test:assertTrue(body1:isActive(), 'check active by def')
 
 
@@ -135,6 +141,7 @@ love.test.physics.Body = function(test)
   test:assertRange(y5, 5, 6, 'check mass data reset y')
   test:assertRange(y5, 5, 6, 'check mass data reset y')
   test:assertRange(mass5, 0.1, 0.2, 'check mass data reset mass')
   test:assertRange(mass5, 0.1, 0.2, 'check mass data reset mass')
   test:assertRange(inertia5, 5, 6, 'check mass data reset inertia')
   test:assertRange(inertia5, 5, 6, 'check mass data reset inertia')
+  test:assertFalse(body1:hasCustomMassData())
 
 
   -- check position
   -- check position
   local x6, y6 = body1:getPosition()
   local x6, y6 = body1:getPosition()
@@ -515,6 +522,10 @@ love.test.physics.World = function(test)
   test:assertRange(world:getBodies()[1]:getY(), 9, 11, 'check body prop change y')
   test:assertRange(world:getBodies()[1]:getY(), 9, 11, 'check body prop change y')
   test:assertEquals(1, world:getBodyCount(), 'check 1 body count')
   test:assertEquals(1, world:getBodyCount(), 'check 1 body count')
 
 
+  -- check shapes in world
+  test:assertEquals(1, #world:getShapesInArea(0, 0, 10, 10), 'check shapes in area #1')
+  test:assertEquals(0, #world:getShapesInArea(20, 20, 30, 30), 'check shapes in area #1')
+
   -- check world status
   -- check world status
   test:assertFalse(world:isLocked(), 'check not updating')
   test:assertFalse(world:isLocked(), 'check not updating')
   test:assertFalse(world:isSleepingAllowed(), 'check no sleep (till brooklyn)')
   test:assertFalse(world:isSleepingAllowed(), 'check no sleep (till brooklyn)')
@@ -571,6 +582,8 @@ love.test.physics.World = function(test)
     return 1
     return 1
   end)
   end)
   test:assertEquals(3, shapes, 'check shapes in raycast')
   test:assertEquals(3, shapes, 'check shapes in raycast')
+  test:assertEquals(world:rayCastClosest(0, 0, 200, 200), rectangle1, 'check closest raycast')
+  test:assertNotEquals(nil, world:rayCastAny(0, 0, 200, 200), 'check any raycast')
 
 
   -- change collision logic
   -- change collision logic
   test:assertEquals(nil, world:getContactFilter(), 'check def filter')
   test:assertEquals(nil, world:getContactFilter(), 'check def filter')

+ 2 - 10
testing/todo.md

@@ -8,14 +8,6 @@ These are all the outstanding methods that require test coverage, along with a f
   try uncommenting love.filesystem.unmountCommonPath and you'll see the issues
   try uncommenting love.filesystem.unmountCommonPath and you'll see the issues
 - revisit love.audio.setPlaybackDevice when we update openal soft for MacOS
 - revisit love.audio.setPlaybackDevice when we update openal soft for MacOS
 
 
-## Physics
-- love.physics.World:rayCastAny
-- love.physics.World:rayCastClosest
-- love.physics.World:getShapesInArea
-- love.physics.Body:getShapes
-- love.physics.Body:getShape
-- love.physics.Body:hasCustomMassData
-
 ## Graphics
 ## Graphics
 - love.graphics.copyBuffer
 - love.graphics.copyBuffer
 - love.graphics.copyBufferToTexture
 - love.graphics.copyBufferToTexture
@@ -36,5 +28,5 @@ These are all the outstanding methods that require test coverage, along with a f
 - love.graphics.setOrthoProjection
 - love.graphics.setOrthoProjection
 - love.graphics.setPerspectiveProjection
 - love.graphics.setPerspectiveProjection
 - love.graphics.resetProjection
 - love.graphics.resetProjection
-- Mesh:getAttachedAttributes
-- Shader:hasStage
+- love.graphics.Mesh:getAttachedAttributes
+- love.graphics.Shader:hasStage