From c33ab1bac593b71810182e8fb914cf5cfcde04b7 Mon Sep 17 00:00:00 2001 From: "D. Ben Knoble" Date: Mon, 13 Nov 2023 16:47:51 -0500 Subject: [PATCH] test list-remove --- qi/utils.rkt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qi/utils.rkt b/qi/utils.rkt index d1c6547..46838af 100644 --- a/qi/utils.rkt +++ b/qi/utils.rkt @@ -6,7 +6,22 @@ (require qi) +(module+ test (require rackunit)) + (define-flow (list-remove _xs _i) (~> split-at (-< (~> (== _ cdr) append) (~> 2> car)))) + +(module+ test + (test-case "list-remove" + (define-flow list-remove1 (~> list-remove 1>)) + (define-flow list-remove2 (~> list-remove 2>)) + (check-equal? (list-remove1 '(a b c) 0) '(b c)) + (check-equal? (list-remove1 '(a b c) 1) '(a c)) + (check-equal? (list-remove1 '(a b c) 2) '(a b)) + (check-equal? (list-remove2 '(a b c) 0) 'a) + (check-equal? (list-remove2 '(a b c) 1) 'b) + (check-equal? (list-remove2 '(a b c) 2) 'c) + (for ([i '(-1 3 4 5 10)]) + (check-exn exn:fail? (thunk (list-remove '(a b c) i))))))