Skip to content

Assert.Is

Name - Description Default Type
<input> The input can be of any type. Any
<output> The output will be the input (passthrough). Any
Value The value to test against for equality. None Any
Abort If we should abort the process on failure. false Bool

This assertion is used to check whether the input is equal to a given value.

Details

If the assertion is satisfied (i.e., the input is equal to or same as the :Value parameter) the program will is allowed to continue (control passes to the next shard), irrespective of the :Abort parameter .

However, if the assertion fails, the program - aborts with an error dump if the :Abort parameter is set to true - logs an assertion validation error but continues running (control passes to the next wire scheduled on the mesh).

Since this shard can precisely control the conditions under which a program is allowed to run or is to be aborted, it's effective for writing (inline) unit test cases with it.

Examples

1
2
3
4
5
6
7
8
;; :Abort = `true`, assertion true
;; => log no errors and don't abort program
8
(Assert.Is
 ;:Value
 8
 ;:Abort
 true)

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;; :Abort = `true`, assertion false
;; => abort the program
7
(Maybe
 (Assert.Is
  ;:Value
  8
  ;:Abort
  ;; uncomment next line to abort program on run
  ;true
  ))
[error] Failed assertion Is, input: 7 expected: 8
[error] Shard activation error, failed shard: Assert.Is, error: Assert failed - Is
[warning] Maybe shard Ignored an error: Assert failed - Is

 

1
2
3
4
5
6
7
8
;; :Abort = `false`, assertion true
;; => log no errors and don't abort program
8
(Assert.Is
 ;:Value
 8
 ;:Abort
 false)

 

1
2
3
4
5
6
7
8
9
;; :Abort = `false`, assertion false
;; => log assertion error but don't abort program
7
(Maybe
 (Assert.Is
  ;:Value
  8
  ;:Abort
  false))
[error] Failed assertion Is, input: 7 expected: 8
[error] Shard activation error, failed shard: Assert.Is, error: Assert failed - Is
[warning] Maybe shard Ignored an error: Assert failed - Is