Safe Haskell | None |
---|---|
Language | GHC2021 |
AtCoder.Internal.Assert
Description
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 !_ = checkIndexBounded "AtCoder.Internal.Assert.doctest" 2 1 3
>>>
let !_ = checkIndexBounded "AtCoder.Internal.Assert.doctest" (-1) 1 3
*** Exception: AtCoder.Internal.Assert.doctest: given invalid index `-1` over bounds `[1, 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` ...
>>>
let !_ = checkIntervalBounded "AtCoder.Internal.Assert.doctest" 2 4 0 5
>>>
let !_ = checkIntervalBounded "AtCoder.Internal.Assert.doctest" (-1) 0 0 5
*** Exception: AtCoder.Internal.Assert.doctest: given invalid interval `[-1, 0)` over bounds `[0, 5)` ...
>>>
let !_ = checkPoint2d "AtCoder.Internal.Assert.doctest" 1 1 2 2
>>>
let !_ = checkPoint2d "AtCoder.Internal.Assert.doctest" 4 4 2 2
*** Exception: AtCoder.Internal.Assert.doctest: given invalid point `(4, 4)` for rectangle `[0, 2) x [0, 2)` ...
>>>
let !_ = checkRect "AtCoder.Internal.Assert.doctest" 1 2 1 2 3 3
>>>
let !_ = checkRect "AtCoder.Internal.Assert.doctest" 1 2 1 2 1 1
*** Exception: AtCoder.Internal.Assert.doctest: given invalid rectangle `[1, 2) x [1, 2)` for rectangle `[0, 1) x [0, 1)` ...
Since: 1.0.0.0
Synopsis
- runtimeAssert :: HasCallStack => Bool -> String -> ()
- testIndex :: HasCallStack => Int -> Int -> Bool
- testInterval :: Int -> Int -> Int -> Bool
- testIntervalBounded :: Int -> Int -> Int -> Int -> Bool
- testPoint2d :: HasCallStack => Int -> Int -> Int -> Int -> Bool
- testRect :: HasCallStack => Int -> Int -> Int -> Int -> Int -> Int -> Bool
- testRectShape :: HasCallStack => Int -> Int -> Int -> Int -> Bool
- checkIndex :: HasCallStack => String -> Int -> Int -> ()
- errorIndex :: HasCallStack => String -> Int -> Int -> a
- checkIndexBounded :: HasCallStack => String -> Int -> Int -> Int -> ()
- errorIndexBounded :: HasCallStack => String -> Int -> 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
- checkIntervalBounded :: HasCallStack => String -> Int -> Int -> Int -> Int -> ()
- errorIntervalBounded :: HasCallStack => String -> Int -> Int -> Int -> Int -> a
- checkPoint2d :: HasCallStack => String -> Int -> Int -> Int -> Int -> ()
- errorPoint2d :: HasCallStack => String -> Int -> Int -> Int -> Int -> a
- checkRect :: HasCallStack => String -> Int -> Int -> Int -> Int -> Int -> Int -> ()
- errorRect :: HasCallStack => String -> Int -> Int -> Int -> Int -> Int -> Int -> a
- checkRectShape :: HasCallStack => String -> Int -> Int -> Int -> Int -> ()
- errorRectShape :: HasCallStack => String -> Int -> Int -> Int -> Int -> a
Runtime assertion
runtimeAssert :: HasCallStack => Bool -> String -> () Source #
\(O(1)\) Assertion that is never erased at compile time.
Since: 1.0.0.0
Tests
Arguments
:: HasCallStack | |
=> Int | \(i\) |
-> Int | \(n\) |
-> Bool | \(0 \le i \lt n\) |
\(O(1)\) Tests \(0 \le i \lt n\).
Since: 1.0.0.0
\(O(1)\) Tests \(0 \le l \le r \le n\).
Since: 1.0.0.0
\(O(1)\) Tests \(l_0 \le l \le r \le r_0\).
Since: 1.2.1.0
Arguments
:: HasCallStack | |
=> Int | \(x\) |
-> Int | \(y\) |
-> Int | \(w\) |
-> Int | \(h\) |
-> Bool | \((x, y) \in [0, w) \times [0, h)\) |
\(O(1)\) Tests \((x, y) \in [0, w) \times [0, h)\).
Since: 1.2.3.0
Arguments
:: HasCallStack | |
=> Int | \(x_1\) |
-> Int | \(x_2\) |
-> Int | \(y_1\) |
-> Int | \(y_2\) |
-> Int | \(w\) |
-> Int | \(h\) |
-> Bool | \([x_1, x_2) \times [y_1 y_2) \in [0, w) \times [0, h)\). |
\(O(1)\) Tests \([x_1, x_2) \times [y_1 y_2) \in [0, w) \times [0, h)\).
Since: 1.2.3.0
Arguments
:: HasCallStack | |
=> Int | \(x_1\) |
-> Int | \(x_2\) |
-> Int | \(y_1\) |
-> Int | \(y_2\) |
-> Bool | \(x_1 \le x_2 \land y_1 \le \y_2\). |
\(O(1)\) Tests \(x_1 \le x_2 \land y_1 \le \y_2\).
Since: 1.2.3.0
Index assertions
checkIndex :: HasCallStack => String -> Int -> Int -> () Source #
\(O(1)\) Asserts \(0 \leq i \lt n\) for an array index \(i\).
Since: 1.0.0.0
errorIndex :: HasCallStack => String -> Int -> Int -> a Source #
\(O(1)\) Emits index boundary error.
Since: 1.0.0.0
checkIndexBounded :: HasCallStack => String -> Int -> Int -> Int -> () Source #
\(O(1)\) Asserts \(l_0 \leq i \lt r_0\) for an array index \(i\).
Since: 1.2.1.0
errorIndexBounded :: HasCallStack => String -> Int -> Int -> Int -> a Source #
\(O(1)\) Emits index boundary error.
Since: 1.2.1.0
checkVertex :: HasCallStack => String -> Int -> Int -> () Source #
\(O(1)\) Asserts \(0 \leq i \lt n\) for a graph vertex \(i\).
Since: 1.0.0.0
errorVertex :: HasCallStack => String -> Int -> Int -> a Source #
\(O(1)\) Emits vertex boundary error.
Since: 1.0.0.0
checkEdge :: HasCallStack => String -> Int -> Int -> () Source #
\(O(1)\) Asserts \(0 \leq i \lt m\) for an edge index \(i\).
Since: 1.0.0.0
errorEdge :: HasCallStack => String -> Int -> Int -> a Source #
\(O(1)\) Emits edge index boundary error.
Since: 1.0.0.0
checkCustom :: HasCallStack => String -> String -> Int -> String -> Int -> () Source #
\(O(1)\) Asserts index boundary with custom message.
Since: 1.0.0.0
errorCustom :: HasCallStack => String -> String -> Int -> String -> Int -> a Source #
\(O(1)\) Emis custom index error.
Since: 1.0.0.0
Interval assertions
checkInterval :: HasCallStack => String -> Int -> Int -> Int -> () Source #
\(O(1)\) Asserts \(0 \leq l \leq r \leq n\) for a half-open interval \([l, r)\).
Since: 1.0.0.0
errorInterval :: HasCallStack => String -> Int -> Int -> Int -> a Source #
\(O(1)\) Emits interval boundary error.
Since: 1.0.0.0
checkIntervalBounded :: HasCallStack => String -> Int -> Int -> Int -> Int -> () Source #
\(O(1)\) Asserts \(0 \leq l \leq r \leq n\) for a half-open interval \([l, r)\).
Since: 1.2.1.0
errorIntervalBounded :: HasCallStack => String -> Int -> Int -> Int -> Int -> a Source #
\(O(1)\) Emits interval boundary error.
Since: 1.2.1.0
Two-dimensional index assertions
checkPoint2d :: HasCallStack => String -> Int -> Int -> Int -> Int -> () Source #
\(O(1)\) Asserts \(0 \leq i \lt n\) for a graph vertex \(i\).
Since: 1.2.3.0
errorPoint2d :: HasCallStack => String -> Int -> Int -> Int -> Int -> a Source #
\(O(1)\) Emits point boundary error.
Since: 1.2.3.0
checkRect :: HasCallStack => String -> Int -> Int -> Int -> Int -> Int -> Int -> () Source #
\(O(1)\) Asserts \([x_1, x_2) \times [y_1 y_2) \in [0, w) \times [0, h)\).
Since: 1.2.3.0
errorRect :: HasCallStack => String -> Int -> Int -> Int -> Int -> Int -> Int -> a Source #
\(O(1)\) Asserts rectangle boundary error.
Since: 1.2.3.0
checkRectShape :: HasCallStack => String -> Int -> Int -> Int -> Int -> () Source #
\(O(1)\) Asserts \(x_1 \le x_2\) and \(y_1 \le \y_2\).
Since: 1.2.3.0
errorRectShape :: HasCallStack => String -> Int -> Int -> Int -> Int -> a Source #
\(O(1)\) Asserts rectangle boundary error.
Since: 1.2.3.0