File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,7 +66,32 @@ do -- path.splitpath & path.splitext
6666end
6767
6868
69- -- TODO: path.abspath
69+ do -- path.abspath
70+ local cp = path .currentdir ()
71+
72+ -- Relative paths should become absolute and point to the same location
73+ local rel = path .abspath (" docs" )
74+ asserteq (path .isabs (rel ), true )
75+ asserteq (slash (rel ):sub (-# " /docs" ), " /docs" )
76+
77+ -- Absolute paths should remain unchanged or normalized
78+ local abs = path .abspath (cp )
79+ asserteq (slash (abs ), slash (cp ))
80+
81+ -- "." should resolve to the current directory
82+ local dot = path .abspath (" ." )
83+ asserteq (slash (dot ), slash (cp ))
84+
85+ -- ".." should resolve to an absolute parent path
86+ local parent = path .abspath (" .." )
87+ asserteq (path .isabs (parent ), true )
88+
89+ -- Explicit pwd parameter should be honored
90+ local with_pwd = path .abspath (" test.txt" , cp )
91+ asserteq (path .isabs (with_pwd ), true )
92+ asserteq (slash (with_pwd ), slash (path .join (cp , " test.txt" )))
93+ end
94+
7095
7196-- TODO: path.dirname
7297
You can’t perform that action at this time.
0 commit comments