Difference between revisions of "Qa.assert"
Jump to navigation
Jump to search
Shellrider (talk | contribs) (Created page with "You can use this function if you want to make sure that a specific fact is true at a certain point of your program. The function takes an condition and an optional description...") |
Shellrider (talk | contribs) |
||
Line 6: | Line 6: | ||
createPerson = function (age) | createPerson = function (age) | ||
− | qa.assert | + | qa.assert age >= 0, "age can not be negative" |
noob = {} | noob = {} | ||
noob.age = age | noob.age = age |
Latest revision as of 13:06, 20 September 2025
You can use this function if you want to make sure that a specific fact is true at a certain point of your program. The function takes an condition and an optional description as parameters. This is often useful when writing tests or to check inputs to functions. In case the condition is not met this function uses abort(errMsg) to halt script execution and print a stack trace.
Example
import "qa"
createPerson = function (age)
qa.assert age >= 0, "age can not be negative"
noob = {}
noob.age = age
return noob
end function