From 6f4a785bd1bd0e6973b5c27b34b86655b1d7a602 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 7 Jan 2018 01:19:08 +0100 Subject: awk: fix 'delete array[var--]' decrementing var twice function old new delta evaluate 3395 3390 -5 Signed-off-by: Denys Vlasenko --- testsuite/awk.tests | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'testsuite') diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 82937bc..ad0583a 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -261,6 +261,25 @@ end d " \ "" "" +prg=' +BEGIN{ +cnt = 0 +a[cnt] = "zeroth" +a[++cnt] = "first" +delete a[cnt--] +print cnt +print "[0]:" a[0] +print "[1]:" a[1] +}' +testing "awk 'delete a[v--]' evaluates v-- once" \ + "awk '$prg'" \ + "\ +0 +[0]:zeroth +[1]: +" \ + "" "" + testing "awk handles empty ()" \ "awk 'BEGIN {print()}' 2>&1" "awk: cmd. line:1: Empty sequence\n" "" "" -- cgit v1.1