Megatest

test.scm at [ad27901967]
Login

File path-glob/test.scm artifact 66f288bdb2 part of check-in ad27901967


(use test posix srfi-1)
(load "path-glob.scm")

;; (define globbers `((multi-glob . ,multi-glob)(path-glob . ,path-glob)))
(define globbers `((path-glob . ,path-glob)))

(define interesting-patts '("../*/*" "/*/bin/*" "./*/bin/*"))
(define simple-patts '("../*" "/*" "/bin/*" "." ".." "*" "a[0-1]*"))

(define (trim-list lst)
  (if (> (length lst) 3)
      (append (take lst 3) '(...))
      lst))

(define (generate-prefix patt)
  (write (conc "patt: " patt (make-string (- 10 (string-length patt)) #\ ))))

(print "\nCompare each globber with glob") ;; can only do one level globs here
(for-each
 (lambda (globber)
   (print "\nGlobber: " globber " vs glob")
   (for-each
    (lambda (patt)
      (generate-prefix patt)
      (test #f '() (trim-list
		    (lset-xor string=? ((alist-ref globber globbers) patt)(glob patt)))))
    simple-patts))
 (map car globbers))

(print "\nTest the globbers against patts - only checks for resiliance, not correctness.")
(for-each
 (lambda (patt)
   (generate-prefix patt)(test #f #t (list? (path-glob patt)))
   ;; (generate-prefix patt)(test #f #t (list? (multi-glob patt)))
   )
 interesting-patts)

(print "\nCompare the globbers against each other")
#;(for-each
 (lambda (patt)
   (generate-prefix patt)
   (test #f '() (trim-list
		 (lset-xor string=? (path-glob patt)(multi-glob patt)))))
 interesting-patts)

(test-exit)