Safe Haskell | None |
---|---|
Language | GHC2021 |
Runtime assertion utility.
Example
>>>
let !_ = runtimeAssert False "errorMessage"
*** Exception: errorMessage ...
>>>
let !_ = checkIndex "AtCoder.Internal.Assert.doctest" 0 3
>>>
let !_ = checkIndex "AtCoder.Internal.Assert.doctest" (-1) 3
*** Exception: AtCoder.Internal.Assert.doctest: given invalid index `-1` over length `3` ...
>>>
let !_ = checkVertex "AtCoder.Internal.Assert.doctest" 0 3
>>>
let !_ = checkVertex "AtCoder.Internal.Assert.doctest" (-1) 3
*** Exception: AtCoder.Internal.Assert.doctest: given invalid vertex `-1` over the number of vertices `3` ...
>>>
let !_ = checkEdge "AtCoder.Internal.Assert.doctest" 0 3
>>>
let !_ = checkEdge "AtCoder.Internal.Assert.doctest" (-1) 3
*** Exception: AtCoder.Internal.Assert.doctest: given invalid edge index `-1` over the number of edges `3` ...
>>>
let !_ = checkCustom "AtCoder.Internal.Assert.doctest" "index" 0 "set" 3
>>>
let !_ = checkCustom "AtCoder.Internal.Assert.doctest" "index" (-1) "set" 3
*** Exception: AtCoder.Internal.Assert.doctest: given invalid index `-1` over set `3` ...
>>>
let !_ = checkInterval "AtCoder.Internal.Assert.doctest" 0 3 3
>>>
let !_ = checkInterval "AtCoder.Internal.Assert.doctest" 0 4 3
*** Exception: AtCoder.Internal.Assert.doctest: given invalid interval `[0, 4)` over length `3` ...
Since: 1.0.0
Synopsis
- runtimeAssert :: HasCallStack => Bool -> String -> ()
- testIndex :: HasCallStack => Int -> Int -> Bool
- testInterval :: Int -> Int -> Int -> Bool
- checkIndex :: HasCallStack => String -> Int -> Int -> ()
- errorIndex :: HasCallStack => String -> Int -> Int -> a
- checkVertex :: HasCallStack => String -> Int -> Int -> ()
- errorVertex :: HasCallStack => String -> Int -> Int -> a
- checkEdge :: HasCallStack => String -> Int -> Int -> ()
- errorEdge :: HasCallStack => String -> Int -> Int -> a
- checkCustom :: HasCallStack => String -> String -> Int -> String -> Int -> ()
- errorCustom :: HasCallStack => String -> String -> Int -> String -> Int -> a
- checkInterval :: HasCallStack => String -> Int -> Int -> Int -> ()
- errorInterval :: HasCallStack => String -> Int -> Int -> Int -> a
Runtime assertion
runtimeAssert :: HasCallStack => Bool -> String -> () #
\(O(1)\) Assertion that is never erased at compile time.
Since: 1.0.0
Tests
testInterval :: Int -> Int -> Int -> Bool #
\(O(1)\) Tests weather \([l, r)\) is a valid interval in \([0, n)\).
Since: 1.0.0
Index assertions
checkIndex :: HasCallStack => String -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt n\) for an array index \(i\).
Since: 1.0.0
errorIndex :: HasCallStack => String -> Int -> Int -> a #
\(O(1)\) Emits index boundary error.
Since: 1.0.0
checkVertex :: HasCallStack => String -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt n\) for a graph vertex \(i\).
Since: 1.0.0
errorVertex :: HasCallStack => String -> Int -> Int -> a #
\(O(1)\) Asserts \(0 \leq i \lt n\) for a graph vertex \(i\).
Since: 1.0.0
checkEdge :: HasCallStack => String -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt m\) for an edge index \(i\).
Since: 1.0.0
errorEdge :: HasCallStack => String -> Int -> Int -> a #
\(O(1)\) Asserts \(0 \leq i \lt m\) for an edge index \(i\).
Since: 1.0.0
checkCustom :: HasCallStack => String -> String -> Int -> String -> Int -> () #
\(O(1)\) Asserts \(0 \leq i \lt m\) for an edge index \(i\).
Since: 1.0.0
errorCustom :: HasCallStack => String -> String -> Int -> String -> Int -> a #
\(O(1)\) Asserts \(0 \leq i \lt m\) for an edge index \(i\).
Since: 1.0.0
Interval assertion
checkInterval :: HasCallStack => String -> Int -> Int -> Int -> () #
\(O(1)\) Asserts \(0 \leq l \leq r \leq n\) for a half-open interval \([l, r)\).
Since: 1.0.0
errorInterval :: HasCallStack => String -> Int -> Int -> Int -> a #
\(O(1)\) Asserts \(0 \leq l \leq r \leq n\) for a half-open interval \([l, r)\).
Since: 1.0.0