# file      : tests/variable/prerequisite-specific/testscript
# license   : MIT; see accompanying LICENSE file

.include ../../common.testscript

# There is currently no support for expanding prerequisite-specific variables
# (since there is no way to id a prerequisite) so we use dump.
#

: basic
:
$* <<EOI 2>>/~%EOE%
dir{x}: fox = FOX
dir{x}: dir{a}: foo = FOO
dir{x}: dir{b}: fox += FOX
dir{x}: dir{c}: bar = [bool] true
dump dir{x}
EOI
<stdin>:5:1: dump:
%  .+/dir\{x/\}:%
  {
    fox = FOX
  }
%  .+/dir\{x/\}: .+:dir\{a/\}:%
  {
    foo = FOO
  }
%  .+/dir\{x/\}: .+:dir\{b/\}:%
  {
    fox = FOX FOX
  }
%  .+/dir\{x/\}: .+:dir\{c/\}:%
  {
    bar = [bool] true
  }
EOE

: multiple
:
$* <<EOI 2>>/~%EOE%
dir{x} dir{y}: dir{a} dir{b}: foo = FOO
dump dir{x} dir{y}
EOI
<stdin>:2:1: dump:
%  .+/dir\{x/\}: .+:dir\{a/\}:%
  {
    foo = FOO
  }
%  .+/dir\{x/\}: .+:dir\{b/\}:%
  {
    foo = FOO
  }

%  .+/dir\{y/\}: .+:dir\{a/\}:%
  {
    foo = FOO
  }
%  .+/dir\{y/\}: .+:dir\{b/\}:%
  {
    foo = FOO
  }
EOE

: block
:
$* <<EOI 2>>/~%EOE%
foo = COX
dir{x}: foo = FOX
dir{x}: dir{a}:
{
  foo = FOO
  bar = BAR
}
dump dir{x}
EOI
<stdin>:8:1: dump:
%  .+/dir\{x/\}:%
  {
    foo = FOX
  }
%  .+/dir\{x/\}: .+:dir\{a/\}:%
  {
    bar = BAR
    foo = FOO
  }
EOE

: block-multiple
:
$* <<EOI 2>>/~%EOE%
dir{y}: foo = FOX
dir{x} dir{y}: dir{a} dir{b}:
{
  foo += FOO
  bar = BAR $foo
}
dump dir{y}
EOI
<stdin>:7:1: dump:
%  .+/dir\{y/\}:%
  {
    foo = FOX
  }
%  .+/dir\{y/\}: .+:dir\{a/\}:%
  {
    bar = BAR FOX FOO
    foo = FOX FOO
  }
%  .+/dir\{y/\}: .+:dir\{b/\}:%
  {
    bar = BAR FOX FOO
    foo = FOX FOO
  }
EOE

: chain
:
$* <<EOI 2>>/~%EOE%
dir{x}: dir{y}: dir{a}: foo = FOO
dump dir{y}
EOI
<stdin>:2:1: dump:
%  .+/dir\{y/\}: .+:dir\{a/\}:%
  {
    foo = FOO
  }
EOE