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)