#+TITLE: Tests for default header arguments to Babel source blocks
#+OPTIONS: ^:nil
#+PROPERTY: var  t1="go1" t3="go3_clobbered"
#+PROPERTY: var+ t2="go2" t3="go3"
#+PROPERTY: header-args  :var t1="gh1" t2="gh2_clobbered"
#+PROPERTY: header-args+ :var t4="gh4" t2="gh2" :var end=9
#+PROPERTY: header-args:emacs-lisp  :var t1="ge1" t4="ge4_clobbered"
#+PROPERTY: header-args:emacs-lisp+ :var t4="ge4" :var t5="ge5"
#+PROPERTY: header-args:emacs-lisp+ :results silent :noweb yes

#+NAME: showvar
#+BEGIN_SRC emacs-lisp :execute no
  (mapconcat (lambda (n)
               (let* ((n (string (+ 48 n)))
                      (p (intern (concat "t" n))))
                 (if (boundp p) (eval p) (concat "--" n))))
             (number-sequence 1 end)
             "/")
#+END_SRC

* Global property
  :PROPERTIES:
  :ID:       3fdadb69-5d15-411e-aad0-f7860cdd7816
  :END:

| Global                 | t1  | t2  | t3  | t4  | t5  | t6  | t7  | t8  | t9  |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| var property           | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
| header-args            | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
| header-args:emacs-lisp | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| Result                 | ge1 | gh2 | go3 | ge4 | ge5 | --6 | --7 | --8 | --9 |

#+CALL: showvar() :results silent
#+BEGIN_SRC emacs-lisp :var end=7
<<showvar>>
#+END_SRC

* Tree property
** Overwrite
  :PROPERTIES:
  :ID:       a9cdfeda-9f31-4bb5-b694-2cf452f07dfd
  :var: t6="to6"
  :header-args: :var t7="th7"
  :header-args:emacs-lisp: :var t8="te8"
  :header-args:emacs-lisp+: :results silent :noweb yes :var end=9
  :END:

| Global                 | t1  | t2  | t3  | t4  | t5  | t6  | t7  | t8  | t9  |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| var property           | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
| header-args            | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
| header-args:emacs-lisp | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| Tree                   | t1  | t2  | t3  | t4  | t5  | t6  | t7  | t8  | t9  |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| var property           | --- | --- | --- | --- | --- | to6 | --- | --- | --- |
| header-args            | --- | --- | --- | --- | --- | --- | th7 | --- | --- |
| header-args:emacs-lisp | --- | --- | --- | --- | --- | --- | --- | te8 | --- |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| Result #+CALL          | go1 | go2 | go3 | --4 | --5 | --- | th7 | te8 | --9 |
| Result noweb           | --1 | --2 | --3 | --4 | --5 | to6 | th7 | te8 | --9 |

#+CALL: showvar() :results silent
#+BEGIN_SRC emacs-lisp
<<showvar>>
#+END_SRC

** Accumulate
  :PROPERTIES:
  :ID:       1d97d258-fd50-4107-a095-e4625bffc57b
  :var+: t1="to1"
  :var+: t6="to6"
  :header-args+: :var t2="th2" t3="th3"
  :header-args:emacs-lisp+: :var t5="te5" end=8
  :END:

| Global                  | t1  | t2  | t3  | t4  | t5  | t6  | t7  | t8  | t9  |
|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| var property            | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
| header-args             | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
| header-args:emacs-lisp  | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| Tree                    | t1  | t2  | t3  | t4  | t5  | t6  | t7  | t8  | t9  |
|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| var+ property           | to1 | --- | --- | --- | --- | to6 | --- | --- | --- |
| header-args+            | --- | th2 | th3 | --- | --- | --- | --- | --- | --- |
| header-args:emacs-lisp+ | --- | --- | --- | --- | te5 | --- | --- | --- | --- |
|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| Result #+CALL           | ge1 | th2 | th3 | ge4 | te5 | --6 | --7 | --8 | --9 |
| Result noweb            | ge1 | th2 | th3 | ge4 | te5 | to6 | --7 | --8 | --9 |

#+CALL: showvar(end=6) :results silent
#+BEGIN_SRC emacs-lisp
<<showvar>>
#+END_SRC

** Complex
  :PROPERTIES:
  :ID:       fa0e912d-d9b4-47b0-9f9e-1cbb39f7cbc2
  :var: t1="to1"
  :var+: t6="to6"
  :header-args+: :var t2="th2"
  :header-args:emacs-lisp: :var t5="te5" end=7
  :header-args:emacs-lisp+: :results silent :noweb yes :var end=9
  :END:

| Global                 | t1  | t2  | t3  | t4  | t5  | t6  | t7  | t8  | t9  |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| var property           | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
| header-args            | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
| header-args:emacs-lisp | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| Tree                   | t1  | t2  | t3  | t4  | t5  | t6  | t7  | t8  | t9  |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| var property           | to1 | --- | --- | --- | --- | to6 | --- | --- | --- |
| header-args+           | --- | th2 | --- | --- | --- | --- | --- | --- | --- |
| header-args:emacs-lisp | --- | --- | --- | --- | te5 | --- | --- | --- | --- |
|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
| Result #+CALL          | gh1 | th2 | go3 | gh4 | te5 | --6 | --7 | --8 | --9 |
| Result noweb           | gh1 | th2 | --3 | gh4 | te5 | to6 | --7 | --8 | --9 |

#+CALL: showvar(end=6) :results silent
#+BEGIN_SRC emacs-lisp
<<showvar>>
#+END_SRC