name: "Brace expansion"
cases:
  - name: "Expansion with curly braces: commas"
    stdin: |
      echo "{a,b} =>"
      echo {a,b}
      echo

      echo "{a} =>"
      echo {a}
      echo

      echo "{a} =>"
      echo {a}
      echo

      echo "a{,}b =>"
      echo a{,}b
      echo

      echo "{} =>"
      echo {}
      echo

      echo "1{a,b}2 =>"
      echo 1{a,b}2
      echo

      echo "1{a,b}2{c,d}3 =>"
      echo 1{a,b}2{c,d}3
      echo

      echo "{a,b}{1,2} =>"
      echo {a,b}{1,2}
      echo

      echo 'W\{1,2}X =>'
      echo W\{1,2}X
      echo

      echo 'W{1,2\}X =>'
      echo W{1,2\}X
      echo

      echo '"W{1,2}X" =>'
      echo "W{1,2}X"
      echo

      var=value
      bar=other
      echo '{$var,$ba}r =>'
      echo {$va,$ba}r
      echo

      echo '\${a,b} =>'
      echo \${a,b}
      echo

  - name: "Expansion with curly braces: alpha ranges"
    stdin: |
      echo "{a..f} =>"
      echo {a..f}
      echo

      echo "{a..f..2} =>"
      echo {a..f..2}
      echo

      echo "{a..f..0} =>"
      echo {a..f..0}
      echo

      echo "{m..f} =>"
      echo {m..f}
      echo

  - name: "Expansion with curly braces: numeric ranges"
    stdin: |
      echo "{2..9} =>"
      echo {2..9}
      echo

      echo "{+2..+9} =>"
      echo {+2..+9}
      echo

      echo "{2..2} =>"
      echo {2..2}
      echo

      echo "{2..1} =>"
      echo {2..1}
      echo

      echo "{10..2..0} =>"
      echo {10..2..0}
      echo

      echo "{10..2..2} =>"
      echo {10..2..2}
      echo

      echo "{10..2..-2} =>"
      echo {10..2..-2}
      echo

      echo "{2..9..2} =>"
      echo {2..9..2}
      echo

      echo "{2..9..0} =>"
      echo {2..9..0}
      echo

      echo "{-1..-10} =>"
      echo {-1..-10}
      echo

      echo "{-10..-1} =>"
      echo {-10..-1}
      echo

      echo "{-1..-10..2} =>"
      echo {-1..-10..2}
      echo

  - name: "Expansion with curly braces: nested"
    stdin: |
      echo "W{{1..3},a,x}Y =>"
      echo W{{1..3},a,x}Y
      echo

  - name: "Iterate through modified array"
    stdin: |
      array=("aa" "ba" "ca")

      echo "With quotes:"
      for i in "${array[@]%a}"; do
          echo "Element: '$i'"
      done

      echo "Without quotes:"
      for i in ${array[@]%a}; do
          echo "Element: '$i'"
      done
