diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-07 01:19:08 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-07 01:19:08 +0100 |
commit | 6f4a785bd1bd0e6973b5c27b34b86655b1d7a602 (patch) | |
tree | f7c5acf0f2f844883e5e183b45d85ba0ee5471df /testsuite | |
parent | 7367a949a6a81d71d524f0635a212371120df4e0 (diff) | |
download | busybox-w32-6f4a785bd1bd0e6973b5c27b34b86655b1d7a602.tar.gz busybox-w32-6f4a785bd1bd0e6973b5c27b34b86655b1d7a602.tar.bz2 busybox-w32-6f4a785bd1bd0e6973b5c27b34b86655b1d7a602.zip |
awk: fix 'delete array[var--]' decrementing var twice
function old new delta
evaluate 3395 3390 -5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/awk.tests | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 82937bc10..ad0583afb 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -261,6 +261,25 @@ end d | |||
261 | " \ | 261 | " \ |
262 | "" "" | 262 | "" "" |
263 | 263 | ||
264 | prg=' | ||
265 | BEGIN{ | ||
266 | cnt = 0 | ||
267 | a[cnt] = "zeroth" | ||
268 | a[++cnt] = "first" | ||
269 | delete a[cnt--] | ||
270 | print cnt | ||
271 | print "[0]:" a[0] | ||
272 | print "[1]:" a[1] | ||
273 | }' | ||
274 | testing "awk 'delete a[v--]' evaluates v-- once" \ | ||
275 | "awk '$prg'" \ | ||
276 | "\ | ||
277 | 0 | ||
278 | [0]:zeroth | ||
279 | [1]: | ||
280 | " \ | ||
281 | "" "" | ||
282 | |||
264 | testing "awk handles empty ()" \ | 283 | testing "awk handles empty ()" \ |
265 | "awk 'BEGIN {print()}' 2>&1" "awk: cmd. line:1: Empty sequence\n" "" "" | 284 | "awk 'BEGIN {print()}' 2>&1" "awk: cmd. line:1: Empty sequence\n" "" "" |
266 | 285 | ||