Files
love/testing/tests/event.lua
T
ell e03b2db08b 0.2
- Added tests for all obj creation, transformation, window + system info graphics methods
- Added half the state methods for graphics + added placeholders for missing drawing methods
- Added TestMethod:assertNotNil() for quick nil checking
- Added time total to the end of each module summary in console log to match file output

- Removed a bunch of unessecary nil checks
- Removed :release() from test methods, collectgarbage("collect") is called between methods instead

- Renamed /output to /examples to avoid confusion

- Replaced love.filesystem.newFile with love.filesystem.openFile
- Replaced love.math.noise with love.math.perlinNoise / love.math.simplexNoise

- Fixed newGearJoint throwing an error in 12 as body needs to be dynamic not static now

- Some general cleanup, incl. better comments and time format in file output
2023-10-05 23:03:32 +01:00

74 lines
1.8 KiB
Lua

-- love.event
-- love.event.clear
love.test.event.clear = function(test)
-- push some events first
love.event.push('test', 1, 2, 3)
love.event.push('test', 1, 2, 3)
love.event.push('test', 1, 2, 3)
-- check after calling clear there are no events left
love.event.clear()
local count = 0
for n, a, b, c, d, e, f in love.event.poll() do
count = count + 1
end
test:assertEquals(0, count, 'check no events')
end
-- love.event.poll
love.test.event.poll = function(test)
-- push some events first
love.event.push('test', 1, 2, 3)
love.event.push('test', 1, 2, 3)
love.event.push('test', 1, 2, 3)
-- check poll recieves all events
local count = 0
for n, a, b, c, d, e, f in love.event.poll() do
count = count + 1
end
test:assertEquals(3, count, 'check 3 events')
end
-- love.event.pump
-- @NOTE dont think can really test as internally used
love.test.event.pump = function(test)
test:skipTest('not sure can be tested as used internally')
end
-- love.event.push
love.test.event.push = function(test)
-- check pushing some different types
love.event.push('add', 1, 2, 3)
love.event.push('ignore', 1, 2, 3)
love.event.push('add', 1, 2, 3)
love.event.push('ignore', 1, 2, 3)
local count = 0
for n, a, b, c, d, e, f in love.event.poll() do
if n == 'add' then
count = count + a + b + c
end
end
test:assertEquals(12, count, 'check total events')
end
-- love.event.quit
love.test.event.quit = function(test)
-- setting this overrides the quit hook to prevent actually quitting
love.test.module.fakequit = true
love.event.quit(0)
-- if it failed we'd have quit here
test:assertEquals(true, true, 'check quit hook called')
end
-- love.event.wait
-- @NOTE not sure best way to test this one
love.test.event.wait = function(test)
test:skipTest('test method needs writing')
end