Skip to content

Commit

Permalink
fix for splitPath test
Browse files Browse the repository at this point in the history
  • Loading branch information
kig committed Jan 21, 2009
1 parent 2eb913c commit 89e6d4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/prelude.ml
Expand Up @@ -8484,21 +8484,30 @@ let splitPath p = match p with
| (""::t) -> "/"::t
| ps -> ps
end
let joinPath ps = match ps with [] -> "." | l -> foldl1 (^/) l
(**T
splitPath "" = []
splitPath "/" = ["/"]
splitPath "/home/foo/derr/" = ["/"; "home"; "foo"; "derr"]
**)
let joinPath ps = match ps with [] -> "" | l -> foldl1 (^/) l
(**T
joinPath (splitPath "/foo/bar/baz") = "/foo/bar/baz"
joinPath (splitPath "/foo/") = "/foo"
joinPath (splitPath "/foo") = "/foo"
joinPath (splitPath "/") = "/"
joinPath [] = "."
joinPath [] = ""
joinPath (splitPath "/foo//bar/baz") = "/foo/bar/baz"
joinPath (splitPath "/foo/../bar/baz") = "/foo/../bar/baz"
**)
let relativePath path =
let cp = splitPath (expandPath ".") in
let pp = splitPath (expandPath path) in
let cp, pp = dropWhile2 (=) cp pp in
joinPath (replicate (len cp) ".." @ pp)
(**T
relativePath "." = "."
relativePath "" = ""
relativePath "." = ""
relativePath "test" = "test"
xmatch "^(\\.\\./)+" (relativePath "/")
xmatch "^(\\.\\./)+tmp$" (relativePath "/tmp")
Expand Down
2 changes: 1 addition & 1 deletion test/quickcheck.ml
Expand Up @@ -105,7 +105,7 @@ let char = (cg, sprintf "%C")
let printable_char = (printable, sprintf "%C")
let numeral_char = (numeral, sprintf "%C")

let string_gen_of_size size gen = (sg_size ~gen, sprintf "%S")
let string_gen_of_size size gen = (sg_size ~gen size, sprintf "%S")
let string_gen gen = (sg ~gen, sprintf "%S")

let string = string_gen cg
Expand Down
1 change: 1 addition & 0 deletions tools/make_suite.rb
Expand Up @@ -108,6 +108,7 @@
module Q = Quickcheck
open #{mod}
let (==>) = Q.(==>)
let _iteri f l = ignore (List.fold_left (fun i v -> f v i; i + 1) 0 l)
let _TL = _iteri (fun (n,b) i ->
OUnit.assert_bool ("Line " ^ string_of_int (i+1) ^ " of bool test: " ^ n) b)
Expand Down

0 comments on commit 89e6d4b

Please sign in to comment.