assert multimethod
Methods
- assert(val:Any, pattern:Any, msg:Str='Assertion failed') Source: stdlib.ngs:301
Throws AssertFail with given message if val does not match the pattern Returns
valExample
my_template.get('concept', []).assert(Arr) assert(loginResult, {'access_token': Str}, "access_token must be present in response")
- assert(val:Any, pattern:Any, e:Exception) Source: stdlib.ngs:308
Throws e with given message if val does not match the pattern Returns
val
- assert(val:Any, msg:Str='Assertion failed') Source: stdlib.ngs:324
Throws AssertFail with given message if val is falsy Parameters
val if evaluates to false, causes AssertFail exception msg message for the exception, defaults to "Assertion failed" Returns
valExample
my_array=[] # ... Code that adds elements to my_array ... assert(my_array.len() > 3, "my_array must have more than 3 elements") # AssertFail exception, with the given message
- assert(f:Fun, t:Type, msg:Str='Assertion failed') Source: stdlib.ngs:334
Throws AssertFail with given function does not throw exception of the given type. Parameters
f Fun t Subtype of Exception Returns
The exceptionExample
assert({1/0}, DivisionByZero)
- assert(p:Path) Source: stdlib.ngs:5926
Checks that the given path exists. Throws AssertFail otherwise. Returns
p
- assert(p:Program) Source: stdlib.ngs:5958
Checks that given program is found in path. Throws AssertFail otherwise. Returns
p