Changeset 12291 in project


Ignore:
Timestamp:
10/29/08 03:17:33 (13 years ago)
Author:
Ivan Raikov
Message:

Completed porting the test cases from FilePath?.hs

Location:
release/3/filepath/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/filepath/trunk/filepath.scm

    r12289 r12291  
    231231
    232232(define (split-all-extensions p)
    233   (match-let (((a b)  (split-file-name p)))
    234     (match (scatter is-ext-separator? b)
    235            ((c . d)  (list a (intersperse b (ext-separator))))
    236            (else     (list p (list))))))
     233  (let ((pcs (if (string? p) (string->list p) p)))
     234    (match-let (((a b)  (split-file-name pcs)))
     235               (match (scatter is-ext-separator? b)
     236                      ((c d . e) (list (concatenate (append a (list c)))
     237                                       (concatenate (intersperse (cons d e) (list (ext-separator))))))
     238                      (else       (list pcs (list)))))))
    237239
    238240(define (drop-all-extensions p)
     
    572574
    573575(define (is-bad-elem? x)
    574   (member (map char-upcase (drop-all-extensions x)) bad-elems))
     576  (let ((x1 (map char-upcase (drop-all-extensions x))))
     577    (member x1 bad-elems)))
    575578
    576579(define (is-valid? p)
     
    656659
    657660(define (list-wrapper lst)
    658   (begin ; (print "lst = " lst)
    659          (map list->string lst)))
     661  (map list->string lst))
    660662
    661663  ;; Path methods (environment $PATH)
  • release/3/filepath/trunk/tests/run.scm

    r12289 r12291  
    209209
    210210
    211 
     211(define is-valid-posix-tests
     212  `(("/random_ path:*" #t)))
     213
     214(define is-valid-windows-tests
     215 `(( "c:\\test" #t)
     216   ( "c:\\test:of_test" #f)
     217   ( "test*" #f)
     218   ( "c:\\test\\nul" #f)
     219   ( "c:\\test\\prn.txt" #f)
     220   ( "c:\\nul\\file" #f)))
     221
     222
     223(test-group "is-valid?"
     224            (filepath:posix #f)
     225            (for-each (lambda (pr)
     226                        (let ((p (first pr)) (res (second pr)))
     227                          (test (sprintf "~S => ~S" (list 'is-valid? p) res)
     228                                res (filepath:is-valid? p))))
     229                      is-valid-windows-tests)
     230            (filepath:posix #t)
     231            (for-each (lambda (pr)
     232                        (let ((p (first pr)) (res (second pr)))
     233                          (test (sprintf "~S => ~S" (list 'is-valid? p) res)
     234                                res (filepath:is-valid? p))))
     235                      is-valid-posix-tests))
     236
     237(define make-valid-tests
     238  `(("c:\\test:of_test"  "c:\\test_of_test")
     239    ("test*"  "test_")
     240    ("c:\\test\\nul"  "c:\\test\\nul_")
     241    ("c:\\test\\prn.txt"  "c:\\test\\prn_.txt")
     242    ("c:\\test/prn.txt"  "c:\\test/prn_.txt")
     243    ("c:\\nul\\file"  "c:\\nul_\\file")))
     244
     245
     246(test-group "make-valid"
     247            (filepath:posix #f)
     248            (for-each (lambda (pr)
     249                        (let ((p (first pr)) (res (second pr)))
     250                          (test (sprintf "~S => ~S" (list 'make-valid p) res)
     251                                res (filepath:make-valid p))))
     252                      make-valid-tests)
     253            (filepath:posix #t)
     254            )
Note: See TracChangeset for help on using the changeset viewer.