Qa.assert

From MiniScript Wiki
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