Qa.assert

From MiniScript Wiki
Revision as of 13:06, 20 September 2025 by 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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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