restructured regression test scripts for awk

This commit is contained in:
hyung-hwan 2009-06-30 04:17:39 +00:00
parent 14b0bca55c
commit e78de0f959
165 changed files with 203 additions and 1637 deletions

View File

@ -1,12 +0,0 @@
BEGIN {
RS = "\n\n";
FS = "\n";
}
{
print $1,$NF;
}
James Brown 012-345-678
Richie Ren 02-3473-9192
Toh WeeKung 9102-1203

View File

@ -1,18 +0,0 @@
BEGIN {
a[1,2,3] = 20;
a[4,5,6] = 30;
for (i in a)
{
n = split (i, k, SUBSEP);
for (j = 1; j < n; j++)
{
print k[j]
}
}
if ((1,2,3) in a)
{
print a[1,2,3];
}
}

View File

@ -1 +0,0 @@
BEGIN { CONVFMT="%s"; printf ("%s\n", 10.34); }

View File

@ -1,23 +0,0 @@
function a()
{
print "aaaa";
a();
}
BEGIN {
a = (b = 20);
print a; print b; for(i=j=1; i< 10; i++) print i, j;
a += b += 20;
print a; print b; for(i=j=1; i< 10; i++) print i, j;
j = (a < 20)? k = 20: c = 30;
print (a < 20)? k = 20: c = 30;
print "j=" j;
print "k=" k;
print "c=" c;
a();
}

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [31] LINE [2] invalid character ''

View File

@ -1,3 +0,0 @@
BEGIN {
ARGC = 39;
}

View File

@ -1,4 +0,0 @@
BEGIN {
ARGC = 39;
}

View File

@ -1,6 +0,0 @@
BEGIN {
abc[20] = "abc";
abc = 10;
}
RUN ERROR: CODE [99] LINE [3] map 'abc' not assignable with a scalar

View File

@ -1,3 +0,0 @@
BEGIN {
delete ARGC;
}

View File

@ -1,5 +0,0 @@
BEGIN {
delete ARGC;
}
RUN ERROR: CODE [91] LINE [2] variable 'ARGC' not deletable

View File

@ -1,6 +0,0 @@
BEGIN {
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix = 20;
delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix;
}
RUN ERROR: CODE [91] LINE [3] variable 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...' not deletable

View File

@ -1,3 +0,0 @@
BEGIN {
helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhelphelp ();
}

View File

@ -1,5 +0,0 @@
BEGIN {
helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhelphelp ();
}
RUN ERROR: CODE [89] LINE [2] function 'helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhel...' not found

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [58] LINE [2] intrinsic function 'substr' redefined

View File

@ -1,6 +0,0 @@
BEGIN {
local substr;
substr = 20;
}

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [58] LINE [3] intrinsic function 'substr' redefined

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [53] LINE [13] 'abc' not a valid function name

View File

@ -1,15 +0,0 @@
global abc;
function abc ()
{
local abc;
abc = 20;
print abc;
abc ();
}
BEGIN {
abc ();
}

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [60] LINE [4] global variable 'abc' redefined

View File

@ -1,13 +0,0 @@
function abc (x)
{
local x;
x = 20;
print x;
abc ();
}
BEGIN {
abc ();
}

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [61] LINE [4] parameter 'x' redefined

View File

@ -1,14 +0,0 @@
function abc ()
{
local j ;
j = 20;
print j;
abc ();
}
global abc;
BEGIN {
abc ();
}

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [59] LINE [11] function 'abc' redefined

View File

@ -1,4 +0,0 @@
function abc (abc)
{
abc (); # invalid as abc is the parameter in this context
}

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [53] LINE [3] 'abc' not a valid function name

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [44] LINE [5] a colon expected in place of ';'

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [39] LINE [2] a left parenthesis expected in place of '='

View File

@ -1,5 +0,0 @@
BEGIN
{
print "hello world";
}

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [54] LINE [2] BEGIN not followed by a left bracket on the same line

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [66] LINE [1] '+' not a valid parameter name

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [67] LINE [1] '+' not a valid variable name

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [67] LINE [3] '+' not a valid variable name

View File

@ -1,4 +0,0 @@
BEGIN {
print abc > "123\0abc";
}

View File

@ -1,5 +0,0 @@
BEGIN {
print abc > "123\0abc";
}
RUN ERROR: CODE [115] LINE [2] i/o name containing a null character

View File

@ -1,4 +0,0 @@
BEGIN {
xx = 20;
split ("a b c", xx);
}

View File

@ -1,6 +0,0 @@
BEGIN {
xx = 20;
split ("a b c",xx);
}
RUN ERROR: CODE [100] LINE [3] cannot change a scalar value to a map

View File

@ -1 +0,0 @@
PARSE ERROR: CODE [64] LINE [1] duplicate global variable 'ARGV'

View File

@ -1,2 +0,0 @@
data 1
data 2

View File

@ -1,8 +0,0 @@
{
if (data[$0]++ == 0) lines[++count] = $0;
}
END {
for (i = 1; i <= count; i++) print lines[i];
}

View File

@ -1,7 +0,0 @@
{
i = 1;
while (i <= $3) {
printf ("\t%.2f\n", $1*(1+$2)**i);
i = i + 1;
}
}

View File

@ -1,4 +0,0 @@
{
for (i = 1; i <= $3; i=i+1)
printf ("\t%.2f\n", $1*(1+$2)**i);
}

View File

@ -1,5 +0,0 @@
function main() {
x = 0;
y = 0;
return 999;
}

View File

@ -1,7 +0,0 @@
function main ()
{
x = 0;
y = 0;
return 999;
}

View File

@ -1,42 +0,0 @@
function error ()
{
exit 200;
}
function getx ()
{
if ((x == 2))
error ();
return (x)++;
}
function gety ()
{
return (y)++;
}
function main ()
{
x = 0;
y = 0;
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
return 999;
}
END {
print "END OF PROGRAM";
return 10;
}
END {
print "END OF PROGRAM 2";
exit 100;
}
END {
print "END OF PROGRAM 3";
exit 900;
}
0
2

View File

@ -1,43 +0,0 @@
BEGIN {
print 3**2;
print -3**2;
print (-3)**2;
print 3**2**3**2;
print -3**2**-3**2;
print (-3)**2**(-3)**2;
print 3**-2**3**-2;;
print -2 ** 3;
print -2 ** -3;
print 0 ** 0;
print 0 ** 1;
#print 0 ** -1;
print -1 ** 4;
print -1 ** 5;
print "-------------------";
print 3.0 ** 2;
print 3.0 ** -2;
print -2.0 ** 3;
print -2.0 ** -3;
print 0.0 ** 0;
print 0.0 ** 1;
#print 0.0 ** -1;
print -1.0 ** 4;
print -1.0 ** 5;
print -2.12 ** 3;
print 2.12 ** -3;
print -12.12 ** 3;
print 12.12 ** -3;
print 0.000000001 ** 30;
print 0.000000002 ** 30;
print 0.000000000000000000000000000000000000000000000000000000001 ** 30;
print 0.000000000000000000000000000000000000000000000000000000002 ** 30;
print "-------------------";
}

View File

@ -1,244 +0,0 @@
#!/bin/sh
OPTION="-explicit -implicit"
run_script_for_init()
{
script="$1"
data="$2"
output=`echo $script | sed 's/\.awk$/.out/g'`
"$ASEAWK" $OPTION -d -f "$script" "$data" > "$output"
}
run_script_for_init_nodata()
{
script="$1"
output=`echo $script | sed 's/\.awk$/.out/g'`
"$ASEAWK" $OPTION -d -f "$script" > "$output"
}
run_script_for_init_main()
{
script="$1"
output=`echo $script | sed 's/\.awk$/.out/g'`
"$ASEAWK" $OPTION -m main -d -f "$script" > "$output"
}
run_init()
{
for script in simple-???.awk
do
run_script_for_init_nodata "$script"
done
for script in main-???.awk
do
run_script_for_init_main "$script"
done
for script in cou-???.awk
do
run_script_for_init "$script" "cou-en.data"
done
for script in adr-???.awk
do
run_script_for_init "$script" "adr-en.data"
done
for script in err-???.awk
do
run_script_for_init "$script" "err-en.data"
done
}
run_script_for_test()
{
script="$1"
data="$2"
output=`echo $script | sed 's/\.awk$/.out/g'`
echo ">> RUNNING $script"
"$ASEAWK" $OPTION -d -f "$script" "$data" > "$output.$pid"
#diff -y "$output" "$output.$pid"
diff "$output" "$output.$pid"
if [ $? -ne 0 ]
then
rm -f "$output.$pid"
return 1
fi
rm -f "$output.$pid"
return 0
}
run_script_for_test_nodata()
{
script="$1"
output=`echo $script | sed 's/\.awk$/.out/g'`
echo ">> RUNNING $script"
"$ASEAWK" $OPTION -d -f "$script" > "$output.$pid"
#diff -y "$output" "$output.$pid"
diff "$output" "$output.$pid"
if [ $? -ne 0 ]
then
rm -f "$output.$pid"
return 1
fi
rm -f "$output.$pid"
return 0
}
run_script_for_test_main()
{
script="$1"
output=`echo $script | sed 's/\.awk$/.out/g'`
echo ">> RUNNING $script"
"$ASEAWK" $OPTION -m main -d -f "$script" > "$output.$pid"
#diff -y "$output" "$output.$pid"
diff "$output" "$output.$pid"
if [ $? -ne 0 ]
then
rm -f "$output.$pid"
return 1
fi
rm -f "$output.$pid"
return 0
}
run_test()
{
pid=$$
for script in simple-???.awk
do
run_script_for_test_nodata "$script"
[ $? -ne 0 ] && {
echo "###################################"
echo "PROBLEM(S) DETECTED IN $script.".
echo "###################################"
echo "Do you want to abort? [y/n]"
read ans
[ "$ans" = "y" -o "$ans" = "Y" ] && return 1
}
done
for script in main-???.awk
do
run_script_for_test_main "$script"
[ $? -ne 0 ] && {
echo "###################################"
echo "PROBLEM(S) DETECTED IN $script.".
echo "###################################"
echo "Do you want to abort? [y/n]"
read ans
[ "$ans" = "y" -o "$ans" = "Y" ] && return 1
}
done
for script in cou-???.awk
do
run_script_for_test "$script" "cou-en.data"
[ $? -ne 0 ] && {
echo "###################################"
echo "PROBLEM(S) DETECTED IN $script.".
echo "###################################"
echo "Do you want to abort? [y/n]"
read ans
[ "$ans" = "y" -o "$ans" = "Y" ] && return 1
}
done
for script in adr-???.awk
do
run_script_for_test "$script" "adr-en.data"
if [ $? -ne 0 ]
then
echo "###################################"
echo "PROBLEM(S) DETECTED IN $script.".
echo "###################################"
echo "Do you want to abort? [y/n]"
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ]
then
return 1
fi
fi
done
for script in err-???.awk
do
run_script_for_test "$script" "err-en.data"
if [ $? -ne 0 ]
then
echo "###################################"
echo "PROBLEM(S) DETECTED IN $script.".
echo "###################################"
echo "Do you want to abort? [y/n]"
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ]
then
return 1
fi
fi
done
return 0
}
print_usage()
{
echo "Usage: $0 init"
echo " $0 test"
}
#--------#
# main #
#--------#
if [ -x ./aseawk ]
then
ASEAWK="./aseawk"
elif [ -x ../../release/bin/aseawk ]
then
ASEAWK="../../release/bin/aseawk"
elif [ -x ../../debug/bin/aseawk ]
then
ASEAWK="../../debug/bin/aseawk"
else
echo "Error: cannot locate a relevant awk interpreter"
exit 1;
fi
[ $# -ne 1 ] && {
print_usage "$0"
exit 1
}
if [ "$1" = "init" ]
then
run_init
elif [ "$1" = "test" ]
then
run_test
else
print_usage "$0"
exit 1
fi
exit 0

View File

@ -1,18 +0,0 @@
function error() { exit (200); }
function getx()
{
if (x == 2) error();
return x++;
}
function gety() { return y++; }
BEGIN {
x = 0;
y = 0;
print getx() + gety();
print getx() + gety();
print getx() + gety();
print getx() + gety();
}

View File

@ -1,28 +0,0 @@
function error ()
{
exit 200;
}
function getx ()
{
if ((x == 2))
error ();
return (x)++;
}
function gety ()
{
return (y)++;
}
BEGIN {
x = 0;
y = 0;
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
}
0
2

View File

@ -1,24 +0,0 @@
function error() { exit (200); }
function getx()
{
if (x == 2) error();
return x++;
}
function gety() { return y++; }
BEGIN {
x = 0;
y = 0;
print getx() + gety();
print getx() + gety();
print getx() + gety();
print getx() + gety();
}
END {
print "END OF PROGRAM";
}

View File

@ -1,32 +0,0 @@
function error ()
{
exit 200;
}
function getx ()
{
if ((x == 2))
error ();
return (x)++;
}
function gety ()
{
return (y)++;
}
BEGIN {
x = 0;
y = 0;
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
}
END {
print "END OF PROGRAM";
}
0
2
END OF PROGRAM

View File

@ -1,25 +0,0 @@
function error() { exit (200); }
function getx()
{
if (x == 2) error();
return x++;
}
function gety() { return y++; }
BEGIN {
x = 0;
y = 0;
print getx() + gety();
print getx() + gety();
print getx() + gety();
print getx() + gety();
}
END {
print "END OF PROGRAM";
exit (20);
}

View File

@ -1,33 +0,0 @@
function error ()
{
exit 200;
}
function getx ()
{
if ((x == 2))
error ();
return (x)++;
}
function gety ()
{
return (y)++;
}
BEGIN {
x = 0;
y = 0;
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
}
END {
print "END OF PROGRAM";
exit 20;
}
0
2
END OF PROGRAM

View File

@ -1,28 +0,0 @@
function error() { exit (200); }
function getx()
{
if (x == 2) error();
return x++;
}
function gety() { return y++; }
BEGIN {
x = 0;
y = 0;
print getx() + gety();
print getx() + gety();
print getx() + gety();
print getx() + gety();
}
END {
print "END OF PROGRAM";
exit (20);
}
END {
print "END OF PROGRAM 2";
}

View File

@ -1,36 +0,0 @@
function error ()
{
exit 200;
}
function getx ()
{
if ((x == 2))
error ();
return (x)++;
}
function gety ()
{
return (y)++;
}
BEGIN {
x = 0;
y = 0;
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
}
END {
print "END OF PROGRAM";
exit 20;
}
END {
print "END OF PROGRAM 2";
}
0
2
END OF PROGRAM

View File

@ -1,29 +0,0 @@
function error() { exit (200); }
function getx()
{
if (x == 2) error();
return x++;
}
function gety() { return y++; }
BEGIN {
x = 0;
y = 0;
print getx() + gety();
print getx() + gety();
print getx() + gety();
print getx() + gety();
}
END {
print "END OF PROGRAM";
return 10;
}
END {
print "END OF PROGRAM 2";
return 20;
}

View File

@ -1,38 +0,0 @@
function error ()
{
exit 200;
}
function getx ()
{
if ((x == 2))
error ();
return (x)++;
}
function gety ()
{
return (y)++;
}
BEGIN {
x = 0;
y = 0;
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
}
END {
print "END OF PROGRAM";
return 10;
}
END {
print "END OF PROGRAM 2";
return 20;
}
0
2
END OF PROGRAM
END OF PROGRAM 2

View File

@ -1,34 +0,0 @@
function error() { exit (200); }
function getx()
{
if (x == 2) error();
return x++;
}
function gety() { return y++; }
BEGIN {
x = 0;
y = 0;
print getx() + gety();
print getx() + gety();
print getx() + gety();
print getx() + gety();
}
END {
print "END OF PROGRAM";
return 10;
}
END {
print "END OF PROGRAM 2";
exit (100);
}
END {
print "END OF PROGRAM 3";
exit (900);
}

View File

@ -1,42 +0,0 @@
function error ()
{
exit 200;
}
function getx ()
{
if ((x == 2))
error ();
return (x)++;
}
function gety ()
{
return (y)++;
}
BEGIN {
x = 0;
y = 0;
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
print (getx () + gety ());
}
END {
print "END OF PROGRAM";
return 10;
}
END {
print "END OF PROGRAM 2";
exit 100;
}
END {
print "END OF PROGRAM 3";
exit 900;
}
0
2
END OF PROGRAM
END OF PROGRAM 2

View File

@ -1,21 +0,0 @@
function sum(i, k, y)
{
y = 0;
for (k = i; k; k = k - 1)
{
y = y + k;
}
return y;
y = 10;
return y;
}
BEGIN {
/*s = sum(10000000);*/
s = sum (100);
print s;
return s;
}

View File

@ -1,25 +0,0 @@
BEGIN {
print "more";
#print | "more";
#print > "echo";
#print >> "echo";
getline x < "abc"; /* open("abc", O_RDONLY|O_LARGEFILE) = 3 */
#print 10 >> "abc"; /* open("abc", O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE, 0666) = 4 */
getline x < "abc";
#print x;
a = close ("abc"); /* close(4) */
print "a=" a;
#print "hey"
b = close ("abc"); /* close(3) */
print "b=" b;
getline x < "Makefile.cl";
getline y < "awk.c";
print x;
print y;
c = close ("Makefile.cl");
d = close ("awk.c");
}

View File

@ -1,17 +0,0 @@
BEGIN {
print "this is only a test";
print;
print 1, 2, (3 >> 10);
print 1, 2, 3 >> 10;
print 3, 4, 5 >> 10;
close (10);
print "-------------" >> 10;
delete abc;
delete abc["aaaa"] ;
/*
print 1 > 2 + 3;
print 1 < 2 + 3;
*/
}

View File

@ -1,38 +0,0 @@
BEGIN {
/*
print "line 1" >> "1";
print "line 2" > "1";
print "line 3" >> "1";
print "line 4" >> "2";
print "line 4" >> "3";
print "line 4" >> "4";
while ((getline x < "abc") > 0) print x;
close ("abc");
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
getline x < "abc";
if (x == "a") print "xxxxxxxxxxxxxxxx"; else print x;
*/
/*
print getline x;
print "[", x, "]";
print "--------------";
*/
if (getline x < "abc" == -1)
{
print "ERRNO = ", ERRNO;
}
print x > "def";
#print "fflush(def) = ", fflush ("def");
print "fflush() = ", fflush ("");
# print (1 (2 getline j) j);
# print "abc" 1 + 2 3 + 49 2 / 3;
}

View File

@ -1,22 +0,0 @@
global a;
BEGIN {
local b;
#a = 20;
#a[1] = 20;
#a[2] = 30;
/*
b["xxx"] = 20;
b["yyy"] = 30;
b[1] = 30;
b["2"] = 30;
delete a;
delete b["1"];
*/
c[1] = 20;
c[1] = "aaa";
c = 30;
}

View File

@ -1,28 +0,0 @@
global x, y;
BEGIN { FS="A"; }
{
print "NF = " NF;
for (i = 0; i < 10; i++)
{
print $i;
if (i == 3) a = $i;
}
$1 = 100;
/*$1 = $2;
$3 = $2;
$2 = $2;*/
/*OFS["1234"]=":";*/
$20 = 10;
print $0;
print "--------------------";
print "NF ===>>> " NF;
print "====================";
}
END { fflush (); system ("dir /w/p"); print sin(270); }

View File

@ -1,16 +0,0 @@
BEGIN {
local a, b;
a = 12;
b = "<" a ">";
print b;
print ("\x5C");
print ("\x5C6_ABCDEGH");
print ("\xZZ5C6_ABCDEGH");
print ("\xZZ5C6_AB\u7658&&");
print "\uC720\uB2C8\uCF54\uB4DC \uD14C\uC2A4\uD2B8";
print "\UC720\UB2C8\UCF54\UB4DC \UD14C\UC2A4\UD2B8";
}

View File

@ -1 +0,0 @@
{ /*$0=" "; */ print NF; print "a" $0 "b"; x = $1; }

View File

@ -1,18 +0,0 @@
/hello[[:space:]]/ {
print $0;
print "INTERNAL LOOP NF=" NF;
for (i = 0; i < NF; i++)
{
print "[" $(i+1) "]";
}
#getline a;
#print a;
if (getline > 0) print $0;
print "GETLINE NF=" NF;
for (i = 0; i < NF; i++)
{
print "[" $(i+1) "]";
}
print "----------------";
}

View File

@ -1,21 +0,0 @@
BEGIN {
print "0. FILENAME=", FILENAME, "FNR=", FNR;
}
/hello/ {
print "1. FILENAME=", FILENAME, "FNR=", FNR;
print "[" $0 "]";
#nextfile;
print "----------------";
}
/hello/ {
print "2. FILENAME=", FILENAME, "FNR=", FNR;
print "[" $0 "]";
nextfile;
print "----------------";
}
END {
print "== END OF PROGRAM ==";
}

View File

@ -1,4 +0,0 @@
//BEGIN { nlines="-0.345"; }
{ nlines++; }
END { print nlines; }

View File

@ -1,24 +0,0 @@
global z, x;
function sum (i)
{
local k, y;
y = 0;
for (k = i; k; k = k - 1)
{
y = y + k;
}
return y;
y = 10;
return y;
}
END {
/*x = sum (10000000);
*/
x = sum (100);
s = x;
ss = z;
}

View File

@ -1,8 +0,0 @@
//"abc" != "def" {
/a\/b/ {
print $0 ~ /abc/;
print $0 !~ /abc/;
print $0 ~ "abc[[:space:]]";
print $0 !~ "abc";
print /abc/;
}

View File

@ -1,8 +0,0 @@
BEGIN { exit 10; }
{
print $0;
#print close ("");
}
END { print "== END OF PROGRAM =="; }

View File

@ -1,15 +0,0 @@
//BEGIN { exit 10; }
//{ while (1) {if (x == 20) continue; if (a) break; while (10) break; }}
//END { while (1) {if (x == 20) continue; if (a) break; while (10) break; }}
{
//return 20;
print getline abc < "";
print "[[" abc "]]";
print close("");
//exit 20;
}
END { print "end"; }

View File

@ -1,19 +0,0 @@
/*
{
print "ALL ==> " $0;
}
/1/,/5/
{
print "/1/,/5/ ==> " $0;
}
*/
BEGIN { c["Europe"] = "XXX"; }
/Europe/, /Africa/ { print $0; }
//(a = "20") { }
/*"Europe" in c { print $0; }*/

View File

@ -1,6 +0,0 @@
BEGIN {
a["abc\0\0xxx"] = "abcdefg";
print a["abc"];
print a["abc\0\0xxx"];
}

View File

@ -1,13 +0,0 @@
/Europe/, /Africa/
1
2
3 % 23
/zab/ { print "XXXX"; }
{
print /ABC/ ~ /DEF/;
}
/zzz/

View File

@ -1,13 +0,0 @@
function call_next ()
{
next;
}
BEGIN {
#call_next ();
}
END {
call_next ();
}

View File

@ -1,6 +0,0 @@
global a, b, c;
BEGIN { while (1) while(1) while (1) a = 20; }
END { while (1) while(1) while (1) ; }

View File

@ -1,41 +0,0 @@
#global xyz;
END {
#local xyz;
print index ("abc", "abc");
print index ("abc", "b");
print index ("abc", "kabc");
print "----------------------------";
print substr ("abc", "abcdefg", 5);
print substr ("abc", -1, 5);
print substr ("abc", 0, 5);
print substr ("abc", 1, 5);
print substr ("abc", 2.829, 5);
print substr ("abc", "3", 5);
print substr ("abc", 4, 5);
/*
a[1] = 20;
substr (a, 3, 4);
*/
print tolower ("AbcDEF");
print toupper ("AbcDEF");
arr[0] = "xxx";
#print split ("abc def abc", arr);
print split ("abc def kkk", j);
print split ("abc def kkk", $0); # error
#xyz = 20;
#print xyz;
print split ("abc def kkk", ((xyz)));
#for (i in arr)
for (i in xyz)
{
print i, " ", xyz[i];
}
}

View File

@ -1,3 +0,0 @@
{ print $0; }
//{ gsub ("abc", "&&&&"); print $0; }

View File

@ -1,25 +0,0 @@
#global x, j;
function func1 (x)
{
c = x["abc"];
x["abc"] = 123;
}
BEGIN {
idx="abc";
x[idx] = 12345;
i = x[idx];
x["1"] = 1;
x["2"] = 2;
func1 (x);
k = x[idx];
return j;
/*
x["abc"] = 12345;
i = x["abc"];
return j;
*/
}

View File

@ -1,3 +0,0 @@
#{ "dir/w/p" | getline; print $0; print "flush(dir/w/p)=", fflush("dir/w/p"); }
#{ print | "grep Asia"; fflush("grep Asia"); }
{ print | "grep Asia"; print "flush(grep Asia)=", fflush("grep Asia"); }

View File

@ -1,2 +0,0 @@
BEGIN { RS=""; }
{ print $0; }

View File

@ -1,2 +0,0 @@
BEGIN { /*RS = "Asia";*/ /*RS=746;*/ /*RS="";*/ RS=/USA/; }
{ print NR, " ", $0; }

View File

@ -1,15 +0,0 @@
BEGIN {
ARGV[1] = 20;
print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
delete NF;
print "NF[1]=", NF[1];
NF[1] = 20; # this line should not be allowed
print "AWK IMPLEMENTATION ERROR: hey... NF[1] = 20 has succeeded in the BEGIN block. your interpreter must be wrong";
print "NF[1]=", NF[1];
}
{
NF = 30;
}

View File

@ -1 +0,0 @@
/* unterminated comment

View File

@ -1,4 +0,0 @@
BEGIN {
print //;
print / /;
}

View File

@ -1,47 +0,0 @@
# test cases
#
# input data []
# result:
# NF=0
#
# input data [abcdefg]
# NF=2
# 0 []
# 1 [bcdefg]
#
# input data [abdefg abcdefg]
# NF=3
# 0 []
# 1 [bdefg ]
# 2 [bcdefg]
#
# input data [ abcdefg hij a a]
# NF=4
# 0 [ ]
# 1 [bcdefg hij ]
# 2 [ ]
# 3 []
#
# input data [ abcdefg hij a a ]
# NF=4
# 0 [ ]
# 1 [bcdefg hij ]
# 2 [ ]
# 3 [ ]
#
# input data [aaaaa]
# NF=6
# 0 []
# 1 []
# 2 []
# 3 []
# 4 []
# 5 []
#
BEGIN { FS="a"; }
{
print "NF=" NF;
for (i = 0; i < NF; i++) print i " [" $(i+1) "]";
}

View File

@ -1,6 +0,0 @@
BEGIN { FS=" "; }
{
print "NF=" NF;
for (i = 0; i < NF; i++) print i " [" $(i+1) "]";
}

View File

@ -1,9 +0,0 @@
BEGIN {
split (" a b c d e ", x, "");
for (j in x) print j "->" x[j];
print "-------------------";
split ("a b c d e", x, "b c");
for (j in x) print j "->" x[j];
print "-------------------";
}

View File

@ -1,9 +0,0 @@
BEGIN {
FS="[:[:space:]]+";
#FS=":+";
}
{
print "NF=" NF;
for (i = 0; i < NF; i++) print i " [" $(i+1) "]";
}

View File

@ -1,21 +0,0 @@
function main (arg1, arg2, arg3)
{
local i, k, c;
for (i = 0; i < 10; i++)
{
abc[i*2] = i;
}
k = 20;
for (i = 0; i < 100; i++)
{
if (i in abc) j[i] = i;
}
print arg1;
print arg2;
print arg3;
print "end of program";
}

View File

@ -1,8 +0,0 @@
BEGIN {
FS="[a-c]+";
IGNORECASE=0.1;
}
{
print "NF=" NF;
for (i = 0; i < NF; i++) print i " [" $(i+1) "]";
}

View File

@ -1,4 +0,0 @@
BEGIN { IGNORECASE=1; }
$0 == "abc" {
print "[" $0 "]";
}

View File

@ -1,13 +0,0 @@
BEGIN {
FS=":";
OFS="::";
}
{
$2=1.23;
NF=4;
print "NF=" NF;
print "[" $10 "]";
print "$0=[" $0 "]";
}

View File

@ -1,3 +0,0 @@
#BEGIN { t = "abc"; gsub ("abc", "[&]", t); print t; }
{ gsub ("abc", "ABC"); print $0; }
{ gsub (/ABC/, "XYZ"); print $0; }

View File

@ -1,3 +0,0 @@
#BEGIN { t = "abc"; gsub ("abc", "[&]", t); print t; }
{ c=$0; print sub ("abc", "ABC", c); print c; }
{ sub (/ABC/, "XYZ", c); print c; }

View File

@ -1 +0,0 @@
BEGIN { t[1] = "abc"; gsub ("abc", "[&]", t); print t[1]; }

View File

@ -1 +0,0 @@
BEGIN { t = "whoabcabcabcwho"; gsub ("abc", "[\\&][&][\\&]", t); print t; }

View File

@ -1,19 +0,0 @@
BEGIN {
a[1] = 20;
a[2] = 40;
a[3,5,6] = 40;
a["abc"] = 20;
for (i in a) print "a[" i "]=" a[i];
#SUBSEP=",,,";
SUBSEP=4.5;
#SUBSEP=555;
print "------------------------";
a[9,x,3] = 40;
for (i in a) print "a[" i "]=" a[i];
}

Some files were not shown because too many files have changed in this diff Show More