aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-02-02 23:28:55 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-02-02 23:28:55 +0100
commitbd8b05ba1b0901bbd6a913dfd5186ac7c8beffed (patch)
treed4989ed16d4824dc8925042bce8c426bd499df2f /testsuite
parent9e2a5668fd38db169d9d91b13089a99df4c9bd37 (diff)
downloadbusybox-bd8b05ba1b0901bbd6a913dfd5186ac7c8beffed.tar.gz
awk: fix more "length" cases, closes 12486
function old new delta next_token 808 831 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/awk.tests23
1 files changed, 22 insertions, 1 deletions
diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index a7a533ba0..b5008290f 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -85,7 +85,8 @@ testing "awk floating const with leading zeroes" \
"" "\n"
# long field seps requiring regex
-testing "awk long field sep" "awk -F-- '{ print NF, length(\$NF), \$NF }'" \
+testing "awk long field sep" \
+ "awk -F-- '{ print NF, length(\$NF), \$NF }'" \
"2 0 \n3 0 \n4 0 \n5 0 \n" \
"" \
"a--\na--b--\na--b--c--\na--b--c--d--"
@@ -317,6 +318,26 @@ testing "awk length()" \
"3\n3\n3\n3\n" \
"" "qwe"
+testing "awk print length, 1" \
+ "awk '{ print length, 1 }'" \
+ "0 1\n" \
+ "" "\n"
+
+testing "awk print length 1" \
+ "awk '{ print length 1 }'" \
+ "01\n" \
+ "" "\n"
+
+testing "awk length == 0" \
+ "awk 'length == 0 { print \"foo\" }'" \
+ "foo\n" \
+ "" "\n"
+
+testing "awk if (length == 0)" \
+ "awk '{ if (length == 0) { print \"bar\" } }'" \
+ "bar\n" \
+ "" "\n"
+
testing "awk -f and ARGC" \
"awk -f - input" \
"re\n2\n" \