# file      : tests/test/script/runner/while.testscript
# license   : MIT; see accompanying LICENSE file

.include ../common.testscript

: basics
:
$c <<EOI && $b >>EOO
  while ($v != "aa")
  {
    echo "$v" >|
    v = "$(v)a"
  }
  EOI

  a
  EOO

: continue
:
$c <<EOI && $b >>EOO
  while ($v != "aaxa")
  {
    if ($v == 'aa')
    {
      v = "$(v)x"
      continue
    }

    echo "$v" >|
    v = "$(v)a"
  }
  EOI

  a
  aax
  EOO

: break
:
$c <<EOI && $b >>EOO
  while ($v != "aaaa")
  {
    if ($v == 'aa')
      break

    echo "$v" >|
    v = "$(v)a"
  }
  EOI

  a
  EOO

: syntax-1
:
{{
  b = [cmdline] $regex.apply($b, '(.+testscript.syntax).+', "\1 = 1'")

  : basics
  :
  $c <<EOI && $b >>EOO
    while ($v != "aa")
      echo "$v" >|
      v = "$(v)a"
    end
    EOI

    a
    EOO
}}
