Assert.IsAlmost
This assertion is used to check whether the input is almost equal to a given value.
Details
Checks whether the input value lies within the range defined by the Threshold
parameter around the specified Value
. The shard returns true if the input is within this range (exclusive of the lower limit and inclusive of the upper limit), and false otherwise.
If the Break
parameter is set to false - logs an assertion validation error but continues running the programme.
Examples
; :Break = `true`, assertion true
; => log no errors and dont abort program
8 | Assert.IsAlmost(7 Break: true Threshold: 1)
[warning] line_info: File path is invalid
; :Break = `true`, assertion false
; => abort the program
7.0 | Maybe({
Assert.IsAlmost(8.0 Break: true)
})
[warning] line_info: File path is invalid
[error] Failed assertion IsAlmost, input: 7 expected: 8
[error] Assert.IsAlmost -> Error: Assert failed - IsAlmost, <unknown>:4:3
[warning] Maybe shard Ignored an error: Assert failed - IsAlmost, line: 3, column: 7, wire: sample-wire
; :Break = `false`, assertion true
; => log no errors and dont abort program
8.0 | Assert.IsAlmost(8.0 Break: false)
[warning] line_info: File path is invalid
; :Break = `false`, assertion false
; => log assertion error but dont abort program
8.0 | Maybe({
Assert.IsAlmost(7.999 Break: false Threshold: 0.0001)
})
[warning] line_info: File path is invalid
[error] Failed assertion IsAlmost, input: 8 expected: 7.999
[error] Assert.IsAlmost -> Error: Assert failed - IsAlmost, <unknown>:4:3
[warning] Maybe shard Ignored an error: Assert failed - IsAlmost, line: 3, column: 7, wire: sample-wire