Changeset 15040 in project


Ignore:
Timestamp:
06/21/09 19:47:26 (10 years ago)
Author:
sjamaan
Message:

Add uri-path-relative/absolute predicates and tests

Location:
release/4/uri-generic
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/uri-generic/tags/2.3/tests/run.scm

    r13229 r15040  
    350350            non-relative-non-absolute-uri-references))
    351351
     352(define absolute-paths
     353  '("/foo"
     354    "//foo/"
     355    "http://foo/bar"
     356    "http://foo/"
     357    "http://foo/#qux"))
     358
     359(define relative-paths
     360  '(""
     361    "http://foo"
     362    "//foo"
     363    "http://foo#bar"
     364    "http://foo?bar=qux"))
     365
     366(test-group "absolute/relative path distinction"
     367  (for-each (lambda (s)
     368              (test-assert (sprintf "~S is not a relative path" s)
     369                           (not (uri-path-relative? (uri-reference s))))
     370              (test-assert (sprintf "~S is an absolute path" s)
     371                           (uri-path-absolute? (uri-reference s))))
     372            absolute-paths)
     373  (for-each (lambda (s)
     374              (test-assert (sprintf "~S is a relative path" s)
     375                           (uri-path-relative? (uri-reference s)))
     376              (test-assert (sprintf "~S is not an absolute path" s)
     377                           (not (uri-path-absolute? (uri-reference s)))))
     378            relative-paths))
     379
    352380(test-group "miscellaneous"
    353381  ;; Special case, see section 4.2
  • release/4/uri-generic/tags/2.3/uri-generic.scm

    r14735 r15040  
    5151   uri-decode-string uri-encode-string
    5252   uri-normalize-case uri-normalize-path-segments
     53   uri-path-absolute? uri-path-relative?
    5354
    5455   char-set:gen-delims char-set:sub-delims
     
    10531054(define (uri-normalize-path-segments uri)
    10541055  (update-URI uri path: (just-segments uri)))
     1056
     1057(define (uri-path-absolute? uri)
     1058  (let ((path (uri-path uri)))
     1059   (and (pair? path) (eq? '/ (car path)))))
     1060
     1061(define (uri-path-relative? uri)
     1062  (not (uri-path-absolute? uri)))
    10551063)
  • release/4/uri-generic/tags/2.3/uri-generic.setup

    r14596 r15040  
    1313
    1414  ;; Assoc list with properties for your extension:
    15   '((version 2.2)
     15  '((version 2.3)
    1616    (documentation "uri-generic.html")))
  • release/4/uri-generic/trunk/tests/run.scm

    r13229 r15040  
    350350            non-relative-non-absolute-uri-references))
    351351
     352(define absolute-paths
     353  '("/foo"
     354    "//foo/"
     355    "http://foo/bar"
     356    "http://foo/"
     357    "http://foo/#qux"))
     358
     359(define relative-paths
     360  '(""
     361    "http://foo"
     362    "//foo"
     363    "http://foo#bar"
     364    "http://foo?bar=qux"))
     365
     366(test-group "absolute/relative path distinction"
     367  (for-each (lambda (s)
     368              (test-assert (sprintf "~S is not a relative path" s)
     369                           (not (uri-path-relative? (uri-reference s))))
     370              (test-assert (sprintf "~S is an absolute path" s)
     371                           (uri-path-absolute? (uri-reference s))))
     372            absolute-paths)
     373  (for-each (lambda (s)
     374              (test-assert (sprintf "~S is a relative path" s)
     375                           (uri-path-relative? (uri-reference s)))
     376              (test-assert (sprintf "~S is not an absolute path" s)
     377                           (not (uri-path-absolute? (uri-reference s)))))
     378            relative-paths))
     379
    352380(test-group "miscellaneous"
    353381  ;; Special case, see section 4.2
  • release/4/uri-generic/trunk/uri-generic.scm

    r14735 r15040  
    5151   uri-decode-string uri-encode-string
    5252   uri-normalize-case uri-normalize-path-segments
     53   uri-path-absolute? uri-path-relative?
    5354
    5455   char-set:gen-delims char-set:sub-delims
     
    10531054(define (uri-normalize-path-segments uri)
    10541055  (update-URI uri path: (just-segments uri)))
     1056
     1057(define (uri-path-absolute? uri)
     1058  (let ((path (uri-path uri)))
     1059   (and (pair? path) (eq? '/ (car path)))))
     1060
     1061(define (uri-path-relative? uri)
     1062  (not (uri-path-absolute? uri)))
    10551063)
  • release/4/uri-generic/trunk/uri-generic.setup

    r14596 r15040  
    1313
    1414  ;; Assoc list with properties for your extension:
    15   '((version 2.2)
     15  '((version 2.3)
    1616    (documentation "uri-generic.html")))
Note: See TracChangeset for help on using the changeset viewer.