diff --git a/ase/test/awk/cou-023.awk b/ase/test/awk/cou-023.awk new file mode 100644 index 00000000..540b65c6 --- /dev/null +++ b/ase/test/awk/cou-023.awk @@ -0,0 +1,2 @@ +BEGIN { FS = OFS = "\t"; } + { $5 = 1000 * $3 / $2; print; } diff --git a/ase/test/awk/cou-023.out b/ase/test/awk/cou-023.out new file mode 100644 index 00000000..58c0e251 --- /dev/null +++ b/ase/test/awk/cou-023.out @@ -0,0 +1,20 @@ +BEGIN { + __global7 = __global13 = " "; +} + +{ + $5 = ((1000 * $3) / $2); + print; +} + +USSR 8649 275 Asia 31.7956 +Canada 3852 25 North America 6.49013 +China 3705 1032 Asia 278.543 +USA 3615 237 North America 65.5602 +Brazil 3286 134 South America 40.7791 +India 1267 746 Asia 588.792 +Mexico 762 78 North America 102.362 +France 211 55 Europe 260.664 +Japan 144 120 Asia 833.333 +Germany 96 61 Europe 635.417 +England 94 56 Europe 595.745 diff --git a/ase/test/awk/cou-024.awk b/ase/test/awk/cou-024.awk new file mode 100644 index 00000000..a10bce8f --- /dev/null +++ b/ase/test/awk/cou-024.awk @@ -0,0 +1,4 @@ +$4 == "Asia" { pop = pop + $3; n = n + 1; } +END { print "Total population of the", n, + "Asian countries is", pop, "million."; + } diff --git a/ase/test/awk/cou-024.out b/ase/test/awk/cou-024.out new file mode 100644 index 00000000..98aae883 --- /dev/null +++ b/ase/test/awk/cou-024.out @@ -0,0 +1,9 @@ +($4 == "Asia") { + pop = (pop + $3); + n = (n + 1); +} + +END { + print "Total population of the",n,"Asian countries is",pop,"million."; +} +Total population of the 4 Asian countries is 2173 million. diff --git a/ase/test/awk/cou-025.awk b/ase/test/awk/cou-025.awk new file mode 100644 index 00000000..a0eb9ca1 --- /dev/null +++ b/ase/test/awk/cou-025.awk @@ -0,0 +1,6 @@ +/Asia/ { pop["Asia"] += $3; } +/Europe/ { pop["Europe"] += $3; } +END { print "Asian population is", pop["Asia"], "million."; + print "European population is", pop["Europe"], "million."; + } + diff --git a/ase/test/awk/cou-025.out b/ase/test/awk/cou-025.out new file mode 100644 index 00000000..503ccd18 --- /dev/null +++ b/ase/test/awk/cou-025.out @@ -0,0 +1,14 @@ +/Asia/ { + pop["Asia"] += $3; +} + +/Europe/ { + pop["Europe"] += $3; +} + +END { + print "Asian population is",pop["Asia"],"million."; + print "European population is",pop["Europe"],"million."; +} +Asian population is 2173 million. +European population is 172 million. diff --git a/ase/test/awk/cou-026.awk b/ase/test/awk/cou-026.awk new file mode 100644 index 00000000..0597c6d9 --- /dev/null +++ b/ase/test/awk/cou-026.awk @@ -0,0 +1,3 @@ +BEGIN { FS = "\t"; } + { pop[$4] += $3; } +END { for (name in pop) print name, pop[name]; } diff --git a/ase/test/awk/cou-026.out b/ase/test/awk/cou-026.out new file mode 100644 index 00000000..fcc41946 --- /dev/null +++ b/ase/test/awk/cou-026.out @@ -0,0 +1,16 @@ +BEGIN { + __global7 = " "; +} + +{ + pop[$4] += $3; +} + +END { + for (name in pop) + print name,pop[name]; +} +Europe 172 +South America 134 +North America 340 +Asia 2173 diff --git a/ase/test/awk/cou-027.awk b/ase/test/awk/cou-027.awk new file mode 100644 index 00000000..f8464883 --- /dev/null +++ b/ase/test/awk/cou-027.awk @@ -0,0 +1,5 @@ +BEGIN { FS = "\t"; } + { pop[$4] += $3; } +END { for (c in pop) + printf ("%15s\t%6d\n", c, pop[c]) | "sort -t'\t' +1rn"; + } diff --git a/ase/test/awk/cou-027.out b/ase/test/awk/cou-027.out new file mode 100644 index 00000000..33dd0d84 --- /dev/null +++ b/ase/test/awk/cou-027.out @@ -0,0 +1,16 @@ +BEGIN { + __global7 = " "; +} + +{ + pop[$4] += $3; +} + +END { + for (c in pop) + printf ("%15s %6d\n",c,pop[c]) | "sort -t' ' +1rn"; +} + Asia 2173 + North America 340 + Europe 172 + South America 134 diff --git a/ase/test/awk/crash08.awk b/ase/test/awk/crash08.awk new file mode 100644 index 00000000..130cf3c8 --- /dev/null +++ b/ase/test/awk/crash08.awk @@ -0,0 +1,23 @@ +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(); +} + +