(examples-for filter-remove

("removes (memoise) from a list of forms"
 (filter-remove 'memoise '((trace)
                           ;; this is a comment
                           (memoise)
                           (let x a
                             (+ x b)
                             (bingo dingbat))))
 (((memoise))
  ((trace)
   (comment "this is a comment")
   (let x a
     (+ x b)
     (bingo dingbat))))))

(examples-for filter-forms

("groups forms by their 'car if the 'car is a key in the given hash"
 (let ff (filter-forms { car nil comment nil mac nil }
                       '(let x 1
                          ; first comment
                          (mac push foo bar)
                          (car that)
                          ; another comment
                          (car engine)
                          (drive faster)
                          (mac more macaroni)
                          (car wheels)
                          (mac and cheese)
                          ; ok enough cheese
                          (finish cheese)
                          (car go)))
   (list (hash-keys ff)
         ff.car
         ff.comment
         ff.mac
         (hash-get ff nil)))
 ((car comment mac nil)
  ((that) (engine) (wheels) (go))
  (("first comment") ("another comment") ("ok enough cheese"))
  ((push foo bar) (more macaroni) (and cheese))
  (let x 1 (drive faster) (finish cheese))))

("find no comments"
 (hash-values (filter-forms { comment nil } '((this) (that))))
 (nil ((this) (that))))

("finds one comment"
 (hash-values (filter-forms { comment nil }
                            '((comment "hello") (this) (that))))
 ((("hello")) ((this) (that))))

("finds more comments"
 (hash-values (filter-forms { comment nil }
                             '((comment "hello")
                               (comment "more details")
                               (comment "very rigourous")
                               (this)
                               (that))))
 ((("hello") ("more details") ("very rigourous")) ((this) (that)))))

(examples-for filter-comments

("returns nil for nil"
 (filter-comments nil nil)
 nil)

("returns atom for atom"
 (filter-comments 12 nil)
 12)

("returns list for list"
 (filter-comments '(a b c d) nil)
 (a b c d))

("returns list without comment for list with comment"
 (filter-comments '(a b (comment "hahaha") c d) nil)
 (a b c d))

("returns nothing for comment"
 (filter-comments '((comment "hahaha")) nil)
 nil)

("weeds out nested comments"
 (filter-comments '(1 2 (3 4
                           (comment "yoyo") 5
                           (6 7 (comment "eight") 8 9)
                           { 10 (comment "eleven") 11 12 13 }
                           (comment "fourteen") 14) (comment "fifteen") 15
                           (if 16 (comment "seventeen") 17 (comment "eighteen") 18 19)))
 (1 2 (3 4 5 (6 7 8 9) (brace-list 10 11 12 13) 14) 15 (if 16 17 18 19))))