aboutsummaryrefslogtreecommitdiff
path: root/tests/function/path/testscript
blob: 0f83ad691a32a1c0d7997761bb87b3d927953c14 (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
# file      : tests/function/path/testscript
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

+mkdir build
+cat <<EOI >>>build/bootstrap.build
project = test
amalgamation =
EOI

test.options += -q --buildfile - noop

+if ($cxx.target.class != windows) # @@ TMP ternarry
  s = '/'
else
  s = '\'
end

: 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/../b)'        >"b$s b"    : mixed
}

: invalid-path
:
if ($cxx.target.class != windows) # @@ TMP ternarry
  p = /../foo
else
  p = c:/../foo
end;
$* <"\$path.normalize\('$p')" 2>>"EOE" != 0
error: invalid path: '$p'
EOE