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
Break If we should trigger a debug breakpoint 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 :Break parameter .

However, if the assertion fails, the program - aborts with an error dump if the :Break 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
;; :Break = `true`, assertion true
;; => log no errors and don't abort program
8
(Assert.Is
 ;:Value
 8
 ;:Break
 true)

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;; :Break = `true`, assertion false
;; => abort the program
7
(Maybe
 (Assert.Is
  ;:Value
  8
  ;:Break
  ;; 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, line: 0, column: 0
[warning] Maybe shard Ignored an error: Assert failed - Is

 

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

 

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