~pepe/eleanor

886b758b74e077048abcf3a784acf5fd9387d4e2 — Josef Pospíšil 1 year, 7 months ago 0a5de3c
Add asserted point
2 files changed, 10 insertions(+), 3 deletions(-)

M eleanor/points.janet
M test/suite01.janet
M eleanor/points.janet => eleanor/points.janet +8 -3
@@ 164,9 164,9 @@
  Returns function that will remove `value` from the array base.
  ```
  [value]
  (fn remove [arr]
    (def index (find-index |(deep= value $) arr))
    (array/remove arr index)))
  (fn remove [base]
    (def index (find-index |(deep= value $) base))
    (array/remove base index)))

(defn trace-base
  ```


@@ 300,3 300,8 @@
(def <->
  "Alias to collected-to-base"
  collected->base)

(defn asserted
  "Asserts `pred` on the `base` and errors with `msg` if it fails."
  [pred msg]
  (fn [base] (assert (pred base) msg)))

M test/suite01.janet => test/suite01.janet +2 -0
@@ 402,4 402,6 @@
(assert (deep= @[@[0] 0] ((=> (<- first) <->) (range 10)))
        "collected->base")

(assert-error "asserted" ((=> (asserted nil? "must be nil")) true))

(end-suite)