~pepe/eleanor

4b4bcc9dc12b35f97f6ad5b8e493132e59cd4a25 — Josef Pospíšil 9 months ago 886b758
Message for asserted is optional
2 files changed, 7 insertions(+), 1 deletions(-)

M eleanor/points.janet
M test/suite01.janet
M eleanor/points.janet => eleanor/points.janet +1 -1
@@ 303,5 303,5 @@

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

M test/suite01.janet => test/suite01.janet +6 -0
@@ 404,4 404,10 @@

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

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

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

(assert-no-error "asserted" ((=> (asserted nil?)) nil))

(end-suite)