3 |
# Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com> |
# Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com> |
4 |
# Licensed under GPL v2, see file LICENSE for details. |
# Licensed under GPL v2, see file LICENSE for details. |
5 |
|
|
6 |
. testing.sh |
. ./testing.sh |
7 |
|
|
8 |
# testing "description" "command" "result" "infile" "stdin" |
# testing "description" "command" "result" "infile" "stdin" |
9 |
|
|
22 |
testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n" |
testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n" |
23 |
testing "awk oct const" "awk '{ print or(01234,1) }'" "669\n" "" "\n" |
testing "awk oct const" "awk '{ print or(01234,1) }'" "669\n" "" "\n" |
24 |
|
|
25 |
|
# long field seps requiring regex |
26 |
|
testing "awk long field sep" "awk -F-- '{ print NF, length(\$NF), \$NF }'" \ |
27 |
|
"2 0 \n3 0 \n4 0 \n5 0 \n" \ |
28 |
|
"" \ |
29 |
|
"a--\na--b--\na--b--c--\na--b--c--d--" |
30 |
|
|
31 |
|
# '@(samp|code|file)\{' is an invalid extended regex (unmatched '{'), |
32 |
|
# but gawk 3.1.5 does not bail out on it. |
33 |
|
testing "awk gsub falls back to non-extended-regex" \ |
34 |
|
"awk 'gsub(\"@(samp|code|file)\{\",\"\");'; echo \$?" "0\n" "" "Hi\n" |
35 |
|
|
36 |
tar xjf awk_t1.tar.bz2 |
tar xjf awk_t1.tar.bz2 |
37 |
testing "awk 'gcc build bug'" \ |
testing "awk 'gcc build bug'" \ |
38 |
"awk -f awk_t1_opt-functions.awk -f awk_t1_opth-gen.awk <awk_t1_input | md5sum" \ |
"awk -f awk_t1_opt-functions.awk -f awk_t1_opth-gen.awk <awk_t1_input | md5sum" \ |
40 |
"" "" |
"" "" |
41 |
rm -rf awk_t1_* |
rm -rf awk_t1_* |
42 |
|
|
43 |
|
Q='":"' |
44 |
|
|
45 |
|
testing "awk NF in BEGIN" \ |
46 |
|
"awk 'BEGIN { print ${Q} NF ${Q} \$0 ${Q} \$1 ${Q} \$2 ${Q} }'" \ |
47 |
|
":0::::\n" \ |
48 |
|
"" "" |
49 |
|
|
50 |
|
prg=' |
51 |
|
function b(tmp) { |
52 |
|
tmp = 0; |
53 |
|
print "" tmp; #this line causes the bug |
54 |
|
return tmp; |
55 |
|
} |
56 |
|
function c(tmpc) { |
57 |
|
tmpc = b(); return tmpc; |
58 |
|
} |
59 |
|
BEGIN { |
60 |
|
print (c() ? "string" : "number"); |
61 |
|
}' |
62 |
|
testing "awk string cast (bug 725)" \ |
63 |
|
"awk '$prg'" \ |
64 |
|
"0\nnumber\n" \ |
65 |
|
"" "" |
66 |
|
|
67 |
exit $FAILCOUNT |
exit $FAILCOUNT |