local tmpdir

before_each ->
  tmpdir = File.tmpdir!

after_each ->


before_each -> File.mkdir tmpdir / 'subdir'

returns the home dir for empty input

assert.same {File.home_dir, ''}, {paths.get_dir_and_leftover ''}

returns the root directory for "/"

assert.same {File.home_dir.root_dir, ''}, {paths.get_dir_and_leftover '/'}

returns the matched path and unmatched parts of a path

assert.same {tmpdir, 'unmatched'}, {paths.get_dir_and_leftover tostring(tmpdir / 'unmatched')}

when given a directory path ending in "/", matches the given directory

assert.same {tmpdir / 'subdir', ''}, {paths.get_dir_and_leftover tostring(tmpdir)..'/subdir/'}

when given a directory path not ending in "/", matches the parent directory

assert.same {tmpdir, 'subdir'}, {paths.get_dir_and_leftover tostring(tmpdir)..'/subdir'}

unmatched part can contain slashes

assert.same {tmpdir, 'unmatched/no/such/file'}, {paths.get_dir_and_leftover tostring(tmpdir / 'unmatched/no/such/file')}

(is given a non absolute path)

uses the home dir as the base path

assert.same {File.home_dir, 'unmatched-asdf98y23903943masgb sdf'}, {paths.get_dir_and_leftover 'unmatched-asdf98y23903943masgb sdf'}