sed: fix a buglet in s///NUM handling
[oweals/busybox.git] / testsuite / awk.tests
index a02302405ec5fcc7f09eda93fd598c28c4862103..9e6952ffd3c39fc5b300b984109470c4a079324b 100755 (executable)
@@ -269,16 +269,48 @@ testing "awk FS assignment" "awk '{FS=\":\"; print \$1}'" \
        "" \
        "a:b c:d\ne:f g:h"
 
+optional FEATURE_AWK_LIBM
 testing "awk large integer" \
        "awk 'BEGIN{n=(2^31)-1; print n, int(n), n%1, ++n, int(n), n%1}'" \
        "2147483647 2147483647 0 2147483648 2147483648 0\n" \
        "" ""
+SKIP=
 
 testing "awk length(array)" \
-       "awk 'BEGIN{ A[1]=2; A["qwe"]="asd"; print length(A)}'" \
+       "awk 'BEGIN{ A[1]=2; A[\"qwe\"]=\"asd\"; print length(A)}'" \
        "2\n" \
        "" ""
 
+testing "awk -f and ARGC" \
+       "awk -f - input" \
+       "re\n2\n" \
+       "do re mi\n" \
+       '{print $2; print ARGC;}' \
+
+optional FEATURE_AWK_GNU_EXTENSIONS
+testing "awk -e and ARGC" \
+       "awk -e '{print \$2; print ARGC;}' input" \
+       "re\n2\n" \
+       "do re mi\n" \
+       ""
+SKIP=
+
+# The examples are in fact not valid awk programs (break/continue
+# can only be used inside loops).
+# But we do accept them outside of loops.
+# We had a bug with misparsing "break ; else" sequence.
+# Test that *that* bug is fixed, using simplest possible scripts:
+testing "awk break" \
+       "awk -f - 2>&1; echo \$?" \
+       "0\n" \
+       "" \
+       'BEGIN { if (1) break; else a = 1 }'
+testing "awk continue" \
+       "awk -f - 2>&1; echo \$?" \
+       "0\n" \
+       "" \
+       'BEGIN { if (1) continue; else a = 1 }'
+
 # testing "description" "command" "result" "infile" "stdin"
 
 exit $FAILCOUNT