aboutsummaryrefslogtreecommitdiff
path: root/tests/function/path/testscript
blob: bfbc8958e44b49d8b4d6bb66eef7c8aa1192702c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# file      : tests/function/path/testscript
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include ../../common.test

s = ($cxx.target.class != 'windows' ? '/' : '\')

: 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

  : actualize
  :
  if ($cxx.target.class == 'windows')
  {
    mkdir Foo;
    $* <'print $path.normalize($out_base/foo, true)' >~'/.+\\Foo/'
  }
}

: invalid-path
:
p = ($cxx.target.class != 'windows' ? /../foo : 'c:/../foo');
$* <"\$path.normalize\('$p')" 2>>"EOE" != 0
error: invalid path: '$p'
EOE