Skip to content

Assert.Is

Name Mandatory Description Default Type
⬅️ Input The input can be of any type. Any
Output ➡️ The output will be the input (passthrough). Any
Value No The value to test against for equality. none Any
Break No 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

Returns true if the input is equal to the Value parameter and false otherwise. The shard also is type sensitive (e.g., 1 | Is(1.0) will return false).

If the Break parameter is set to false - logs an assertion validation error but continues running the programme.

Examples

1
2
3
// :Break = `true`, assertion true
// => log no errors and dont abort program
8 | Assert.Is(8 Break: true)


 

1
2
3
4
5
// :Break = `true`, assertion false
// => abort the program
7 | Maybe({
  Assert.Is(8 Break: true)
})

[error] Failed assertion Is, input: 7 expected: 8
[warning] Maybe shard Ignored an error
    Assert failed - Is
    Unknown error
  - Assert.Is Shards/Assert/Is/2.shs:4:3
    Unknown error
  - Maybe Shards/Assert/Is/2.shs:3:5
 

1
2
3
// :Break = `false`, assertion true
// => log no errors and dont abort program
8 | Assert.Is(8 Break: false)


 

1
2
3
4
5
// :Break = `false`, assertion false
// => log assertion error but dont abort program
7 | Maybe({
  Assert.Is(8 Break: false)
})

[error] Failed assertion Is, input: 7 expected: 8
[warning] Maybe shard Ignored an error
    Assert failed - Is
    Unknown error
  - Assert.Is Shards/Assert/Is/4.shs:4:3
    Unknown error
  - Maybe Shards/Assert/Is/4.shs:3:5