New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update splitDirectories
function
#4
Conversation
I checked the test function. And here are my thought about how to update it. My first attempt was to compare lists of test_SplitDirectories :: Test
test_SplitDirectories = assertions "splitDirectories" $ do
let splitDirectories x = P.splitDirectories (fromChar8 x)
fromChar8' = map fromChar8
$expect $ equal (splitDirectories "") (fromChar8' [""])
$expect $ equal (splitDirectories "/") (fromChar8' ["/"])
$expect $ equal (splitDirectories "/a") (fromChar8' ["/", "a"])
$expect $ equal (splitDirectories "/ab/cd") (fromChar8' ["/", "ab", "cd"])
$expect $ equal (splitDirectories "/ab/cd/") (fromChar8' ["/", "ab", "cd"])
$expect $ equal (splitDirectories "ab/cd") (fromChar8' ["ab", "cd"])
$expect $ equal (splitDirectories "ab/cd/") (fromChar8' ["ab", "cd"])
$expect $ equal (splitDirectories "ab/cd.txt") (fromChar8' ["ab", "cd.txt"])
$expect $ equal (splitDirectories "ab/cd/.txt") (fromChar8' ["ab", "cd", ".txt"])
$expect $ equal (splitDirectories "ab/./cd") (fromChar8' ["ab", ".", "cd"]) But
So yeah. that's was expectable. The second attempt was to use test_SplitDirectories :: Test
test_SplitDirectories = assertions "splitDirectories" $ do
let splitDirectories x = P.concat $ P.splitDirectories (fromChar8 x)
$expect $ equal (splitDirectories "") (fromChar8 "")
$expect $ equal (splitDirectories "/") (fromChar8 "/")
$expect $ equal (splitDirectories "/a") (fromChar8 "/a")
$expect $ equal (splitDirectories "/ab/cd") (fromChar8 "/ab/cd")
$expect $ equal (splitDirectories "/ab/cd/") (fromChar8 "/ab/cd")
$expect $ equal (splitDirectories "ab/cd") (fromChar8 "ab/cd")
$expect $ equal (splitDirectories "ab/cd/") (fromChar8 "ab/cd")
$expect $ equal (splitDirectories "ab/cd.txt") (fromChar8 "ab/cd.txt")
$expect $ equal (splitDirectories "ab/cd/.txt") (fromChar8 "ab/cd/.txt")
$expect $ equal (splitDirectories "ab/./cd") (fromChar8 "ab/./cd") (yeah, probably I should use another name instead of All tests are passed and I am happy. But wait. While I do like using My intuition says me that Current definition of Checkout my last commit to see what I've got. |
splitDirectories
function
Hm, just checked
But I saw it only once. |
so it respects root and directories
@chrisdone Can you look into this? |
Ping. Any updates on this? |
Checking it out. |
So there's quite a mess of invariants flying around in this library. But the Where are your |
Ah, from the test suite. |
Okay, this gives at least the property of identity on Passing to @snoyberg. |
@chrisdone thanks for checking my commit
True indeed. |
update `splitDirectories` function
I propose this solution for issue #3.
In short, currently
concat . splitDirectories /= id
.Here is example of using
concat . splitDirectories
:In my commit I updated
splitDirectories
function, so now it treats root part aspathRoot
, but not aspathBasename
.I have run all testes, and here is content of log file:
I found that there is
test_SplitDirectories
function inFilesystemPathTests.hs
file:So probably it couldn't find the problem because of
toChar8 . f . fromChar8
. Basically, that's what I get if I don't converttoChar8
:Also I see that there are other places where
toChar8 . f . fromChar8
conversion is used, so I am going to check those functions as well.Sorry for long message.
Cheers and thanks for your awesome library!