aboutsummaryrefslogtreecommitdiff
path: root/test/paths.tm
diff options
context:
space:
mode:
Diffstat (limited to 'test/paths.tm')
-rw-r--r--test/paths.tm50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/paths.tm b/test/paths.tm
index 1302f7a5..f224b0ff 100644
--- a/test/paths.tm
+++ b/test/paths.tm
@@ -6,14 +6,14 @@ func main():
= yes
>> (~/Downloads/file(1).txt)
- = ~/Downloads/file(1).txt
+ = (~/Downloads/file(1).txt)
>> (/half\)paren)
- = /half)paren
+ = (/half\)paren)
>> filename := "example.txt"
>> (~):child(filename)
- = ~/example.txt
+ = (~/example.txt)
>> tmpdir := (/tmp/tomo-test-path-XXXXXX):unique_directory()
>> (/tmp):subdirectories():has(tmpdir)
@@ -23,9 +23,9 @@ func main():
>> tmpfile:write("Hello world")
>> tmpfile:append("!")
>> tmpfile:read()
- = "Hello world!" : Text?
+ = "Hello world!"?
>> tmpfile:read_bytes()
- = [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21] : [Byte]?
+ = [:Byte, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21]?
>> tmpdir:files():has(tmpfile)
= yes
@@ -36,9 +36,9 @@ func main():
fail("Couldn't read lines in $tmpfile")
>> (./does-not-exist.xxx):read()
- = none : Text?
+ = none : Text
>> (./does-not-exist.xxx):read_bytes()
- = none : [Byte]?
+ = none : [Byte]
if lines := (./does-not-exist.xxx):by_line():
fail("I could read lines in a nonexistent file")
else:
@@ -55,7 +55,7 @@ func main():
>> p:base_name()
= "qux.tar.gz"
>> p:parent()
- = /foo/baz.x
+ = (/foo/baz.x)
>> p:extension()
= "tar.gz"
>> p:extension(full=no)
@@ -69,62 +69,62 @@ func main():
= "baz.qux"
>> (/):parent()
- = /
+ = (/)
>> (~/x/.):parent()
- = ~
+ = (~)
>> (~/x):parent()
- = ~
+ = (~)
>> (.):parent()
- = ..
+ = (..)
>> (..):parent()
- = ../..
+ = (../..)
>> (../foo):parent()
- = ..
+ = (..)
# Concatenation tests:
!! Basic relative path concatenation:
>> (/foo) ++ (./baz)
- = /foo/baz
+ = (/foo/baz)
!! Concatenation with a current directory (`.`):
>> (/foo/bar) ++ (./.)
- = /foo/bar
+ = (/foo/bar)
!! Trailing slash in the first path:
>> (/foo/) ++ (./baz)
- = /foo/baz
+ = (/foo/baz)
!! Trailing slash in the second path:
>> (/foo/bar) ++ (./baz/)
- = /foo/bar/baz
+ = (/foo/bar/baz)
!! Removing redundant current directory (`.`):
>> (/foo/bar) ++ (./baz/./qux)
- = /foo/bar/baz/qux
+ = (/foo/bar/baz/qux)
!! Removing redundant parent directory (`..`):
>> (/foo/bar) ++ (./baz/qux/../quux)
- = /foo/bar/baz/quux
+ = (/foo/bar/baz/quux)
!! Collapsing `..` to navigate up:
>> (/foo/bar/baz) ++ (../qux)
- = /foo/bar/qux
+ = (/foo/bar/qux)
!! Current directory and parent directory mixed:
>> (/foo/bar) ++ (././../baz)
- = /foo/baz
+ = (/foo/baz)
!! Path begins with a `.`:
>> (/foo) ++ (./baz/../qux)
- = /foo/qux
+ = (/foo/qux)
!! Multiple slashes:
>> (/foo) ++ (./baz//qux)
- = /foo/baz/qux
+ = (/foo/baz/qux)
!! Complex path with multiple `.` and `..`:
>> (/foo/bar/baz) ++ (./.././qux/./../quux)
- = /foo/bar/quux
+ = (/foo/bar/quux)
!! Globbing:
>> (./*.tm):glob()