mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
review changes
- spaced out object class tests and added more defined comment groups - changed reusing vars in case it causes unexpected asserts in future - fixed some shape:point test having wrong params - added assertTrue + assertFalse for basic checks - used assertRange more for some of the physics + audio tests
This commit is contained in:
@@ -71,6 +71,58 @@ TestMethod = {
|
||||
end,
|
||||
|
||||
|
||||
-- @method - TestMethod:assertTrue()
|
||||
-- @desc - used to assert a value is true
|
||||
-- @param {any} value - value to test
|
||||
-- @param {string} label - label for this test to use in exports
|
||||
-- @return {nil}
|
||||
assertTrue = function(self, value, label)
|
||||
self.count = self.count + 1
|
||||
table.insert(self.asserts, {
|
||||
key = 'assert ' .. tostring(self.count),
|
||||
passed = value == true,
|
||||
message = 'expected \'true\' got \'' ..
|
||||
tostring(value) .. '\'',
|
||||
test = label or 'no label given'
|
||||
})
|
||||
end,
|
||||
|
||||
|
||||
-- @method - TestMethod:assertFalse()
|
||||
-- @desc - used to assert a value is false
|
||||
-- @param {any} value - value to test
|
||||
-- @param {string} label - label for this test to use in exports
|
||||
-- @return {nil}
|
||||
assertFalse = function(self, value, label)
|
||||
self.count = self.count + 1
|
||||
table.insert(self.asserts, {
|
||||
key = 'assert ' .. tostring(self.count),
|
||||
passed = value == false,
|
||||
message = 'expected \'false\' got \'' ..
|
||||
tostring(value) .. '\'',
|
||||
test = label or 'no label given'
|
||||
})
|
||||
end,
|
||||
|
||||
|
||||
-- @method - TestMethod:assertNotEquals()
|
||||
-- @desc - used to assert two values are not equal
|
||||
-- @param {any} expected - expected value of the test
|
||||
-- @param {any} actual - actual value of the test
|
||||
-- @param {string} label - label for this test to use in exports
|
||||
-- @return {nil}
|
||||
assertNotEquals = function(self, expected, actual, label)
|
||||
self.count = self.count + 1
|
||||
table.insert(self.asserts, {
|
||||
key = 'assert ' .. tostring(self.count),
|
||||
passed = expected ~= actual,
|
||||
message = 'avoiding \'' .. tostring(expected) .. '\' got \'' ..
|
||||
tostring(actual) .. '\'',
|
||||
test = label or 'no label given'
|
||||
})
|
||||
end,
|
||||
|
||||
|
||||
-- @method - TestMethod:assertPixels()
|
||||
-- @desc - checks a list of coloured pixels agaisnt given imgdata
|
||||
-- @param {ImageData} imgdata - image data to check
|
||||
@@ -103,24 +155,6 @@ TestMethod = {
|
||||
end,
|
||||
|
||||
|
||||
-- @method - TestMethod:assertNotEquals()
|
||||
-- @desc - used to assert two values are not equal
|
||||
-- @param {any} expected - expected value of the test
|
||||
-- @param {any} actual - actual value of the test
|
||||
-- @param {string} label - label for this test to use in exports
|
||||
-- @return {nil}
|
||||
assertNotEquals = function(self, expected, actual, label)
|
||||
self.count = self.count + 1
|
||||
table.insert(self.asserts, {
|
||||
key = 'assert ' .. tostring(self.count),
|
||||
passed = expected ~= actual,
|
||||
message = 'avoiding \'' .. tostring(expected) .. '\' got \'' ..
|
||||
tostring(actual) .. '\'',
|
||||
test = label or 'no label given'
|
||||
})
|
||||
end,
|
||||
|
||||
|
||||
-- @method - TestMethod:assertRange()
|
||||
-- @desc - used to check a value is within an expected range
|
||||
-- @param {number} actual - actual value of the test
|
||||
|
||||
Reference in New Issue
Block a user