Differences

This shows you the differences between two versions of the page.

Link to this comparison view

asserttag [2016/09/22 02:35] (current)
Line 1: Line 1:
 +===== Assert Tag=====
 +
 +Assert tag asserts that the condition defined in the attributes is true and forces failure when the condition does not evaluate to true.
 +
 +==== Syntax ====
 +The syntax of //assert// tag is:
 +
 +    <assert value1="​expression1" ​
 +            op="​comparator" ​
 +            value2="​expression2" ​
 +            else="​L1:​ exception message" ​
 +            tags="​requirement tags" ​
 +            passed="​message or expression"/>​
 +
 +==== Value Expression ====
 +//value1// and //value2// are MScript expressions. ​ MScript expression can be:
 +
 +  * static text
 +  * numeric string
 +  * [[mscriptFunc|mScript method]]
 +  * mixture of all above
 +
 +==== Comparison Operator ====
 +//​Comparison Operator// can be one of the following:
 +
 +  * //eq// - exact match, for comparing two numbers or text strings
 +  * //lt// - less than, for comparing two numbers or text strings
 +  * //gt// - greater\ than=gt@tooltip:​greater than, for comparing two numbers or text strings
 +  * //le// - less than or equal to, for comparing two numbers or text strings
 +  * //ge// - greater than or equal to, for comparing two numbers or text strings
 +  * //match// - regular express to matching value 1 with pattern in value2
 +  * //between// - between two numbers specified in comma separated string
 +  * //​contains//​ - contains a substring
 +  * //in// - test if a number or text is in one of the numbers or texts specified in comma separated string ​
 +  * //​startsWith//​ - starts with the text
 +  * //​endsWith//​ - ends with the text
 +  * //​soundsLike//​ - sounds like the word specified using [[http://​en.wikipedia.org/​wiki/​Soundex|Soundex]]
 +  * //​spellsLike//​ - spells like the word specified by calculating the [[http://​en.wikipedia.org/​wiki/​Levenshtein_distance| Levenshtein edit distance]] between the two words and check if the edit distance is within 10% of the length of shorter word.
 +  * //ne// - not equal, for comparing two numbers or text strings
 +  * //​NOTmatch//​ - regular express to matching value 1 with pattern in value2
 +  * //​NOTbetween//​ - between two numbers specified in comma separated string
 +  * //NOTin// - test if a number or text is in one of the numbers or texts specified in comma separated string ​
 +  * //​NOTcontains//​ - does not contain a sub-string
 +  * //​NOTstartsWith//​ - does not start with the text
 +  * //​NOTendsWith//​ - does not end with the text
 +  * //​NOTsoundsLike//​ - does not sound like the word specified
 +  * //​NOTspellsLike//​ - does not spell like the word specified
 +
 +
 +==== Additional Info ====
 +Use //true// to compare to a boolean data value.
 +
 +You may use mscript logic operation methods //$not()//, //​$compare()//,​ //$or()// etc. to construct a more complex logic expression, see details of these methods in [[mScriptFunc|mScript method]].
 +
 +The exception level in the //else// attribute can be L1, L2, ... L5.
 +
 +You may signal to have execution aborted when the assert is failed by specifying //abort// as the exception level. For example:
 +
 +    <assert .... else = "​abort:​ fatal error, can not continue."/>​
 +
 +The expression message can be a static message or an expression containing [[mScriptFunc|mScript method]].
 +
 +You may also use the following tokens in the "​else"​ and "​passed"​ message:
 +
 +  * //EXPR1// (or [expr1]) - the original expr1 specified in the assert tag
 +  * //EXPR2// (or [expr2]) - the original expr2 specified in the assert tag
 +  * //OP// (or [op]) - the compare operator specified in the assert tag
 +  * //VALUE1// (or [value1]) - the result value from the expr1 in the assert tag
 +  * //VALUE2// (or [value2]) - the result value from the expr2 in the assert tag
 +  * //STATUS// (or [status]) - the validation status of the assert tag: //passed// or //failed//
 +
 +//passed// attribute is optional. When the assert evaluates to true, this expression is executed and the results are written to mScript log. (rel 3.0.10)
 +
 +//tags// attribute is also optional. This is equivalent to //​$addTagCheck()//​ call. You may embed a priority in the tags, e.g. H:1.2.3 to indicate High priority for the requirement 1.2.3. (rel 3.1.6)
 +
 +//assert// tag can be used in //Guard Trigger//​. ​ Starting with release build 4.4.10, you should use [[guardTag | guard tag]] in //Guard Trigger//.
  
Print/export
QR Code
QR Code asserttag (generated for current page)