diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:09:58 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:09:58 +0300 |
commit | cae8bc6ced84c12590e3554a06a952283735363a (patch) | |
tree | ca4f38bfcb1312bfb62fc693564d68f3e9b3e973 /test | |
parent | dbd583bd2b8a6dd40c622875a4e197360cb5aba7 (diff) | |
download | egawk-cae8bc6ced84c12590e3554a06a952283735363a.tar.gz egawk-cae8bc6ced84c12590e3554a06a952283735363a.tar.bz2 egawk-cae8bc6ced84c12590e3554a06a952283735363a.zip |
Move to 2.14.
Diffstat (limited to 'test')
87 files changed, 1662 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 00000000..dcf4f15f --- /dev/null +++ b/test/Makefile @@ -0,0 +1,133 @@ +SHELL = /bin/sh + +all: msg swaplns messages argarray longwrds \ + getline inftest fstabplus compare arrayref rs fsrs rand \ + fsbs negexp asgext anchgsub splitargv awkpath nfset reparse + +gawk.extensions: fieldwidths ignorecase posix manyfiles igncfs + +bigtest: all pound-bang gawk.extensions + +extra: regtest + +pound-bang:: + cp ../gawk /tmp && chmod +x pound-bang && ./pound-bang pound-bang >tmp + rm -f /tmp/gawk + cmp pound-bang.good tmp && rm -f tmp + +msg:: + @echo 'Any output from "cmp" is bad news, although some differences' + @echo 'in floating point values are probably benign -- in particular,' + @echo 'some systems may omit a leading zero and the floating point' + @echo 'precision may lead to slightly different output in a few cases.' + +swaplns:: + @../gawk -f swaplns.awk data >tmp + cmp swaplns.good tmp && rm -f tmp + +messages:: + @../gawk -f messages.awk >out2 2>out3 + cmp out1.good out1 && cmp out2.good out2 && cmp out3.good out3 && \ + rm -f out1 out2 out3 + +argarray:: + @TEST=test ../gawk -f argarray.awk >tmp + cmp argarray.good tmp && rm -f tmp + +fstabplus:: + @echo '1 2' | ../gawk -f fstabplus >tmp + cmp fstabplus.good tmp && rm -f tmp + +fsrs:: + @../gawk -f fsrs.awk fsrs.in >tmp + cmp fsrs.good tmp && rm -f tmp + +igncfs:: + @../gawk -f igncfs.awk igncfs.in >tmp + cmp igncfs.good tmp && rm -f tmp + +longwrds:: + @../gawk -f longwrds.awk manpage | sort >tmp + cmp longwrds.good tmp && rm -f tmp + +fieldwidths:: + @echo '123456789' | ../gawk -v FIELDWIDTHS="2 3 4" '{print $$2}' >tmp + cmp fieldwidths.good tmp && rm -f tmp + +ignorecase:: + @echo xYz | ../gawk -v IGNORECASE=1 '{sub(/y/, ""); print}' >tmp + cmp ignorecase.good tmp && rm -f tmp + +regtest:: + @echo 'Some of the output from regtest is very system specific, do not' + @echo 'be distressed if your output differs from that distributed.' + @echo 'Manual inspection is called for.' + AWK=`pwd`/../gawk ./regtest + +posix:: + @echo '1:2,3 4' | ../gawk -f posix >tmp + cmp posix.good tmp && rm -f tmp + +manyfiles:: + @mkdir junk + @../gawk 'BEGIN { for (i = 1; i <= 100; i++) print i, i}' >tmp + @../gawk -f manyfiles.awk tmp tmp + @echo -n "This number better be 1 ->" + @wc -l junk/* | ../gawk '$$1 != 2' | wc -l + @rm -rf junk tmp + +compare:: + @../gawk -f compare.awk 0 1 compare.in >tmp + cmp compare.good tmp && rm -f tmp + +arrayref:: + @../gawk -f arrayref >tmp + cmp arrayref.good tmp && rm -f tmp + +rs:: + @../gawk -v RS="" '{print $$1, $$2}' rs.data >tmp + cmp rs.good tmp && rm -f tmp + +fsbs:: + @../gawk -v FS='\' '{ print $$1, $$2 }' fsbs.in >tmp + cmp fsbs.good tmp && rm -f tmp + +inftest:: + @../gawk -f inftest.awk >tmp + cmp inftest.good tmp && rm -f tmp + +getline:: + @../gawk -f getline.awk getline.awk getline.awk >tmp + cmp getline.good tmp && rm -f tmp + +rand:: + @echo The following line should just be 19 random numbers between 1 and 100 + @../gawk -f rand.awk + +negexp:: + @../gawk 'BEGIN {a = -2; print 10^a }' >tmp + cmp negexp.good tmp && rm -f tmp + +asgext:: + @../gawk -f asgext.awk asgext.in >tmp + cmp asgext.good tmp && rm -f tmp + +anchgsub:: + @../gawk -f anchgsub.awk anchgsub.in >tmp + cmp anchgsub.good tmp && rm -f tmp + +splitargv:: + @../gawk -f splitargv.awk splitargv.in >tmp + cmp splitargv.good tmp && rm -f tmp + +awkpath:: + @AWKPATH=".:lib" ../gawk -f awkpath.awk >tmp + cmp awkpath.good tmp && rm -f tmp + +nfset:: + @../gawk -f nfset.awk nfset.in >tmp + cmp nfset.good tmp && rm -f tmp + +reparse:: + @../gawk -f reparse.awk reparse.in >tmp + cmp reparse.good tmp && rm -f tmp diff --git a/test/anchgsub.awk b/test/anchgsub.awk new file mode 100644 index 00000000..52e8aa4d --- /dev/null +++ b/test/anchgsub.awk @@ -0,0 +1 @@ +{ gsub(/^[ ]*/, "", $0) ; print } diff --git a/test/anchgsub.good b/test/anchgsub.good new file mode 100644 index 00000000..c33dfb95 --- /dev/null +++ b/test/anchgsub.good @@ -0,0 +1 @@ +This is a test, this is only a test. diff --git a/test/anchgsub.in b/test/anchgsub.in new file mode 100644 index 00000000..b829d84e --- /dev/null +++ b/test/anchgsub.in @@ -0,0 +1 @@ + This is a test, this is only a test. diff --git a/test/argarray.awk b/test/argarray.awk new file mode 100644 index 00000000..3911b6e9 --- /dev/null +++ b/test/argarray.awk @@ -0,0 +1,11 @@ +BEGIN { + argn = " argument" (ARGC > 1 ? "s" : "") + are = ARGC > 1 ? "are" : "is" + print "here we have " ARGC argn + print "which " are + for (x = 0; x < ARGC; x++) + print "\t", ARGV[x] + print "Environment variable TEST=" ENVIRON["TEST"] + print "and the current input file is called", FILENAME + print "but this would change if we would have something to process" +} diff --git a/test/argarray.good b/test/argarray.good new file mode 100644 index 00000000..fe6d0bf8 --- /dev/null +++ b/test/argarray.good @@ -0,0 +1,6 @@ +here we have 1 argument +which is + gawk +Environment variable TEST=test +and the current input file is called - +but this would change if we would have something to process diff --git a/test/arrayref b/test/arrayref new file mode 100644 index 00000000..144d41a0 --- /dev/null +++ b/test/arrayref @@ -0,0 +1,13 @@ + BEGIN { # foo[10] = 0 # put this line in and it will work + test(foo); print foo[1] + test2(foo2); print foo2[1] + } + + function test(foo) + { + test2(foo) + } + function test2(bar) + { + bar[1] = 1 + } diff --git a/test/arrayref.good b/test/arrayref.good new file mode 100644 index 00000000..6ed281c7 --- /dev/null +++ b/test/arrayref.good @@ -0,0 +1,2 @@ +1 +1 diff --git a/test/asgext.awk b/test/asgext.awk new file mode 100644 index 00000000..c7f17754 --- /dev/null +++ b/test/asgext.awk @@ -0,0 +1 @@ +{ print $3; $4 = "a"; print } diff --git a/test/asgext.good b/test/asgext.good new file mode 100644 index 00000000..2c0df70f --- /dev/null +++ b/test/asgext.good @@ -0,0 +1,6 @@ +3 +1 2 3 a + +1 a +3 +1 2 3 a diff --git a/test/asgext.in b/test/asgext.in new file mode 100644 index 00000000..3743b5b4 --- /dev/null +++ b/test/asgext.in @@ -0,0 +1,3 @@ +1 2 3 +1 +1 2 3 4 diff --git a/test/awkpath.good b/test/awkpath.good new file mode 100644 index 00000000..6cffe1b7 --- /dev/null +++ b/test/awkpath.good @@ -0,0 +1 @@ +Found it. diff --git a/test/compare.awk b/test/compare.awk new file mode 100644 index 00000000..39a88f31 --- /dev/null +++ b/test/compare.awk @@ -0,0 +1,13 @@ +BEGIN { + if (ARGV[1]) print 1 + ARGV[1] = "" + if (ARGV[2]) print 2 + ARGV[2] = "" + if ("0") print "zero" + if ("") print "null" + if (0) print 0 +} +{ + if ($0) print $0 + if ($1) print $1 +} diff --git a/test/compare.good b/test/compare.good new file mode 100644 index 00000000..8241359b --- /dev/null +++ b/test/compare.good @@ -0,0 +1,5 @@ +2 +zero +1 +1 +0 1 diff --git a/test/compare.in b/test/compare.in new file mode 100644 index 00000000..1ab098bc --- /dev/null +++ b/test/compare.in @@ -0,0 +1,4 @@ +0 +1 +0 1 + diff --git a/test/csi1.out b/test/csi1.out new file mode 100644 index 00000000..f93c2cc2 --- /dev/null +++ b/test/csi1.out @@ -0,0 +1,574 @@ +Title: Ideal Charge Sensitive Amp +Date: today +Plotname: Transient analysis. +Flags: real +No. Variables: 7 +No. Points: 70 +Variables: 0 time time + 1 v(1) voltage + 2 v(3) voltage + 3 v(5) voltage + 4 v(9) voltage + 5 v(11) voltage + 6 v(13) voltage +Values: + 0 0.000000000000000e+00 + 0.000000000000000e+00 + 0.000000000000000e+00 + 0.000000000000000e+00 + 0.000000000000000e+00 + 0.000000000000000e+00 + 0.000000000000000e+00 + + 1 1.000000000000000e-09 + -1.264149466030735e-09 + 1.264149466030735e-04 + 2.526984953580682e-04 + 2.521735549927725e-16 + 5.033500623385340e-16 + 1.004709971525236e-15 + + 2 1.180906969374945e-09 + -1.514801380340722e-09 + 1.514801380340722e-04 + 3.028004880113196e-04 + 3.078631347571166e-16 + 6.145090159683228e-16 + 1.226588337655132e-15 + + 3 1.542720908124834e-09 + -2.049689597483709e-09 + 2.049689597483709e-04 + 4.097115469383853e-04 + 4.437763676567463e-16 + 8.857978571714022e-16 + 1.768092896751413e-15 + + 4 2.266348785624612e-09 + -3.265760932995932e-09 + 3.265760932995932e-04 + 6.527287612098135e-04 + 9.397999789660777e-16 + 1.875866006928358e-15 + 3.744278902267733e-15 + + 5 3.713604540624168e-09 + -5.968710391500898e-09 + 5.968710391500899e-04 + 1.192640228419305e-03 + 4.345207513494314e-15 + 8.671579322257517e-15 + 1.730556654319970e-14 + + 6 6.608116050623280e-09 + -1.165754959289845e-08 + 1.165754959289845e-03 + 2.327838222854165e-03 + 5.642967340561880e-14 + 1.124945877057287e-13 + 2.242619207939039e-13 + + 7 1.179564303717826e-08 + -2.193530367475176e-08 + 2.193530367475176e-03 + 4.374658167824437e-03 + 9.992331799374361e-13 + 1.987384302704409e-12 + 3.952723001792399e-12 + + 8 2.217069701028822e-08 + -4.233554991551749e-08 + 4.233554991551749e-03 + 8.421454467083355e-03 + 2.567075209989195e-11 + 5.079257750506960e-11 + 1.004987167234087e-10 + + 9 4.292080495650814e-08 + -8.246787850423504e-08 + 8.246787850423504e-03 + 1.631955711542618e-02 + 7.429352627112179e-10 + 1.454666979009004e-09 + 2.848205166007601e-09 + + 10 6.747377244914711e-08 + -1.288241599365203e-07 + 1.288241599365203e-02 + 2.533540213098864e-02 + 6.016036906368960e-09 + 1.168438224023758e-08 + 2.269242430687209e-08 + + 11 1.027485608531171e-07 + -1.933367451151489e-07 + 1.933367451151489e-02 + 3.768347326653115e-02 + 4.547604757457383e-08 + 8.718365928170803e-08 + 1.671235294549662e-07 + + 12 1.550811172440954e-07 + -2.846833995746566e-07 + 2.846833995746566e-02 + 5.474832541420137e-02 + 3.375250800116866e-07 + 6.342555725437884e-07 + 1.191537432922743e-06 + + 13 2.124749343141491e-07 + -3.791439105081753e-07 + 3.791439105081753e-02 + 7.183486021773615e-02 + 1.485074359346451e-06 + 2.739473718610748e-06 + 5.050651248135159e-06 + + 14 2.934050742073026e-07 + -5.028277031417205e-07 + 5.028277031417205e-02 + 9.325941790944214e-02 + 6.951921938590966e-06 + 1.246646151568946e-05 + 2.233163733376972e-05 + + 15 3.899183279910254e-07 + -6.368485744692849e-07 + 6.368485744692850e-02 + 1.150948619702300e-01 + 2.649747455292758e-05 + 4.602250953893021e-05 + 7.978045912595374e-05 + + 16 5.093968731264188e-07 + -7.843833530131612e-07 + 7.843833530131612e-02 + 1.371850504655500e-01 + 9.207624151396878e-05 + 1.537740811662592e-04 + 2.559528885476014e-04 + + 17 6.489752711203596e-07 + -9.338518261925084e-07 + 9.338518261925084e-02 + 1.570273197910303e-01 + 2.792909973592655e-04 + 4.461073848024906e-04 + 7.086148431639843e-04 + + 18 8.223850555731352e-07 + -1.089864299179190e-06 + 1.089864299179190e-01 + 1.742648556363447e-01 + 8.126979446078827e-04 + 1.228244125338940e-03 + 1.839630830557003e-03 + + 19 1.039936620365588e-06 + -1.246638298441507e-06 + 1.246638298441507e-01 + 1.867092058644591e-01 + 2.285828604654097e-03 + 3.224697163278019e-03 + 4.483765996458879e-03 + + 20 1.319715872115905e-06 + -1.397349357516515e-06 + 1.397349357516515e-01 + 1.916979805788835e-01 + 6.317689492712388e-03 + 8.164324401851115e-03 + 1.030606900115141e-02 + + 21 1.686517899697324e-06 + -1.529891860605749e-06 + 1.529891860605749e-01 + 1.859565532106186e-01 + 1.718247093837089e-02 + 1.982736574760900e-02 + 2.201037442321020e-02 + + 22 2.186647083767628e-06 + -1.629428398181613e-06 + 1.629428398181613e-01 + 1.662034028698354e-01 + 4.642596629125201e-02 + 4.602451354215933e-02 + 4.268299343823448e-02 + + 23 2.786647083767628e-06 + -1.671982381159767e-06 + 1.671982381159767e-01 + 1.360832067083017e-01 + 1.086486529677349e-01 + 9.028520856351136e-02 + 6.680053659714552e-02 + + 24 3.386647083767628e-06 + -1.666708289319382e-06 + 1.666708289319382e-01 + 1.065961137297528e-01 + 2.019933895320813e-01 + 1.409501492585539e-01 + 8.111767734595639e-02 + + 25 3.986647083767628e-06 + -1.636239392733020e-06 + 1.636239392733020e-01 + 8.119800486443494e-02 + 3.221985296170131e-01 + 1.879090396235947e-01 + 8.016274379356519e-02 + + 26 4.586647083767628e-06 + -1.592958303223056e-06 + 1.592958303223056e-01 + 6.070506604262340e-02 + 4.601454482849191e-01 + 2.224246188905672e-01 + 6.424612709287120e-02 + + 27 5.186647083767628e-06 + -1.543623379945047e-06 + 1.543623379945047e-01 + 4.479678708109880e-02 + 6.043239691667113e-01 + 2.392201482511665e-01 + 3.780590619181199e-02 + + 28 5.786647083767628e-06 + -1.491907702045976e-06 + 1.491907702045976e-01 + 3.275072893014933e-02 + 7.431846280885604e-01 + 2.368781117682013e-01 + 6.852359091660139e-03 + + 29 6.386647083767628e-06 + -1.439792435778303e-06 + 1.439792435778303e-01 + 2.378169349328440e-02 + 8.668590173262367e-01 + 2.171478488724319e-01 + -2.306848179644787e-02 + + 30 6.986647083767627e-06 + -1.388331481824472e-06 + 1.388331481824472e-01 + 1.718228907053183e-02 + 9.681191419274604e-01 + 1.838077897422596e-01 + -4.796365600793339e-02 + + 31 7.586647083767627e-06 + -1.338071075679957e-06 + 1.338071075679957e-01 + 1.236766007539650e-02 + 1.042671016972224e+00 + 1.415321327946899e-01 + -6.566996968152291e-02 + + 32 8.186647083767628e-06 + -1.289280023988654e-06 + 1.289280023988654e-01 + 8.876981250123693e-03 + 1.088969089643156e+00 + 9.499362660424981e-02 + -7.562842047016014e-02 + + 33 8.786647083767628e-06 + -1.242076017350638e-06 + 1.242076017350638e-01 + 6.357881031810623e-03 + 1.107746658963011e+00 + 4.827333239307662e-02 + -7.843915471504923e-02 + + 34 9.386647083767627e-06 + -1.196494910292573e-06 + 1.196494910292573e-01 + 4.546231107047477e-03 + 1.101424879765328e+00 + 4.554708620525528e-03 + -7.538805789638806e-02 + + 35 9.986647083767627e-06 + -1.152528702498193e-06 + 1.152528702498193e-01 + 3.246760457659020e-03 + 1.073516666992439e+00 + -3.396212210108883e-02 + -6.804675773661231e-02 + + 36 1.058664708376763e-05 + -1.110146344414089e-06 + 1.110146344414089e-01 + 2.316517021036618e-03 + 1.028097189336683e+00 + -6.599874853245306e-02 + -5.798336364268095e-02 + + 37 1.118664708376763e-05 + -1.069305118106022e-06 + 1.069305118106022e-01 + 1.651595638606269e-03 + 9.693765313679967e-01 + -9.105384005235785e-02 + -4.658294889089031e-02 + + 38 1.178664708376763e-05 + -1.029956847083499e-06 + 1.029956847083499e-01 + 1.176870150147819e-03 + 9.013842949659325e-01 + -1.092246920089114e-01 + -3.495841677136451e-02 + + 39 1.238664708376763e-05 + -9.920512695316036e-07 + 9.920512695316036e-02 + 8.382359024086052e-04 + 8.277595463975323e-01 + -1.210283048726013e-01 + -2.392680475810324e-02 + + 40 1.298664708376763e-05 + -9.555378560684139e-07 + 9.555378560684139e-02 + 5.968428720504958e-04 + 7.516306562496196e-01 + -1.272418012047138e-01 + -1.402749198168676e-02 + + 41 1.358664708376763e-05 + -9.203667750735073e-07 + 9.203667750735073e-02 + 4.248571522307446e-04 + 6.755660933441945e-01 + -1.287717046055234e-01 + -5.563263673549205e-03 + + 42 1.418664708376763e-05 + -8.864893913817122e-07 + 8.864893913817122e-02 + 3.023712418928277e-04 + 6.015772305806626e-01 + -1.265545538806776e-01 + 1.349584122132374e-03 + + 43 1.478664708376763e-05 + -8.538585100266795e-07 + 8.538585100266795e-02 + 2.151653061229580e-04 + 5.311562150980697e-01 + -1.214869821570401e-01 + 6.731151169583247e-03 + + 44 1.538664708376763e-05 + -8.224284811671143e-07 + 8.224284811671143e-02 + 1.530922818134957e-04 + 4.653348807170765e-01 + -1.143810920904009e-01 + 1.069309216830403e-02 + + 45 1.598664708376763e-05 + -7.921552298901439e-07 + 7.921552298901439e-02 + 1.089168937368159e-04 + 4.047538335014330e-01 + -1.059400761361653e-01 + 1.340149806837349e-02 + + 46 1.658664708376763e-05 + -7.629962458090119e-07 + 7.629962458090119e-02 + 7.748311028005782e-05 + 3.497338006619688e-01 + -9.674904580077289e-02 + 1.504812104097493e-02 + + 47 1.718664708376763e-05 + -7.349105515804137e-07 + 7.349105515804137e-02 + 5.511827138234112e-05 + 3.003438820737499e-01 + -8.727655437525563e-02 + 1.582944868848389e-02 + + 48 1.778664708376763e-05 + -7.078586608014144e-07 + 7.078586608014144e-02 + 3.920723301882219e-05 + 2.564634021780585e-01 + -7.788305033150851e-02 + 1.593255151302921e-02 + + 49 1.838664708376763e-05 + -6.818025309915621e-07 + 6.818025309915621e-02 + 2.788835904166550e-05 + 2.178356320976079e-01 + -6.883330624805746e-02 + 1.552640761946806e-02 + + 50 1.898664708376763e-05 + -6.567055147578671e-07 + 6.567055147578671e-02 + 1.983668298288980e-05 + 1.841127879600602e-01 + -6.031062641991226e-02 + 1.475741378469763e-02 + + 51 1.958664708376763e-05 + -6.325323108102860e-07 + 6.325323108102860e-02 + 1.410934680022455e-05 + 1.548924830204021e-01 + -5.243129198065891e-02 + 1.374792257730501e-02 + + 52 2.018664708376763e-05 + -6.092489157117236e-07 + 6.092489157117236e-02 + 1.003548599883787e-05 + 1.297462940285003e-01 + -4.525823594528676e-02 + 1.259683280234207e-02 + + 53 2.078664708376763e-05 + -5.868225768176519e-07 + 5.868225768176519e-02 + 7.137810396578103e-06 + 1.082413673531994e-01 + -3.881335316739105e-02 + 1.138146154193364e-02 + + 54 2.138664708376763e-05 + -5.652217466261597e-07 + 5.652217466261597e-02 + 5.076773907606561e-06 + 8.995609902455238e-02 + -3.308815413377584e-02 + 1.016011499551744e-02 + + 55 2.198664708376763e-05 + -5.444160386317303e-07 + 5.444160386317303e-02 + 3.610835627798982e-06 + 7.449092524094347e-02 + -2.805268412856604e-02 + 8.974939299801216e-03 + + 56 2.258664708376763e-05 + -5.243761847070938e-07 + 5.243761847070938e-02 + 2.568179429164067e-06 + 6.147519509948855e-02 + -2.366276900703495e-02 + 7.854766820299426e-03 + + 57 2.318664708376763e-05 + -5.050739940006428e-07 + 5.050739940006428e-02 + 1.826590813882191e-06 + 5.057099452538205e-02 + -1.986573288373220e-02 + 6.817778296350529e-03 + + 58 2.378664708376763e-05 + -4.864823133176291e-07 + 4.864823133176291e-02 + 1.299139640224724e-06 + 4.147467043621487e-02 + -1.660477643856061e-02 + 5.873879622379742e-03 + + 59 2.438664708376763e-05 + -4.685749889436973e-07 + 4.685749889436973e-02 + 9.239944550735617e-07 + 3.391668122982992e-02 + -1.382221958359773e-02 + 5.026748086095437e-03 + + 60 2.498664708376763e-05 + -4.513268298648920e-07 + 4.513268298648920e-02 + 6.571766090561239e-07 + 2.766028273321528e-02 + -1.146180858163665e-02 + 4.275540948961647e-03 + + 61 2.558664708376763e-05 + -4.347135723367043e-07 + 4.347135723367043e-02 + 4.674059248624993e-07 + 2.249945299326918e-02 + -9.470272664280982e-03 + 3.616283467240179e-03 + + 62 2.618664708376763e-05 + -4.187118457546762e-07 + 4.187118457546762e-02 + 3.324343204742104e-07 + 1.825636722182948e-02 + -7.798294060677664e-03 + 3.042967402610447e-03 + + 63 2.678664708376763e-05 + -4.032991397798472e-07 + 4.032991397798472e-02 + 2.364379187533634e-07 + 1.477865648663428e-02 + -6.401031800939865e-03 + 2.548397723334224e-03 + + 64 2.738664708376763e-05 + -3.884537726735109e-07 + 3.884537726735109e-02 + 1.681620986362542e-07 + 1.193661985373132e-02 + -5.238316132556311e-03 + 2.124826894723649e-03 + + 65 2.798664708376763e-05 + -3.741548607971242e-07 + 3.741548607971242e-02 + 1.196021236620889e-07 + 9.620508435261841e-03 + -4.274608378947787e-03 + 1.764414688058854e-03 + + 66 2.858664708376763e-05 + -3.603822892346797e-07 + 3.603822892346797e-02 + 8.506472355827554e-08 + 7.737959636137384e-03 + -3.478801396862400e-03 + 1.459548113681114e-03 + + 67 2.918664708376763e-05 + -3.471166834963309e-07 + 3.471166834963309e-02 + 6.050063999733899e-08 + 6.211629169891409e-03 + -2.823918805423725e-03 + 1.203051836793585e-03 + + 68 2.978664708376763e-05 + -3.343393822635298e-07 + 3.343393822635298e-02 + 4.302990054439619e-08 + 4.977045512498984e-03 + -2.286756907007834e-03 + 9.883148941077680e-04 + + 69 3.000000000000000e-05 + -3.299106422685328e-07 + 3.299106422685328e-02 + 3.815817763877542e-08 + 4.599101705030142e-03 + -2.120719628045261e-03 + 9.210101886687262e-04 + diff --git a/test/data b/test/data new file mode 100644 index 00000000..71fb1627 --- /dev/null +++ b/test/data @@ -0,0 +1,9 @@ +This directory contains some examples/test-cases for different +features of gawk - mostly not present in an old awk. Some are from +"The GAWK Manual", some are original, and some are mixture of the two. +Read header comments before attempting to use. Have fun and remember +that program which consists only of BEGIN block does not need an input +file. + + --mj + diff --git a/test/fieldwidths.good b/test/fieldwidths.good new file mode 100644 index 00000000..51b40081 --- /dev/null +++ b/test/fieldwidths.good @@ -0,0 +1 @@ +345 diff --git a/test/fontdata.txt b/test/fontdata.txt new file mode 100644 index 00000000..b2601237 --- /dev/null +++ b/test/fontdata.txt @@ -0,0 +1,120 @@ +@ +@ Data file for awk program genscrpt.awk which generates gulam +@ script for creation of bitmap TeX fonts. +@ Edit this file to your needs - each line starting with @ is ignored +@ unless it is in a form '@ fonts' or '@ magstep'. The rest should be quite +@ obvious. +@ +@ basic fonts - all magsteps +@ fonts +cmb10 +cmbx10 +cmbx5 +cmbx7 +cmcsc10 +cmex10 +cmmi10 +cmmi5 +cmmi7 +cmr10 +cmr5 +cmr7 +cmsl10 +cmss10 +cmssbx10 +cmsy10 +cmsy5 +cmsy7 +cmti10 +cmtt10 +@ magstep +0 0.5 1 2 3 4 5 +@ other fonts only in magsteps 0, 0.5 and 1 +@ fonts +cmbsy10 +cmbx12 +cmbx6 +cmbx7 +cmbx8 +cmbx9 +cmbxsl10 +cmbxti10 +cmdunh10 +cmff10 +cmfi10 +cmfib8 +cmitt10 +cmmi12 +cmmi6 +cmmi8 +cmmi9 +cmmib10 +cmr12 +cmr17 +cmr6 +cmr8 +cmr9 +cmsl12 +cmsl8 +cmsl9 +cmsltt10 +cmss12 +cmss17 +cmss8 +cmss9 +cmssdc10 +cmssi10 +cmssi12 +cmssi17 +cmssi8 +cmssi9 +cmssq8 +cmssqi8 +cmsy6 +cmsy8 +cmsy9 +cmtcsc10 +cmtex10 +cmtex8 +cmtex9 +cmti12 +cmti7 +cmti8 +cmti9 +cmtt12 +cmtt8 +cmtt9 +cmu10 +cmvtt10 +@ magstep +0 0.5 1 +@ specials +@ fonts +logo10 +@ magstep +0 0.5 1 +@ fonts +cminch +@ magstep +0 +@ LaTeX fonts +lasy10 +lasy5 +lasy7 +lasyb10 +@ magstep +0 0.5 1 2 3 4 5 +@ These fonts should not use cmbase +@ fonts +circle10 +circlew10 +line10 +linew10 +@ magstep +0 0.5 1 2 3 4 5 +@ fonts +lasy6 +lasy8 +lasy9 +@ magstep +0 0.5 1 diff --git a/test/fsbs.good b/test/fsbs.good new file mode 100644 index 00000000..8d04f961 --- /dev/null +++ b/test/fsbs.good @@ -0,0 +1 @@ +1 2 diff --git a/test/fsbs.in b/test/fsbs.in new file mode 100644 index 00000000..0a102c32 --- /dev/null +++ b/test/fsbs.in @@ -0,0 +1 @@ +1\2 diff --git a/test/fsrs.awk b/test/fsrs.awk new file mode 100644 index 00000000..a0014891 --- /dev/null +++ b/test/fsrs.awk @@ -0,0 +1,8 @@ +BEGIN { + RS=""; FS="\n"; + ORS=""; OFS="\n"; + } +{ + split ($2,f," ") + print $0; +} diff --git a/test/fsrs.good b/test/fsrs.good new file mode 100644 index 00000000..7dafd658 --- /dev/null +++ b/test/fsrs.good @@ -0,0 +1,5 @@ +a b +c d +e f1 2 +3 4 +5 6
\ No newline at end of file diff --git a/test/fsrs.in b/test/fsrs.in new file mode 100644 index 00000000..4b49d81c --- /dev/null +++ b/test/fsrs.in @@ -0,0 +1,7 @@ +a b +c d +e f + +1 2 +3 4 +5 6 diff --git a/test/fstabplus b/test/fstabplus new file mode 100644 index 00000000..748a44f4 --- /dev/null +++ b/test/fstabplus @@ -0,0 +1,2 @@ +BEGIN { FS = "\t+" } + { print $1, $2 } diff --git a/test/fstabplus.good b/test/fstabplus.good new file mode 100644 index 00000000..8d04f961 --- /dev/null +++ b/test/fstabplus.good @@ -0,0 +1 @@ +1 2 diff --git a/test/getline.awk b/test/getline.awk new file mode 100644 index 00000000..f4e413f9 --- /dev/null +++ b/test/getline.awk @@ -0,0 +1 @@ +BEGIN { while( getline > 0) { print } } diff --git a/test/getline.good b/test/getline.good new file mode 100644 index 00000000..9b7f2b90 --- /dev/null +++ b/test/getline.good @@ -0,0 +1,2 @@ +BEGIN { while( getline > 0) { print } } +BEGIN { while( getline > 0) { print } } diff --git a/test/header.awk b/test/header.awk new file mode 100644 index 00000000..2066c829 --- /dev/null +++ b/test/header.awk @@ -0,0 +1,5 @@ +BEGIN{ + "date" | getline cur_time + close ("date") + print "This line printed on", cur_time +} diff --git a/test/igncfs.awk b/test/igncfs.awk new file mode 100644 index 00000000..ebb58b24 --- /dev/null +++ b/test/igncfs.awk @@ -0,0 +1,8 @@ +BEGIN { + IGNORECASE=1 + FS="[^a-z]+" +} +{ + for (i=1; i<NF; i++) printf "%s, ", $i + printf "%s\n", $NF +} diff --git a/test/igncfs.good b/test/igncfs.good new file mode 100644 index 00000000..41df9a4c --- /dev/null +++ b/test/igncfs.good @@ -0,0 +1,2 @@ +this, is, handled, ok +This, is, Not, hanDLed, Well diff --git a/test/igncfs.in b/test/igncfs.in new file mode 100644 index 00000000..55980172 --- /dev/null +++ b/test/igncfs.in @@ -0,0 +1,2 @@ +this is handled ok +This is Not hanDLed Well diff --git a/test/ignorecase.good b/test/ignorecase.good new file mode 100644 index 00000000..d66e95ca --- /dev/null +++ b/test/ignorecase.good @@ -0,0 +1 @@ +xz diff --git a/test/include.awk b/test/include.awk new file mode 100644 index 00000000..a506a813 --- /dev/null +++ b/test/include.awk @@ -0,0 +1,13 @@ +# input file should have lines which start with "@incl" followed by +# a name of a file to include +{ + if ((NF == 2) && ($1 == "@incl")) { + print " -- included file -- ", $2 + while ((getline line < $2) > 0) + print line + close ($2) + printf "\t***\n" + } else { + print + } +} diff --git a/test/inftest.awk b/test/inftest.awk new file mode 100644 index 00000000..ec0eda13 --- /dev/null +++ b/test/inftest.awk @@ -0,0 +1,5 @@ +BEGIN { + x = 100 + do { y = x ; x *= 1000; print x,y } while ( y != x ) + print "loop terminated" +} diff --git a/test/inftest.good b/test/inftest.good new file mode 100644 index 00000000..83a93d01 --- /dev/null +++ b/test/inftest.good @@ -0,0 +1,105 @@ +100000 100 +100000000 100000 +1e+11 100000000 +1e+14 1e+11 +1e+17 1e+14 +1e+20 1e+17 +1e+23 1e+20 +1e+26 1e+23 +1e+29 1e+26 +1e+32 1e+29 +1e+35 1e+32 +1e+38 1e+35 +1e+41 1e+38 +1e+44 1e+41 +1e+47 1e+44 +1e+50 1e+47 +1e+53 1e+50 +1e+56 1e+53 +1e+59 1e+56 +1e+62 1e+59 +1e+65 1e+62 +1e+68 1e+65 +1e+71 1e+68 +1e+74 1e+71 +1e+77 1e+74 +1e+80 1e+77 +1e+83 1e+80 +1e+86 1e+83 +1e+89 1e+86 +1e+92 1e+89 +1e+95 1e+92 +1e+98 1e+95 +1e+101 1e+98 +1e+104 1e+101 +1e+107 1e+104 +1e+110 1e+107 +1e+113 1e+110 +1e+116 1e+113 +1e+119 1e+116 +1e+122 1e+119 +1e+125 1e+122 +1e+128 1e+125 +1e+131 1e+128 +1e+134 1e+131 +1e+137 1e+134 +1e+140 1e+137 +1e+143 1e+140 +1e+146 1e+143 +1e+149 1e+146 +1e+152 1e+149 +1e+155 1e+152 +1e+158 1e+155 +1e+161 1e+158 +1e+164 1e+161 +1e+167 1e+164 +1e+170 1e+167 +1e+173 1e+170 +1e+176 1e+173 +1e+179 1e+176 +1e+182 1e+179 +1e+185 1e+182 +1e+188 1e+185 +1e+191 1e+188 +1e+194 1e+191 +1e+197 1e+194 +1e+200 1e+197 +1e+203 1e+200 +1e+206 1e+203 +1e+209 1e+206 +1e+212 1e+209 +1e+215 1e+212 +1e+218 1e+215 +1e+221 1e+218 +1e+224 1e+221 +1e+227 1e+224 +1e+230 1e+227 +1e+233 1e+230 +1e+236 1e+233 +1e+239 1e+236 +1e+242 1e+239 +1e+245 1e+242 +1e+248 1e+245 +1e+251 1e+248 +1e+254 1e+251 +1e+257 1e+254 +1e+260 1e+257 +1e+263 1e+260 +1e+266 1e+263 +1e+269 1e+266 +1e+272 1e+269 +1e+275 1e+272 +1e+278 1e+275 +1e+281 1e+278 +1e+284 1e+281 +1e+287 1e+284 +1e+290 1e+287 +1e+293 1e+290 +1e+296 1e+293 +1e+299 1e+296 +1e+302 1e+299 +1e+305 1e+302 +1e+308 1e+305 +Inf 1e+308 +Inf Inf +loop terminated diff --git a/test/lastnpages b/test/lastnpages new file mode 100644 index 00000000..0acb7738 --- /dev/null +++ b/test/lastnpages @@ -0,0 +1,47 @@ +From nstn.ns.ca!news.cs.indiana.edu!news.nd.edu!spool.mu.edu!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!ssc-vax!brennan Mon May 6 23:41:40 ADT 1991 +Article: 26492 of comp.unix.questions +Path: cs.dal.ca!nstn.ns.ca!news.cs.indiana.edu!news.nd.edu!spool.mu.edu!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!ssc-vax!brennan +From: brennan@ssc-vax.UUCP (Michael D Brennan) +Newsgroups: comp.unix.questions +Subject: Re: How to print last <n> pages of a file +Message-ID: <3948@ssc-bee.ssc-vax.UUCP> +Date: 6 May 91 15:42:00 GMT +Article-I.D.: ssc-bee.3948 +Organization: Boeing Aerospace & Electronics, Seattle WA +Lines: 33 + + +The following shell & (new) awk program prints the last n pages. + +If you get more than 65 lines to a page, the program that inserts +the ^L's should be fixed. + +------------------------------------------------------------- +#!/bin/sh +# usage: lastpages -- prints 1 page reads stdin +# lastpages n -- prints n pages reads stdin +# lastpages n files -- prints n pages, reads file list + +program='BEGIN{RS = ORS = "\f" } + + +{ page[NR] = $0 + if ( NR > numpages ) delete page[NR-numpages] +} + +END { + i = NR - numpages + 1 + if ( i <= 0 ) i = 1 + + while( i <= NR ) print page[i++] +}' + + +case $# in +0) awk "$program" numpages=1 - ;; +1) awk "$program" numpages=$1 - ;; +*) pages=$1 ; shift + awk "$program" numpages=$pages $* ;; +esac + + diff --git a/test/lib/awkpath.awk b/test/lib/awkpath.awk new file mode 100644 index 00000000..6663ca4b --- /dev/null +++ b/test/lib/awkpath.awk @@ -0,0 +1 @@ +BEGIN { print "Found it." } diff --git a/test/longwrds.awk b/test/longwrds.awk new file mode 100644 index 00000000..f6a7816d --- /dev/null +++ b/test/longwrds.awk @@ -0,0 +1,20 @@ +# From Gawk Manual modified by bug fix and removal of punctuation +# Record every word which is used at least once +{ + for (i = 1; i <= NF; i++) { + tmp = tolower($i) + if (0 != (pos = match(tmp, /([a-z]|-)+/))) + used[substr(tmp, pos, RLENGTH)] = 1 + } +} + +#Find a number of distinct words longer than 10 characters +END { + num_long_words = 0 + for (x in used) + if (length(x) > 10) { + ++num_long_words + print x + } + print num_long_words, "long words" +} diff --git a/test/longwrds.good b/test/longwrds.good new file mode 100644 index 00000000..01faa847 --- /dev/null +++ b/test/longwrds.good @@ -0,0 +1,21 @@ +20 long words +compatibility +concatenated +consistency +definitions +description +distributing +fistatements +gawk-options +gnu-specific +identically +implementation +implementations +information +non-portable +pattern-action +pre-defined +program-file +program-text +programming +restrictions diff --git a/test/manpage b/test/manpage new file mode 100644 index 00000000..09c39485 --- /dev/null +++ b/test/manpage @@ -0,0 +1,200 @@ +.ds PX \s-1POSIX\s+1 +.ds UX \s-1UNIX\s+1 +.ds AN \s-1ANSI\s+1 +.TH GAWK 1 "May 28 1991" "Free Software Foundation" "Utility Commands" +.SH NAME +gawk \- pattern scanning and processing language +.SH SYNOPSIS +.B gawk +[ +.B \-W +.I gawk-options +] [ +.BI \-F\^ fs +] [ +.B \-v +.IR var = val +] +.B \-f +.I program-file +[ +.B \-\^\- +] file .\^.\^. +.br +.B gawk +[ +.B \-W +.I gawk-options +] [ +.BI \-F\^ fs +] [ +.B \-v +.IR var = val +] [ +.B \-\^\- +] +.I program-text +file .\^.\^. +.SH DESCRIPTION +.I Gawk +is the GNU Project's implementation of the AWK programming language. +It conforms to the definition of the language in +the \*(PX 1003.2 Command Language And Utilities Standard +(draft 11). +This version in turn is based on the description in +.IR "The AWK Programming Language" , +by Aho, Kernighan, and Weinberger, +with the additional features defined in the System V Release 4 version +of \*(UX +.IR awk . +.I Gawk +also provides some GNU-specific extensions. +.PP +The command line consists of options to +.I gawk +itself, the AWK program text (if not supplied via the +.B \-f +option), and values to be made +available in the +.B ARGC +and +.B ARGV +pre-defined AWK variables. +.SH OPTIONS +.PP +.I Gawk +accepts the following options, which should be available on any implementation +of the AWK language. +.TP +.BI \-F fs +Use +.I fs +for the input field separator (the value of the +.B FS +predefined +variable). +.TP +\fB\-v\fI var\fR\^=\^\fIval\fR +Assign the value +.IR val , +to the variable +.IR var , +before execution of the program begins. +Such variable values are available to the +.B BEGIN +block of an AWK program. +.TP +.BI \-f " program-file" +Read the AWK program source from the file +.IR program-file , +instead of from the first command line argument. +Multiple +.B \-f +options may be used. +.TP +.B \-\^\- +Signal the end of options. This is useful to allow further arguments to the +AWK program itself to start with a ``\-''. +This is mainly for consistency with the argument parsing convention used +by most other \*(PX programs. +.PP +Following the \*(PX standard, +.IR gawk -specific +options are supplied via arguments to the +.B \-W +option. Multiple +.B \-W +options may be supplied, or multiple arguments may be supplied together +if they are separated by commas, or enclosed in quotes and separated +by white space. +Case is ignored in arguments to the +.B \-W +option. +.PP +The +.B \-W +option accepts the following arguments: +.TP \w'\fBcopyright\fR'u+1n +.B compat +Run in +.I compatibility +mode. In compatibility mode, +.I gawk +behaves identically to \*(UX +.IR awk ; +none of the GNU-specific extensions are recognized. +.TP +.PD 0 +.B copyleft +.TP +.PD +.B copyright +Print the short version of the GNU copyright information message on +the error output. +.TP +.B lint +Provide warnings about constructs that are +dubious or non-portable to other AWK implementations. +.TP +.B posix +This turns on +.I compatibility +mode, with the following additional restrictions: +.RS +.TP \w'\(bu'u+1n +\(bu +.B \ex +escape sequences are not recognized. +.TP +\(bu +The synonym +.B func +for the keyword +.B function +is not recognized. +.TP +\(bu +The operators +.B ** +and +.B **= +cannot be used in place of +.B ^ +and +.BR ^= . +.RE +.TP +.B version +Print version information for this particular copy of +.I gawk +on the error output. +This is useful mainly for knowing if the current copy of +.I gawk +on your system +is up to date with respect to whatever the Free Software Foundation +is distributing. +.PP +Any other options are flagged as illegal, but are otherwise ignored. +.SH AWK PROGRAM EXECUTION +.PP +An AWK program consists of a sequence of pattern-action statements +and optional function definitions. +.RS +.PP +\fIpattern\fB { \fIaction statements\fB }\fR +.br +\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR +.RE +.PP +.I Gawk +first reads the program source from the +.IR program-file (s) +if specified, or from the first non-option argument on the command line. +The +.B \-f +option may be used multiple times on the command line. +.I Gawk +will read the program text as if all the +.IR program-file s +had been concatenated together. This is useful for building libraries +of AWK functions, without having to include them in each new AWK diff --git a/test/manyfiles.awk b/test/manyfiles.awk new file mode 100644 index 00000000..212e88d7 --- /dev/null +++ b/test/manyfiles.awk @@ -0,0 +1 @@ +{ print $2 > "junk/" $1 } diff --git a/test/messages.awk b/test/messages.awk new file mode 100644 index 00000000..555f6e38 --- /dev/null +++ b/test/messages.awk @@ -0,0 +1,9 @@ +# This is a demo of different ways of printing with gawk. Try it +# with and without -c (compatibility) flag, redirecting output +# from gawk to a file or not. Some results can be quite unexpected. +BEGIN { + print "Goes to a file out1" > "out1" + print "Normal print statement" + print "This printed on stdout" > "/dev/stdout" + print "You blew it!" > "/dev/stderr" +} diff --git a/test/negexp.good b/test/negexp.good new file mode 100644 index 00000000..6e6566ce --- /dev/null +++ b/test/negexp.good @@ -0,0 +1 @@ +0.01 diff --git a/test/nfset.awk b/test/nfset.awk new file mode 100644 index 00000000..09ebd083 --- /dev/null +++ b/test/nfset.awk @@ -0,0 +1 @@ +{ NF = 5 ; print } diff --git a/test/nfset.good b/test/nfset.good new file mode 100644 index 00000000..3ba48aec --- /dev/null +++ b/test/nfset.good @@ -0,0 +1,5 @@ +1 2 +1 2 3 4 +1 2 3 4 5 +1 2 3 4 5 +1 diff --git a/test/nfset.in b/test/nfset.in new file mode 100644 index 00000000..43329b51 --- /dev/null +++ b/test/nfset.in @@ -0,0 +1,5 @@ +1 2 +1 2 3 4 +1 2 3 4 5 +1 2 3 4 5 6 7 8 +1 diff --git a/test/numfunc.awk b/test/numfunc.awk new file mode 100644 index 00000000..de1d7a4d --- /dev/null +++ b/test/numfunc.awk @@ -0,0 +1,19 @@ +BEGIN { + y = 8 + x = 1 + while (x < 256) { + print "arctan", y/x, atan2(y , x) + x += x + } + print "" + pi8 = atan2(1, 1) / 2 + arg = 0 + for (i = 0; i <= 8; i++) { + print "cos sin", arg, cos(arg), sin(arg) + arg += pi8 + } + print "" + for (i = -5; i<= 5; i++) { + print "exp log", i, exp(i), log(exp(i)) + } +} diff --git a/test/out1.good b/test/out1.good new file mode 100644 index 00000000..f54b2b4d --- /dev/null +++ b/test/out1.good @@ -0,0 +1 @@ +Goes to a file out1 diff --git a/test/out2.good b/test/out2.good new file mode 100644 index 00000000..66b7d2f7 --- /dev/null +++ b/test/out2.good @@ -0,0 +1,2 @@ +Normal print statement +This printed on stdout diff --git a/test/out3.good b/test/out3.good new file mode 100644 index 00000000..7eb822ff --- /dev/null +++ b/test/out3.good @@ -0,0 +1 @@ +You blew it! diff --git a/test/plus-minus b/test/plus-minus new file mode 100644 index 00000000..9fec4bff --- /dev/null +++ b/test/plus-minus @@ -0,0 +1,8 @@ +{ + if ($1 == "-") + print "minus" + if ($1 == "+") + print "plus" + if (($1 != "-") && ($1 != "+")) + print "something else" +} diff --git a/test/posix b/test/posix new file mode 100755 index 00000000..79474f30 --- /dev/null +++ b/test/posix @@ -0,0 +1,69 @@ +BEGIN { + a = "+2"; b = 2; c = "+2a"; d = "+2 "; e = " 2" + + printf "Test #1: " + if (b == a) print "\"" a "\"" " compares as a number" + else print "\"" a "\"" " compares as a string" + + printf "Test #2: " + if (b == c) print "\"" c "\"" " compares as a number" + else print "\"" c "\"" " compares as a string" + + printf "Test #3: " + if (b == d) print "\"" d "\"" " compares as a number" + else print "\"" d "\"" " compares as a string" + + printf "Test #4: " + if (b == e) print "\"" e "\"" " compares as a number" + else print "\"" e "\"" " compares as a string" + + f = a + b + c + d + e + print "after addition" + + printf "Test #5: " + if (b == a) print "\"" a "\"" " compares as a number" + else print "\"" a "\"" " compares as a string" + + printf "Test #6: " + if (b == c) print "\"" c "\"" " compares as a number" + else print "\"" c "\"" " compares as a string" + + printf "Test #7: " + if (b == d) print "\"" d "\"" " compares as a number" + else print "\"" d "\"" " compares as a string" + + printf "Test #8: " + if (b == e) print "\"" e "\"" " compares as a number" + else print "\"" e "\"" " compares as a string" + + printf "Test #9: " + if ("3e5" > "5") print "\"3e5\" > \"5\"" + else print "\"3e5\" <= \"5\"" + + printf "Test #10: " + x = 32.14 + y[x] = "test" + OFMT = "%e" + print y[x] + + printf "Test #11: " + x = x + 0 + print y[x] + + printf "Test #12: " + OFMT="%f" + CONVFMT="%e" + print 1.5, 1.5 "" + + printf "Test #13: " + if ( 1000000 "" == 1000001 "") print "match" + else print "nomatch" +} +{ + printf "Test #14: " + FS = ":" + print $1 + FS = "," + printf "Test #15: " + print $2 +} diff --git a/test/posix.good b/test/posix.good new file mode 100644 index 00000000..100b1505 --- /dev/null +++ b/test/posix.good @@ -0,0 +1,16 @@ +Test #1: "+2" compares as a string +Test #2: "+2a" compares as a string +Test #3: "+2 " compares as a string +Test #4: " 2" compares as a string +after addition +Test #5: "+2" compares as a string +Test #6: "+2a" compares as a string +Test #7: "+2 " compares as a string +Test #8: " 2" compares as a string +Test #9: "3e5" <= "5" +Test #10: test +Test #11: test +Test #12: 1.500000 1.500000e+00 +Test #13: nomatch +Test #14: 1:2,3 +Test #15: 4 diff --git a/test/pound-bang b/test/pound-bang new file mode 100755 index 00000000..a1c24d2b --- /dev/null +++ b/test/pound-bang @@ -0,0 +1,3 @@ +#! /tmp/gawk -f + { ccount += length($0) } +END { print "average line length is", ccount/NR} diff --git a/test/pound-bang.good b/test/pound-bang.good new file mode 100644 index 00000000..a94f6a99 --- /dev/null +++ b/test/pound-bang.good @@ -0,0 +1 @@ +average line length is 29.6667 diff --git a/test/rand.awk b/test/rand.awk new file mode 100644 index 00000000..08f9894e --- /dev/null +++ b/test/rand.awk @@ -0,0 +1,6 @@ +BEGIN { + srand() + for (i = 0; i < 19; i++) + printf "%3d ", (1 + int(100 * rand())) + print "" +} diff --git a/test/reg/exp-eq.awk b/test/reg/exp-eq.awk new file mode 100644 index 00000000..fed6a694 --- /dev/null +++ b/test/reg/exp-eq.awk @@ -0,0 +1 @@ +{ $0 ^= 3 ; print $1} diff --git a/test/reg/exp-eq.good b/test/reg/exp-eq.good new file mode 100644 index 00000000..d8d59aa0 --- /dev/null +++ b/test/reg/exp-eq.good @@ -0,0 +1,3 @@ +1 +8 +27 diff --git a/test/reg/exp-eq.in b/test/reg/exp-eq.in new file mode 100644 index 00000000..01e79c32 --- /dev/null +++ b/test/reg/exp-eq.in @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/test/reg/exp.awk b/test/reg/exp.awk new file mode 100644 index 00000000..4e707f89 --- /dev/null +++ b/test/reg/exp.awk @@ -0,0 +1 @@ +BEGIN { print exp(0), exp(1000000), exp(0.5) } diff --git a/test/reg/exp.good b/test/reg/exp.good new file mode 100644 index 00000000..07b88537 --- /dev/null +++ b/test/reg/exp.good @@ -0,0 +1,2 @@ +1 gawk: reg/exp.awk:1: warning: exp argument 1e+06 is out of range +Inf 1.64872 diff --git a/test/reg/exp.in b/test/reg/exp.in new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/reg/exp.in diff --git a/test/reg/func.awk b/test/reg/func.awk new file mode 100644 index 00000000..e32cd4e6 --- /dev/null +++ b/test/reg/func.awk @@ -0,0 +1 @@ +BEGIN { print dummy(1) } diff --git a/test/reg/func.good b/test/reg/func.good new file mode 100644 index 00000000..d3c7c715 --- /dev/null +++ b/test/reg/func.good @@ -0,0 +1 @@ +gawk: reg/func.awk:1: fatal: function `dummy' not defined diff --git a/test/reg/func.in b/test/reg/func.in new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/reg/func.in diff --git a/test/reg/func2.awk b/test/reg/func2.awk new file mode 100644 index 00000000..2abf2c10 --- /dev/null +++ b/test/reg/func2.awk @@ -0,0 +1,2 @@ +function dummy() { ; } +BEGIN { print dummy (1) } diff --git a/test/reg/func2.good b/test/reg/func2.good new file mode 100644 index 00000000..ae87bc3d --- /dev/null +++ b/test/reg/func2.good @@ -0,0 +1,2 @@ +gawk: reg/func2.awk:2: fatal: function `dummy' called with space between name and (, +or used in other expression context diff --git a/test/reg/func2.in b/test/reg/func2.in new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/reg/func2.in diff --git a/test/reg/log.awk b/test/reg/log.awk new file mode 100644 index 00000000..bcae90b8 --- /dev/null +++ b/test/reg/log.awk @@ -0,0 +1 @@ +BEGIN { print log(0), log(-1), log(100) } diff --git a/test/reg/log.good b/test/reg/log.good new file mode 100644 index 00000000..857ab770 --- /dev/null +++ b/test/reg/log.good @@ -0,0 +1,4 @@ +log: SING error +-Inf gawk: reg/log.awk:1: warning: log called with negative argument -1 +log: DOMAIN error +NaN 4.60517 diff --git a/test/reg/log.in b/test/reg/log.in new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/reg/log.in diff --git a/test/regtest b/test/regtest new file mode 100755 index 00000000..72b0dbf9 --- /dev/null +++ b/test/regtest @@ -0,0 +1,18 @@ +#! /bin/sh + +case "$AWK" in +"") AWK=../gawk ;; +esac +#AWK=${AWK:-../gawk} + +for i in reg/*.awk +do + it=`basename $i .awk` + $AWK -f $i <reg/$it.in >reg/$it.out 2>&1 + if cmp -s reg/$it.out reg/$it.good + then + rm -f reg/$it.out + else + echo "regtest: $it fails" + fi +done diff --git a/test/reparse.awk b/test/reparse.awk new file mode 100644 index 00000000..433ecbb2 --- /dev/null +++ b/test/reparse.awk @@ -0,0 +1,7 @@ +{ + gsub(/x/, " ") + $0 = $0 + print $1 + print $0 + print $1, $2, $3 +} diff --git a/test/reparse.good b/test/reparse.good new file mode 100644 index 00000000..6bdfacfa --- /dev/null +++ b/test/reparse.good @@ -0,0 +1,3 @@ +1 +1 a b c 2 +1 a b diff --git a/test/reparse.in b/test/reparse.in new file mode 100644 index 00000000..6f31cde8 --- /dev/null +++ b/test/reparse.in @@ -0,0 +1 @@ +1 axbxc 2 diff --git a/test/reverse.awk b/test/reverse.awk new file mode 100644 index 00000000..c6b2e299 --- /dev/null +++ b/test/reverse.awk @@ -0,0 +1,13 @@ +#this program creates palindromic output - slightly modified from Gawk Manual +{ + rev($0, length) +} + +function rev(str, len) { + if (len == 0) { + print " ", $0 + return + } + printf "%c", substr(str, len, 1) + rev(str, len - 1) +} diff --git a/test/rs.data b/test/rs.data new file mode 100644 index 00000000..edef835e --- /dev/null +++ b/test/rs.data @@ -0,0 +1,15 @@ + + +a +b + + +c d + + + +e + + + + diff --git a/test/rs.good b/test/rs.good new file mode 100644 index 00000000..7e14cc14 --- /dev/null +++ b/test/rs.good @@ -0,0 +1,4 @@ +a b +c d +e + diff --git a/test/splitargv.awk b/test/splitargv.awk new file mode 100644 index 00000000..10886ef2 --- /dev/null +++ b/test/splitargv.awk @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/test/splitargv.good b/test/splitargv.good new file mode 100644 index 00000000..10886ef2 --- /dev/null +++ b/test/splitargv.good @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/test/splitargv.in b/test/splitargv.in new file mode 100644 index 00000000..10886ef2 --- /dev/null +++ b/test/splitargv.in @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/test/sqrt.awk b/test/sqrt.awk new file mode 100644 index 00000000..c9d8f512 --- /dev/null +++ b/test/sqrt.awk @@ -0,0 +1,4 @@ +BEGIN { + for (i = 0; i <= 25; i++) + printf "gawk sez -- square root of %2d is %15.12f\n", i, sqrt(i) +} diff --git a/test/swaplns.awk b/test/swaplns.awk new file mode 100644 index 00000000..6bf2240a --- /dev/null +++ b/test/swaplns.awk @@ -0,0 +1,7 @@ +{ + if ((getline tmp) > 0) { + print tmp + print + } else + print +} diff --git a/test/swaplns.good b/test/swaplns.good new file mode 100644 index 00000000..d38b7caa --- /dev/null +++ b/test/swaplns.good @@ -0,0 +1,9 @@ +features of gawk - mostly not present in an old awk. Some are from +This directory contains some examples/test-cases for different +Read header comments before attempting to use. Have fun and remember +"The GAWK Manual", some are original, and some are mixture of the two. +file. +that program which consists only of BEGIN block does not need an input + --mj + + diff --git a/test/up_down.awk b/test/up_down.awk new file mode 100644 index 00000000..32ab847c --- /dev/null +++ b/test/up_down.awk @@ -0,0 +1,15 @@ +{ + lim = split ($0, line) + out = "" + if (lim > 0) { + i = 0 + while (i < lim) { + i++ + if (i % 2) + out = out sprintf("%s ", toupper(line[i])) + else + out = out sprintf("%s ", tolower(line[i])) + } + } + print out +} diff --git a/test/zap_cpp.awk b/test/zap_cpp.awk new file mode 100644 index 00000000..99a5a1f4 --- /dev/null +++ b/test/zap_cpp.awk @@ -0,0 +1,13 @@ +# this will remove (comment out) all preprocessor traces from +# cpp produced files: +# run this awk program as follows +# awk -f zap_cpp.awk <file> +# end redirect output where you want it to +NF > 0 { + if ($1 ~ /^#/) + print "/*", $0, "*/" + else + print +} + + |