aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-09 14:35:00 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-09 14:35:00 -0400
commit900b456a267afc469fb9d79020a6c511e0318959 (patch)
treebd7659c45e8c79dd447fdb58eb22d37603b7ffec /test
parente16792d5eb76326634cb1ad0b21301ec693fccb3 (diff)
Ensure more rigoroous cleanup and validation of paths
Diffstat (limited to 'test')
-rw-r--r--test/paths.tm46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/paths.tm b/test/paths.tm
index 817ef86b..84321bab 100644
--- a/test/paths.tm
+++ b/test/paths.tm
@@ -54,3 +54,49 @@ func main():
>> (../foo):parent()
= (../)
+
+ # Concatenation tests:
+ !! Basic relative path concatenation:
+ >> (/foo) ++ (./baz)
+ = (/foo/baz)
+
+ !! Concatenation with a current directory (`.`):
+ >> (/foo/bar) ++ (./.)
+ = (/foo/bar)
+
+ !! Trailing slash in the first path:
+ >> (/foo/) ++ (./baz)
+ = (/foo/baz)
+
+ !! Trailing slash in the second path:
+ >> (/foo/bar) ++ (./baz/)
+ = (/foo/bar/baz/)
+
+ !! Removing redundant current directory (`.`):
+ >> (/foo/bar) ++ (./baz/./qux)
+ = (/foo/bar/baz/qux)
+
+ !! Removing redundant parent directory (`..`):
+ >> (/foo/bar) ++ (./baz/qux/../quux)
+ = (/foo/bar/baz/quux)
+
+ !! Collapsing `..` to navigate up:
+ >> (/foo/bar/baz) ++ (../qux)
+ = (/foo/bar/qux)
+
+ !! Current directory and parent directory mixed:
+ >> (/foo/bar) ++ (././../baz)
+ = (/foo/baz)
+
+ !! Path begins with a `.`:
+ >> (/foo) ++ (./baz/../qux)
+ = (/foo/qux)
+
+ !! Multiple slashes:
+ >> (/foo) ++ (./baz//qux)
+ = (/foo/baz/qux)
+
+ !! Complex path with multiple `.` and `..`:
+ >> (/foo/bar/baz) ++ (./.././qux/./../quux)
+ = (/foo/bar/quux)
+