Root/
| 1 | #!/bin/bash |
| 2 | . ./Common |
| 3 | |
| 4 | ############################################################################### |
| 5 | |
| 6 | tst "substitutions: continue" -ds -q <<EOF |
| 7 | !-s |
| 8 | in = blah |
| 9 | out = x |
| 10 | in = (?)(*) { |
| 11 | out = \$out\$1\$1 |
| 12 | in = \$2 |
| 13 | continue |
| 14 | } |
| 15 | EOF |
| 16 | |
| 17 | expect <<EOF |
| 18 | in=blah |
| 19 | out=x |
| 20 | in=RE { |
| 21 | out=\${out}\$1\$1 |
| 22 | in=\$2 |
| 23 | continue in |
| 24 | } |
| 25 | in= |
| 26 | out=xbbllaahh |
| 27 | EOF |
| 28 | |
| 29 | #------------------------------------------------------------------------------ |
| 30 | |
| 31 | tst "substitutions: named continue to inner block" -q x=abc <<EOF |
| 32 | !-s |
| 33 | z = x |
| 34 | x = (?)(*) { |
| 35 | x = \$2 |
| 36 | y = \$x |
| 37 | y = (*)(?) { |
| 38 | z = \$z\$y\$2 |
| 39 | y = \$1 |
| 40 | continue y |
| 41 | } |
| 42 | } |
| 43 | EOF |
| 44 | |
| 45 | expect <<EOF |
| 46 | z=xbccbb |
| 47 | x=bc |
| 48 | y= |
| 49 | EOF |
| 50 | |
| 51 | #------------------------------------------------------------------------------ |
| 52 | |
| 53 | tst "substitutions: named continue to outer block" -q x=abc <<EOF |
| 54 | !-s |
| 55 | z = x |
| 56 | x = (?)(*) { |
| 57 | x = \$2 |
| 58 | y = \$x |
| 59 | y = (*)(?) { |
| 60 | z = \$z\$y\$2 |
| 61 | y = \$1 |
| 62 | continue x |
| 63 | } |
| 64 | } |
| 65 | EOF |
| 66 | |
| 67 | expect <<EOF |
| 68 | z=xbcccc |
| 69 | x= |
| 70 | y= |
| 71 | EOF |
| 72 | |
| 73 | #------------------------------------------------------------------------------ |
| 74 | |
| 75 | tst "substitutions: continue to \$" -ds -q <<EOF |
| 76 | !-s |
| 77 | in = blah |
| 78 | out = x |
| 79 | in = ?(*) { |
| 80 | in = \$1 |
| 81 | out = \${out}+ |
| 82 | continue \$ |
| 83 | } |
| 84 | EOF |
| 85 | |
| 86 | expect <<EOF |
| 87 | in=blah |
| 88 | out=x |
| 89 | in=RE { |
| 90 | in=\$1 |
| 91 | out=\${out}+ |
| 92 | continue in |
| 93 | } |
| 94 | in= |
| 95 | out=x++++ |
| 96 | EOF |
| 97 | |
| 98 | #------------------------------------------------------------------------------ |
| 99 | |
| 100 | tst_fail "substitutions: unnamed continue inside block" <<EOF |
| 101 | !-s |
| 102 | foo = * { |
| 103 | continue |
| 104 | bar = x |
| 105 | } |
| 106 | EOF |
| 107 | |
| 108 | expect <<EOF |
| 109 | s:3: syntax error |
| 110 | EOF |
| 111 | |
| 112 | #------------------------------------------------------------------------------ |
| 113 | |
| 114 | tst_fail "substitutions: named continue inside block" <<EOF |
| 115 | !-s |
| 116 | foo = * { |
| 117 | continue foo |
| 118 | bar = x |
| 119 | } |
| 120 | EOF |
| 121 | |
| 122 | expect <<EOF |
| 123 | s:4: unreachable code |
| 124 | EOF |
| 125 | |
| 126 | #------------------------------------------------------------------------------ |
| 127 | |
| 128 | tst_fail "substitutions: named continue to unknown block" -q <<EOF |
| 129 | !-s |
| 130 | x = foo |
| 131 | x = * { |
| 132 | y = \$x |
| 133 | y = * { |
| 134 | continue z |
| 135 | } |
| 136 | } |
| 137 | EOF |
| 138 | |
| 139 | expect <<EOF |
| 140 | s:8: cannot find "z" |
| 141 | EOF |
| 142 | |
| 143 | #------------------------------------------------------------------------------ |
| 144 | |
| 145 | tst_fail "substitutions: continue without block" -q <<EOF |
| 146 | !-s |
| 147 | continue |
| 148 | EOF |
| 149 | |
| 150 | expect <<EOF |
| 151 | s:2: jump without block |
| 152 | EOF |
| 153 | |
| 154 | ############################################################################### |
| 155 |
Branches:
master
