# File : tests/test/script/runner/for.testscript # license : MIT; see accompanying LICENSE file .include ../common.testscript : form-1 : : for x: ... : { : basics : $c <>EOO for x: a b echo "$x" >| end EOI a b EOO : test-options : $c <>~%EOO% for test.options: -a -b echo $* >| end EOI %.+ -a% %.+ -b% EOO : special-var : $c <>EOE != 0 for ~: -a -b echo $~ >| end EOI testscript:1:5: error: attempt to set '~' variable directly EOE : exit : $c <>EOO for x: a b echo "$x" >| exit end EOI a EOO : error : $c <>EOO 2>>EOE != 0 for x: a b echo "$x" >| exit 'fed up' end EOI a EOO testscript:3:3: error: fed up info: test id: 1 EOE } : form-2 : : ... | for x : { : whitespace-split : $c <>EOO echo " a b " | for -w x echo "'$x'" >| end EOI 'a' 'b' EOO : newline-split : $c <>EOO cat <| end EOI '' '' 'a' '' '' 'b' '' EOO : typed : $c <>/EOO echo "a b" | for -w x [dir_path] echo $x >| end EOI a/ b/ EOO : nested : $c <>EOO echo "a b" | for -w x echo "x y" | for -w y echo "'$x $y'" >| end end EOI 'a x' 'a y' 'b x' 'b y' EOO : nested-diag : $c <>/~%EOE% != 0 echo "a b" | for -w x echo "x y" | for -w y echo "'$x $y'" >"'a x'" end end EOI testscript:3:5: error: echo stdout doesn't match expected info: stdout: test/1/stdout-i1-i2-n3 info: expected stdout: test/1/stdout-i1-i2-n3.orig info: stdout diff: test/1/stdout-i1-i2-n3.diff %.+ EOE : nested-diag-test-id : $c <>EOE != 0 echo "a b" | for -w x echo "x y" | for -w y test -f $x$y end end EOI testscript:3:5: error: builtin test exited with code 1 info: test id: 1 EOE : var-value : $c <>EOO x = 'x'; echo "a b" | for -w x end; echo $x >| EOI b EOO : both-sep-options : $c <>/~%EOE% != 0 echo "a b" | for -n -w x echo $x >| end EOI testscript:1:1: error: for: both -n|--newline and -w|--whitespace specified %.+ EOE : invalid-option : $c <>/~%EOE% != 0 echo "a b" | for -a x echo $x >| end EOI testscript:1:1: error: for: unknown option '-a' %.+ EOE : no-variable : $c <>/~%EOE% != 0 echo "a b" | for -w echo $x >| end EOI testscript:1:1: error: for: missing variable name %.+ EOE : special-var : $c <>EOE != 0 echo "a b" | for -w ~ echo $* >| end EOI testscript:1:1: error: attempt to set '~' variable directly info: test id: 1 EOE : unsep-attrs : $c <>EOE != 0 echo "a b" | for -w x[string] echo $x >| end EOI testscript:1:1: error: for: expected variable name instead of x[string] info: test id: 1 EOE : misuse : { : after-var : $c <>EOE != 0 echo "a b" | for v: echo $v >| end EOI testscript:1:19: error: expected newline instead of ':' EOE : after-attrs : $c <>EOE != 0 echo "a b" | for v [string]: echo $v >| end EOI testscript:1:28: error: expected newline instead of ':' EOE } : exit : $c <>EOO echo "a b" | for x echo "$x" >| exit end EOI a EOO : error : $c <>EOO 2>>EOE != 0 echo "a b" | for x echo "$x" >| exit 'fed up' end EOI a EOO testscript:3:3: error: fed up info: test id: 1 EOE } : form-3 : : for x <... : { : whitespace-split : $c <>EOO for -w x <" a b " echo "'$x'" >| end EOI 'a' 'b' EOO : quoted-opt : $c <>EOO o = -n for "$o" x <| end; for "($o)" x <| end EOI 'a' 'b' 'c' 'd' EOO : newline-split : $c <>EOO for -n x <| end EOI '' '' 'a' '' '' 'b' '' EOO : string-before-var : $c <>EOO for <"a b" -w x echo "'$x'" >| end EOI 'a' 'b' EOO : here-doc-before-var : $c <>EOO for <| end EOI 'a' 'b' EOO : typed : $c <>/EOO for -w x [dir_path] <"a b" echo $x >| end EOI a/ b/ EOO : typed-no-ops : $c <>/EOO for x [dir_path] <"a b" echo $x >| end EOI a/ b/ EOO : nested : $c <>EOO for -w x <"a b" for -w y <"x y" echo "'$x $y'" >| end end EOI 'a x' 'a y' 'b x' 'b y' EOO : nested-diag : $c <>/~%EOE% != 0 for -w x <"a b" for -w y <"x y" echo "'$x $y'" >"'a x'" end end EOI testscript:3:5: error: echo stdout doesn't match expected info: stdout: test/1/stdout-i1-i2-n3 info: expected stdout: test/1/stdout-i1-i2-n3.orig info: stdout diff: test/1/stdout-i1-i2-n3.diff %.+ EOE : nested-diag-test-id : $c <>EOE != 0 for -w x <"a b" for -w y <"x y" test -f $x$y end end EOI testscript:3:5: error: builtin test exited with code 1 info: test id: 1 EOE : var-value : $c <>EOO x = 'x'; for -w x <"a b" end; echo $x >| EOI b EOO : invalid-option : $c <>/~%EOE% != 0 for -a x <"a b" echo $x >| end EOI testscript:1:1: error: for: unknown option '-a' %. EOE : no-variable : $c <>/~%EOE% != 0 for -w <"a b" echo $x >| end EOI testscript:1:1: error: for: missing variable name %. EOE : special-var : $c <>EOE != 0 for ~ <"a b" echo $~ >| end EOI testscript:1:5: error: attempt to set '~' variable directly EOE : exit : $c <>EOO for x <"a b" echo "$x" >| exit end EOI a EOO : error : $c <>EOO 2>>EOE != 0 for x <"a b" echo "$x" >| exit 'fed up' end EOI a EOO testscript:3:3: error: fed up info: test id: 1 EOE }