diff options
-rw-r--r-- | test/ChangeLog | 7 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rwxr-xr-x | test/ofs1.awk | 23 | ||||
-rw-r--r-- | test/ofs1.in | 4 | ||||
-rw-r--r-- | test/ofs1.ok | 7 |
7 files changed, 59 insertions, 2 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index bb26c185..219396cf 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,10 @@ +2012-08-05 Arnold D. Robbins <arnold@skeeve.com> + + New test from Nelson Beebe. + + * Makefile.am (ofs1): New test. + * ofs1.awk, ofs1.in, ofs1.ok: New files. + 2012-07-13 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (getline5): New test. diff --git a/test/Makefile.am b/test/Makefile.am index 967a20c4..9c96c386 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -522,6 +522,9 @@ EXTRA_DIST = \ ofmts.awk \ ofmts.in \ ofmts.ok \ + ofs1.awk \ + ofs1.in \ + ofs1.ok \ onlynl.awk \ onlynl.in \ onlynl.ok \ @@ -816,7 +819,7 @@ BASIC_TESTS = \ nasty nasty2 negexp negrange nested nfldstr nfneg nfset nlfldsep \ nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ noparms nors nulrsend numindex numsubstr \ - octsub ofmt ofmta ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \ paramdup paramres paramtyp parse1 parsefld parseme pcntplus \ posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ prt1eval prtoeval \ diff --git a/test/Makefile.in b/test/Makefile.in index be567702..56c07305 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -727,6 +727,9 @@ EXTRA_DIST = \ ofmts.awk \ ofmts.in \ ofmts.ok \ + ofs1.awk \ + ofs1.in \ + ofs1.ok \ onlynl.awk \ onlynl.in \ onlynl.ok \ @@ -1021,7 +1024,7 @@ BASIC_TESTS = \ nasty nasty2 negexp negrange nested nfldstr nfneg nfset nlfldsep \ nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ noparms nors nulrsend numindex numsubstr \ - octsub ofmt ofmta ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \ paramdup paramres paramtyp parse1 parsefld parseme pcntplus \ posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ prt1eval prtoeval \ @@ -2410,6 +2413,11 @@ ofmts: @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +ofs1: + @echo ofs1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + onlynl: @echo onlynl @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 1b58d5b4..12d7e35c 100644 --- a/test/Maketests +++ b/test/Maketests @@ -560,6 +560,11 @@ ofmts: @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +ofs1: + @echo ofs1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + onlynl: @echo onlynl @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/ofs1.awk b/test/ofs1.awk new file mode 100755 index 00000000..83b3c2a5 --- /dev/null +++ b/test/ofs1.awk @@ -0,0 +1,23 @@ +# Translate this shell script into gawk: +# +#! /bin/sh - +# +# awktest() +# { +# echo a:b:c | $AWK -F":" '{$2="x"; OFS=FS; print}' +# echo a:b:c | $AWK -F":" '{$2="x"; print; OFS=FS; print}' +# echo a:b:c | $AWK -F":" '{$2="x"; print $1; OFS=FS; print}' +# echo a:b:c | $AWK -F":" '{$2="x"; print; $2=$2; OFS=FS; print}' +# } +# +# AWK=./gawk +# awktest > foo.gawk + +BEGIN { FS = ":" } + +# Have to reset OFS at end since not running separate invocations + +FNR == 1 { $2 = "x"; OFS = FS; print ; OFS = " "} +FNR == 2 { $2 = "x"; print; OFS = FS; print ; OFS = " "} +FNR == 3 { $2 = "x"; print $1; OFS = FS; print ; OFS = " "} +FNR == 4 { $2 = "x"; print; $2 = $2; OFS = FS; print } diff --git a/test/ofs1.in b/test/ofs1.in new file mode 100644 index 00000000..0582b9b1 --- /dev/null +++ b/test/ofs1.in @@ -0,0 +1,4 @@ +a:b:c +a:b:c +a:b:c +a:b:c diff --git a/test/ofs1.ok b/test/ofs1.ok new file mode 100644 index 00000000..a3a8ca7b --- /dev/null +++ b/test/ofs1.ok @@ -0,0 +1,7 @@ +a:x:c +a x c +a x c +a +a:x:c +a x c +a:x:c |