aboutsummaryrefslogtreecommitdiff
path: root/tests/function/path
diff options
context:
space:
mode:
Diffstat (limited to 'tests/function/path')
-rw-r--r--tests/function/path/testscript168
1 files changed, 150 insertions, 18 deletions
diff --git a/tests/function/path/testscript b/tests/function/path/testscript
index 6219f3c..6321b3d 100644
--- a/tests/function/path/testscript
+++ b/tests/function/path/testscript
@@ -8,36 +8,107 @@ posix = (!$windows)
s = ($posix ? '/' : '\')
-: canonicalize
+: posix-string
:
{
- $* <'print $canonicalize([path] a/b)' >"a$(s)b" : path
- $* <'print $canonicalize([paths] a/b a/c)' >"a$(s)b a$(s)c" : paths
- $* <'print $canonicalize([dir_path] a/b)' >"a$(s)b$s" : dir-path
- $* <'print $canonicalize([dir_paths] a/b a/c/)' >"a$(s)b$s a$(s)c$s" : dir-paths
- $* <'print $path.canonicalize(a/b)' >"a$(s)b" : untyped
- $* <'print $path.canonicalize(a/b/ a/c)' >"a$(s)b$s a$(s)c" : mixed
+ : relative
+ :
+ {
+ s = ($posix ? '/' : '\\')
+
+ $* <"print \$posix_string\([path] a$(s)b)" >'a/b' : path
+ $* <"print \$posix_string\([paths] a$(s)b a$(s)c$(s))" >'a/b a/c' : paths
+ $* <"print \$posix_string\([dir_path] a$(s)b)" >'a/b' : dir-path
+ $* <"print \$posix_string\([dir_paths] a$(s)b a$(s)c$(s))" >'a/b a/c' : dir-paths
+ $* <"print \$path.posix_string\(a$(s)b a$(s)c$(s))" >'a/b a/c' : untyped
+ }
+
+ : absolute
+ :
+ {
+ if $posix
+ {
+ $* <'print $posix_string([paths] /a/b /a/c/)' >'/a/b /a/c' : paths
+ $* <'print $posix_string([dir_paths] /a/b /a/c/)' >'/a/b /a/c' : dir-paths
+ $* <'print $posix_string([dir_path] /)' >'/' : root-dir
+ $* <'print $path.posix_string(/a/b /a/c/)' >'/a/b /a/c' : untyped
+ }
+ else
+ {
+ $* <'print $posix_string([paths] "c:\\a\\b" "C:\\a\\c\\")' >'c:/a/b C:/a/c' : paths
+ $* <'print $posix_string([dir_paths] "c:\\a\\b" "C:\\a\\c\\")' >'c:/a/b C:/a/c' : dir-paths
+ $* <'print $posix_string([dir_paths] "c:\\" "C:")' >'c:/ C:/' : root-dir
+ $* <'print $path.posix_string("c:\\a\\b" "C:\\a\\c\\")' >'c:/a/b C:/a/c' : untyped
+ $* <'print $path.posix_string("c:\\" "C:")' >'c:/ C:/' : untyped-root
+ }
+ }
}
-: normalize
+: posix-representation
:
{
- $* <'print $normalize([path] a/../b)' >"b" : path
- $* <'print $normalize([paths] a/../b a/../c)' >"b c" : paths
- $* <'print $normalize([dir_path] a/../b)' >"b$s" : dir-path
- $* <'print $normalize([dir_paths] a/../b a/../c/)' >"b$s c$s" : dir-paths
- $* <'print $path.normalize(a/../b)' >"b" : untyped
- $* <'print $path.normalize(a/../b/ a/../c)' >"b$s c" : mixed
+ : relative
+ :
+ {
+ s = ($posix ? '/' : '\\')
+
+ $* <"print \$posix_representation\([path] a$(s)b)" >'a/b' : path
+ $* <"print \$posix_representation\([paths] a$(s)b a$(s)c$(s))" >'a/b a/c/' : paths
+ $* <"print \$posix_representation\([dir_path] a$(s)b)" >'a/b/' : dir-path
+ $* <"print \$posix_representation\([dir_paths] a$(s)b a$(s)c$(s))" >'a/b/ a/c/' : dir-paths
+ $* <"print \$path.posix_representation\(a$(s)b a$(s)c$(s))" >'a/b a/c/' : untyped
+ }
+
+ : absolute
+ :
+ {
+ if $posix
+ {
+ $* <'print $posix_representation([paths] /a/b /a/c/)' >'/a/b /a/c/' : paths
+ $* <'print $posix_representation([dir_paths] /a/b /a/c/)' >'/a/b/ /a/c/' : dir-paths
+ $* <'print $posix_representation([dir_path] /)' >'/' : root-dir
+ $* <'print $path.posix_representation(/a/b /a/c/)' >'/a/b /a/c/' : untyped
+ }
+ else
+ {
+ $* <'print $posix_representation([paths] "c:\\a\\b" "C:\\a\\c\\")' >'c:/a/b C:/a/c/' : paths
+ $* <'print $posix_representation([dir_paths] "c:\\a\\b" "C:\\a\\c\\")' >'c:/a/b/ C:/a/c/' : dir-paths
+ $* <'print $posix_representation([dir_paths] "c:\\" "C:")' >'c:/ C:/' : root-dir
+ $* <'print $path.posix_representation("c:\\a\\b" "C:\\a\\c\\")' >'c:/a/b C:/a/c/' : untyped
+ $* <'print $path.posix_representation("c:\\" "C:")' >'c:/ C:/' : untyped-root
+ }
+ }
}
-: actualize
+: absolute
:
-if! $posix
{
- mkdir Foo;
- $* <'print $path.actualize($out_base/foo)' >~'/.+\\Foo/'
+ $* <'print $absolute($src_root)' >"true" : true
+ $* <'print $path.absolute(a/b)' >"false" : false
+}
+
+: simple
+:
+{
+ $* <'print $simple([path] a)' >"true" : true
+ $* <'print $path.simple(a/b)' >"false" : false
+}
+
+: sub_path
+:
+{
+ $* <'print $sub_path($src_base, $src_root)' >"true" : true-absolute
+ $* <'print $path.sub_path(a/b/c, a/b)' >"true" : true-relative
+ $* <'print $path.sub_path(a/b/c, a/d)' >"false" : false
}
+: super_path
+:
+{
+ $* <'print $super_path($src_base, true-absolute)' >"true" : true-absolute
+ $* <'print $path.super_path(a/b/c, b/c)' >"true" : true-relative
+ $* <'print $path.super_path(a/b/c, c/a)' >"false" : false
+}
: directory
:
@@ -133,6 +204,53 @@ if! $posix
EOO
}
+: complete
+:
+{
+ $* <'print $complete([path] a)' >"$~$(s)a" : path
+ $* <'print $complete([dir_path] a)' >"$~$(s)a$(s)" : dir-path
+ $* <'print $path.complete(a)' >"$~$(s)a" : untyped
+
+ echo $path.complete(a) > "$~$(s)a" : testscript
+}
+
+: canonicalize
+:
+{
+ $* <'print $canonicalize([path] a/b)' >"a$(s)b" : path
+ $* <'print $canonicalize([paths] a/b a/c)' >"a$(s)b a$(s)c" : paths
+ $* <'print $canonicalize([dir_path] a/b)' >"a$(s)b$s" : dir-path
+ $* <'print $canonicalize([dir_paths] a/b a/c/)' >"a$(s)b$s a$(s)c$s" : dir-paths
+ $* <'print $path.canonicalize(a/b)' >"a$(s)b" : untyped
+ $* <'print $path.canonicalize(a/b/ a/c)' >"a$(s)b$s a$(s)c" : mixed
+}
+
+: normalize
+:
+{
+ $* <'print $normalize([path] a/../b)' >"b" : path
+ $* <'print $normalize([paths] a/../b a/../c)' >"b c" : paths
+ $* <'print $normalize([dir_path] a/../b)' >"b$s" : dir-path
+ $* <'print $normalize([dir_paths] a/../b a/../c/)' >"b$s c$s" : dir-paths
+ $* <'print $path.normalize(a/../b)' >"b" : untyped
+ $* <'print $path.normalize(a/../b/ a/../c)' >"b$s c" : mixed
+}
+
+: try_normalize
+:
+{
+ $* <'print $try_normalize([path] a/../b)' >"b" : valid
+ $* <'print $path.try_normalize($root_directory($src_root)/..)' >"[null]" : invalid
+}
+
+: actualize
+:
+if! $posix
+{
+ mkdir Foo;
+ $* <'print $path.actualize($out_base/foo)' >~'/.+\\Foo/'
+}
+
: sort
:
{
@@ -158,6 +276,20 @@ if! $posix
$* <'print $size([dir_path] )' >'0' : dir-zero
}
+: find
+:
+{
+ $* <'print $find([paths] x y z, y)' >'true' : basics-true
+ $* <'print $find([paths] x y z, a)' >'false' : basics-false
+}
+
+: find_index
+:
+{
+ $* <'print $find_index([dir_paths] x y z, y)' >'1' : basics-true
+ $* <'print $find_index([dir_paths] x y z, a)' >'3' : basics-false
+}
+
: invalid-path
:
p = ($posix ? /../foo : 'c:/../foo');