diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2019-01-25 11:47:18 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2019-01-25 11:47:18 +0200 |
commit | eceb548b02f0d72ca6a6e9a68bfd615ac9549a64 (patch) | |
tree | 10d127076e7f850560095dd386c9f28b2c4811aa /test | |
parent | 378de9aa9e73d44d0172947c38be67c0bd78a0b0 (diff) | |
download | egawk-eceb548b02f0d72ca6a6e9a68bfd615ac9549a64.tar.gz egawk-eceb548b02f0d72ca6a6e9a68bfd615ac9549a64.tar.bz2 egawk-eceb548b02f0d72ca6a6e9a68bfd615ac9549a64.zip |
Rework namespace handling to make simpler and correct. Add two test cases.
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 14 | ||||
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/Makefile.in | 17 | ||||
-rw-r--r-- | test/Maketests | 10 | ||||
-rw-r--r-- | test/nsforloop.awk | 20 | ||||
-rw-r--r-- | test/nsforloop.ok | 7 | ||||
-rw-r--r-- | test/nsfuncrecurse.awk | 18 | ||||
-rw-r--r-- | test/nsfuncrecurse.ok | 5 | ||||
-rw-r--r-- | test/nsindirect2.ok | 2 | ||||
-rw-r--r-- | test/nsprof2.ok | 20 |
10 files changed, 106 insertions, 13 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 812f3faf..b8352718 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,17 @@ +2018-01-24 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (EXTRA_DIST): New test: nsforloop. + * nsforloop.awk, nsforloop.ok: New files. + +2018-01-23 Arnold D. Robbins <arnold@skeeve.com> + + * nsprof2.ok: Adjust after code changes. + +2018-01-23 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (EXTRA_DIST): New test: nsfuncrecurse. + * nsfuncrecurse.awk, nsfuncrecurse.ok: New files. + 2019-01-09 Andrew J. Schorr <aschorr@telemetry-investments.com> * Makefile.am (EXTRA_DIST): New test: arraytype. diff --git a/test/Makefile.am b/test/Makefile.am index 0ffad9ad..046d8c67 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -773,6 +773,10 @@ EXTRA_DIST = \ nsbad.awk \ nsbad.ok \ nsbad_cmd.ok \ + nsforloop.awk \ + nsforloop.ok \ + nsfuncrecurse.awk \ + nsfuncrecurse.ok \ nsindirect1.awk \ nsindirect1.ok \ nsindirect2.awk \ @@ -1327,7 +1331,7 @@ GAWK_EXT_TESTS = \ lint lintexp lintindex lintint lintlength lintold lintset lintwarn \ manyfiles match1 match2 match3 mbstr1 mbstr2 mixed1 mktime muldimposix \ nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \ - nsbad nsbad_cmd nsindirect1 nsindirect2 nsprof1 nsprof2 \ + nsbad nsbad_cmd nsforloop nsfuncrecurse nsindirect1 nsindirect2 nsprof1 nsprof2 \ patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \ procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6 \ profile7 profile8 profile9 profile10 profile11 pty1 pty2 \ diff --git a/test/Makefile.in b/test/Makefile.in index c244c7af..e0fbd970 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1031,6 +1031,10 @@ EXTRA_DIST = \ nsbad.awk \ nsbad.ok \ nsbad_cmd.ok \ + nsforloop.awk \ + nsforloop.ok \ + nsfuncrecurse.awk \ + nsfuncrecurse.ok \ nsindirect1.awk \ nsindirect1.ok \ nsindirect2.awk \ @@ -1585,7 +1589,7 @@ GAWK_EXT_TESTS = \ lint lintexp lintindex lintint lintlength lintold lintset lintwarn \ manyfiles match1 match2 match3 mbstr1 mbstr2 mixed1 mktime muldimposix \ nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \ - nsbad nsbad_cmd nsindirect1 nsindirect2 nsprof1 nsprof2 \ + nsbad nsbad_cmd nsforloop nsfuncrecurse nsindirect1 nsindirect2 nsprof1 nsprof2 \ patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \ procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6 \ profile7 profile8 profile9 profile10 profile11 pty1 pty2 \ @@ -1647,6 +1651,7 @@ NEED_POSIX = printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix NEED_PRETTY = nsprof1 nsprof2 \ profile4 profile5 profile8 profile9 profile10 profile11 + # List of tests that need --re-interval NEED_RE_INTERVAL = gsubtst3 reint reint2 @@ -4383,6 +4388,16 @@ nsbad: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +nsforloop: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +nsfuncrecurse: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + nsindirect1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 7163b4ab..84a0218d 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1678,6 +1678,16 @@ nsbad: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +nsforloop: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +nsfuncrecurse: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + nsindirect1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/nsforloop.awk b/test/nsforloop.awk new file mode 100644 index 00000000..b050db64 --- /dev/null +++ b/test/nsforloop.awk @@ -0,0 +1,20 @@ +@namespace "foo" + +function test(v) +{ + print "-- 1" + for (i in Data) + print i + + print "-- 2" + for (v in Data) + print v + print "-- 3" +} + +BEGIN { + Data[1] = 1 + Data[2] = 2 + + test() +} diff --git a/test/nsforloop.ok b/test/nsforloop.ok new file mode 100644 index 00000000..b87cd3ef --- /dev/null +++ b/test/nsforloop.ok @@ -0,0 +1,7 @@ +-- 1 +1 +2 +-- 2 +1 +2 +-- 3 diff --git a/test/nsfuncrecurse.awk b/test/nsfuncrecurse.awk new file mode 100644 index 00000000..1a006ceb --- /dev/null +++ b/test/nsfuncrecurse.awk @@ -0,0 +1,18 @@ +@namespace "foo" + +function test(v) +{ + if (v <= 0) + return + + Level++ + v-- + printf("Level = %d, v = %d\n", Level, v) + test(v) + Level-- +} + +BEGIN { + Level = 0 + test(5) +} diff --git a/test/nsfuncrecurse.ok b/test/nsfuncrecurse.ok new file mode 100644 index 00000000..3dc76e41 --- /dev/null +++ b/test/nsfuncrecurse.ok @@ -0,0 +1,5 @@ +Level = 1, v = 4 +Level = 2, v = 3 +Level = 3, v = 2 +Level = 4, v = 1 +Level = 5, v = 0 diff --git a/test/nsindirect2.ok b/test/nsindirect2.ok index 9b71cd92..c447220d 100644 --- a/test/nsindirect2.ok +++ b/test/nsindirect2.ok @@ -1,4 +1,4 @@ -strftime() - this is not the function you are looking for +strftime(from 'testing') - this is not the function you are looking for gensub = gensub iteration 1, got good result from systime iteration 2, got good result from systime diff --git a/test/nsprof2.ok b/test/nsprof2.ok index 1bb78822..5a861830 100644 --- a/test/nsprof2.ok +++ b/test/nsprof2.ok @@ -48,13 +48,13 @@ function Init(oldfs, oldrs, olddol0, pwcat, using_fw, using_fpat) if (Inited) { return } - oldfs = awk::FS - oldrs = awk::RS + oldfs = FS + oldrs = RS olddol0 = $0 - using_fw = (awk::PROCINFO["FS"] == "FIELDWIDTHS") - using_fpat = (awk::PROCINFO["FS"] == "FPAT") - awk::FS = ":" - awk::RS = "\n" + using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") + using_fpat = (PROCINFO["FS"] == "FPAT") + FS = ":" + RS = "\n" pwcat = Awklib "pwcat" while ((pwcat | getline) > 0) { Byname[$1] = $0 @@ -64,12 +64,12 @@ function Init(oldfs, oldrs, olddol0, pwcat, using_fw, using_fpat) close(pwcat) Count = 0 Inited = 1 - awk::FS = oldfs + FS = oldfs if (using_fw) { - awk::FIELDWIDTHS = awk::FIELDWIDTHS + FIELDWIDTHS = FIELDWIDTHS } else if (using_fpat) { - awk::FPAT = awk::FPAT + FPAT = FPAT } - awk::RS = oldrs + RS = oldrs $0 = olddol0 } |