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:
ell
2023-11-23 12:52:54 +00:00
parent 63d303a22f
commit f846d4ab91
16 changed files with 1028 additions and 534 deletions
+52 -18
View File
@@ -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