aboutsummaryrefslogtreecommitdiff
path: root/tests/function/path/testscript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/function/path/testscript')
-rw-r--r--tests/function/path/testscript161
1 files changed, 152 insertions, 9 deletions
diff --git a/tests/function/path/testscript b/tests/function/path/testscript
index 52b4138..1ed89ca 100644
--- a/tests/function/path/testscript
+++ b/tests/function/path/testscript
@@ -3,7 +3,82 @@
.include ../../common.testscript
-s = ($cxx.target.class != 'windows' ? '/' : '\')
+windows = ($cxx.target.class == 'windows')
+posix = (!$windows)
+
+s = ($posix ? '/' : '\')
+
+: posix-string
+:
+{
+ : 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
+ }
+ }
+}
+
+: posix-representation
+:
+{
+ : 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
+ }
+ }
+}
: canonicalize
:
@@ -25,16 +100,17 @@ s = ($cxx.target.class != 'windows' ? '/' : '\')
$* <'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
+}
- : actualize
- :
- if ($cxx.target.class == 'windows')
- {
- mkdir Foo;
- $* <'print $path.normalize($out_base/foo, true)' >~'/.+\\Foo/'
- }
+: actualize
+:
+if! $posix
+{
+ mkdir Foo;
+ $* <'print $path.actualize($out_base/foo)' >~'/.+\\Foo/'
}
+
: directory
:
{
@@ -45,6 +121,28 @@ s = ($cxx.target.class != 'windows' ? '/' : '\')
$* <'print $path.directory(a/b c/d/)' >"a/ c/" : dir-names
}
+: root_directory
+:
+{
+ : posix
+ :
+ if $posix
+ {
+ $* <'print $root_directory([path] /a/b)' >'/' : basics
+ $* <'print $root_directory([path] /)' >'/' : root
+ }
+
+ : windows
+ :
+ if $windows
+ {
+ $* <'print $root_directory([path] "c:\\a\\b")' >'c:\' : basics
+ $* <'print $root_directory([path] "c:")' >'c:\' : root
+ }
+
+ $* <'print $root_directory([path] a/b)' >'' : relative
+}
+
: base
:
{
@@ -75,6 +173,12 @@ s = ($cxx.target.class != 'windows' ? '/' : '\')
EOE
}
+: relative
+:
+{
+ $* <'print $relative([path] a/b/c, [dir_path] a/x/y)' >"..$s..$(s)b/c" : basics
+}
+
: extension
:
{
@@ -101,9 +205,48 @@ s = ($cxx.target.class != 'windows' ? '/' : '\')
EOO
}
+: sort
+:
+{
+ $* <'print $sort([paths] a c b a)' >'a a b c' : basics
+ $* <'print $sort([paths] a c b a, dedup)' >'a b c' : dedup
+
+ : icase
+ :
+ if $windows
+ {
+ $* <'print $sort([paths] a C B a)' >'a a B C'
+ }
+}
+
+: size
+:
+{
+ $* <'print $size([path] abc)' >'3' : basics
+ $* <'print $size([path] )' >'0' : zero
+
+ $* <'print $size([dir_path] abc)' >'3' : dir-basics
+ $* <'print $size([dir_path] abc/)' >'3' : dir-separator
+ $* <'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 = ($cxx.target.class != 'windows' ? /../foo : 'c:/../foo');
+p = ($posix ? /../foo : 'c:/../foo');
$* <"\$path.normalize\('$p')" 2>>"EOE" != 0
error: invalid path: '$p'
<stdin>:1:2: info: while calling path.normalize\(<untyped>\)