xref: /aosp_15_r20/external/one-true-awk/testdir/T.gawk (revision 9a7741de182b2776d7b30d6355f2585c0780a51b)
1*9a7741deSElliott Hughesecho T.gawk: tests adapted from gawk test suite
2*9a7741deSElliott Hughes# for which thanks.
3*9a7741deSElliott Hughes
4*9a7741deSElliott Hughesawk=${awk-../a.out}
5*9a7741deSElliott Hughes
6*9a7741deSElliott Hughes# arrayref:
7*9a7741deSElliott Hughes./echo '1
8*9a7741deSElliott Hughes1' >foo1
9*9a7741deSElliott Hughes$awk '
10*9a7741deSElliott Hughes	BEGIN { # foo[10] = 0		# put this line in and it will work
11*9a7741deSElliott Hughes		test(foo); print foo[1]
12*9a7741deSElliott Hughes		test2(foo2); print foo2[1]
13*9a7741deSElliott Hughes	}
14*9a7741deSElliott Hughes	function test(foo) { test2(foo) }
15*9a7741deSElliott Hughes	function test2(bar) { bar[1] = 1 }
16*9a7741deSElliott Hughes' >foo2
17*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk arrayref'
18*9a7741deSElliott Hughes
19*9a7741deSElliott Hughes# asgext
20*9a7741deSElliott Hughes./echo '1 2 3
21*9a7741deSElliott Hughes1
22*9a7741deSElliott Hughes1 2 3 4' >foo
23*9a7741deSElliott Hughes./echo '3
24*9a7741deSElliott Hughes1 2 3 a
25*9a7741deSElliott Hughes
26*9a7741deSElliott Hughes1   a
27*9a7741deSElliott Hughes3
28*9a7741deSElliott Hughes1 2 3 a' >foo1
29*9a7741deSElliott Hughes$awk '{ print $3; $4 = "a"; print }' foo >foo2
30*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk asgext'
31*9a7741deSElliott Hughes
32*9a7741deSElliott Hughes# backgsub:
33*9a7741deSElliott Hughes./echo 'x\y
34*9a7741deSElliott Hughesx\\y' >foo
35*9a7741deSElliott Hughes./echo 'x\y
36*9a7741deSElliott HughesxAy
37*9a7741deSElliott HughesxAy
38*9a7741deSElliott HughesxAAy' >foo1
39*9a7741deSElliott Hughes$awk '{	x = y = $0
40*9a7741deSElliott Hughes        gsub( /\\\\/, "A", x); print x
41*9a7741deSElliott Hughes        gsub( "\\\\", "A", y); print y
42*9a7741deSElliott Hughes}' foo >foo2
43*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk backgsub'
44*9a7741deSElliott Hughes
45*9a7741deSElliott Hughes
46*9a7741deSElliott Hughes# backgsub2:
47*9a7741deSElliott Hughes./echo 'x\y
48*9a7741deSElliott Hughesx\\y
49*9a7741deSElliott Hughesx\\\y' >foo
50*9a7741deSElliott Hughes./echo '	x\y
51*9a7741deSElliott Hughes	x\y
52*9a7741deSElliott Hughes	x\y
53*9a7741deSElliott Hughes	x\y
54*9a7741deSElliott Hughes	x\\y
55*9a7741deSElliott Hughes	x\\\y
56*9a7741deSElliott Hughes	x\\y
57*9a7741deSElliott Hughes	x\\\y
58*9a7741deSElliott Hughes	x\\\\y' >foo1
59*9a7741deSElliott Hughes$awk '{	w = x = y = z = $0
60*9a7741deSElliott Hughes        gsub( /\\\\/, "\\", w); print "	" w
61*9a7741deSElliott Hughes        gsub( /\\\\/, "\\\\", x); print "	" x
62*9a7741deSElliott Hughes        gsub( /\\\\/, "\\\\\\", y); print "	" y
63*9a7741deSElliott Hughes}
64*9a7741deSElliott Hughes' foo >foo2
65*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk backgsub2'
66*9a7741deSElliott Hughes
67*9a7741deSElliott Hughes
68*9a7741deSElliott Hughes# backgsub3:
69*9a7741deSElliott Hughes./echo 'xax
70*9a7741deSElliott Hughesxaax' >foo
71*9a7741deSElliott Hughes./echo '	xax
72*9a7741deSElliott Hughes	x&x
73*9a7741deSElliott Hughes	x&x
74*9a7741deSElliott Hughes	x\ax
75*9a7741deSElliott Hughes	x\ax
76*9a7741deSElliott Hughes	x\&x
77*9a7741deSElliott Hughes	xaax
78*9a7741deSElliott Hughes	x&&x
79*9a7741deSElliott Hughes	x&&x
80*9a7741deSElliott Hughes	x\a\ax
81*9a7741deSElliott Hughes	x\a\ax
82*9a7741deSElliott Hughes	x\&\&x' >foo1
83*9a7741deSElliott Hughes$awk '{	w = x = y = z = z1 = z2 = $0
84*9a7741deSElliott Hughes        gsub( /a/, "\&", w); print "	" w
85*9a7741deSElliott Hughes        gsub( /a/, "\\&", x); print "	" x
86*9a7741deSElliott Hughes        gsub( /a/, "\\\&", y); print "	" y
87*9a7741deSElliott Hughes        gsub( /a/, "\\\\&", z); print "	" z
88*9a7741deSElliott Hughes        gsub( /a/, "\\\\\&", z1); print "	" z1
89*9a7741deSElliott Hughes        gsub( /a/, "\\\\\\&", z2); print "	" z2
90*9a7741deSElliott Hughes}
91*9a7741deSElliott Hughes' foo >foo2
92*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk backgsub3'
93*9a7741deSElliott Hughes
94*9a7741deSElliott Hughes
95*9a7741deSElliott Hughes# backsub3:
96*9a7741deSElliott Hughes./echo 'xax
97*9a7741deSElliott Hughesxaax' >foo
98*9a7741deSElliott Hughes./echo '	xax
99*9a7741deSElliott Hughes	x&x
100*9a7741deSElliott Hughes	x&x
101*9a7741deSElliott Hughes	x\ax
102*9a7741deSElliott Hughes	x\ax
103*9a7741deSElliott Hughes	x\&x
104*9a7741deSElliott Hughes	xaax
105*9a7741deSElliott Hughes	x&ax
106*9a7741deSElliott Hughes	x&ax
107*9a7741deSElliott Hughes	x\aax
108*9a7741deSElliott Hughes	x\aax
109*9a7741deSElliott Hughes	x\&ax' >foo1
110*9a7741deSElliott Hughes$awk '{	w = x = y = z = z1 = z2 = $0
111*9a7741deSElliott Hughes        sub( /a/, "\&", w); print "	" w
112*9a7741deSElliott Hughes        sub( /a/, "\\&", x); print "	" x
113*9a7741deSElliott Hughes        sub( /a/, "\\\&", y); print "	" y
114*9a7741deSElliott Hughes        sub( /a/, "\\\\&", z); print "	" z
115*9a7741deSElliott Hughes        sub( /a/, "\\\\\&", z1); print "	" z1
116*9a7741deSElliott Hughes        sub( /a/, "\\\\\\&", z2); print "	" z2
117*9a7741deSElliott Hughes}
118*9a7741deSElliott Hughes' foo >foo2
119*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk backsub3'
120*9a7741deSElliott Hughes
121*9a7741deSElliott Hughes
122*9a7741deSElliott Hughes# backsub:
123*9a7741deSElliott Hughes./echo 'x\y
124*9a7741deSElliott Hughesx\\y' >foo
125*9a7741deSElliott Hughes./echo 'x\y
126*9a7741deSElliott Hughesx\\y
127*9a7741deSElliott Hughesx\\y
128*9a7741deSElliott Hughesx\\\y' >foo1
129*9a7741deSElliott Hughes$awk '{	x = y = $0
130*9a7741deSElliott Hughes        sub( /\\\\/, "\\\\", x); print x
131*9a7741deSElliott Hughes        sub( "\\\\", "\\\\", y); print y
132*9a7741deSElliott Hughes}' foo >foo2
133*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk backsub'
134*9a7741deSElliott Hughes
135*9a7741deSElliott Hughes
136*9a7741deSElliott Hughes
137*9a7741deSElliott Hughes
138*9a7741deSElliott Hughes# dynlj:
139*9a7741deSElliott Hughes./echo 'hello               world' >foo1
140*9a7741deSElliott Hughes$awk 'BEGIN { printf "%*sworld\n", -20, "hello" }' >foo2
141*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk dynlj'
142*9a7741deSElliott Hughes
143*9a7741deSElliott Hughes# fsrs:
144*9a7741deSElliott Hughes./echo 'a b
145*9a7741deSElliott Hughesc d
146*9a7741deSElliott Hughese f
147*9a7741deSElliott Hughes
148*9a7741deSElliott Hughes1 2
149*9a7741deSElliott Hughes3 4
150*9a7741deSElliott Hughes5 6' >foo
151*9a7741deSElliott Hughes# note -n:
152*9a7741deSElliott Hughes./echo -n 'a b
153*9a7741deSElliott Hughesc d
154*9a7741deSElliott Hughese f1 2
155*9a7741deSElliott Hughes3 4
156*9a7741deSElliott Hughes5 6' >foo1
157*9a7741deSElliott Hughes$awk '
158*9a7741deSElliott HughesBEGIN {
159*9a7741deSElliott Hughes       RS=""; FS="\n";
160*9a7741deSElliott Hughes       ORS=""; OFS="\n";
161*9a7741deSElliott Hughes      }
162*9a7741deSElliott Hughes{
163*9a7741deSElliott Hughes        split ($2,f," ")
164*9a7741deSElliott Hughes        print $0;
165*9a7741deSElliott Hughes}' foo >foo2
166*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk fsrs'
167*9a7741deSElliott Hughes
168*9a7741deSElliott Hughes# intest
169*9a7741deSElliott Hughes./echo '0 1' >foo1
170*9a7741deSElliott Hughes$awk 'BEGIN {
171*9a7741deSElliott Hughes	bool = ((b = 1) in c);
172*9a7741deSElliott Hughes	print bool, b	# gawk-3.0.1 prints "0 "; should print "0 1"
173*9a7741deSElliott Hughes}' >foo2
174*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk intest'
175*9a7741deSElliott Hughes
176*9a7741deSElliott Hughes# intprec:
177*9a7741deSElliott Hughes./echo '0000000005:000000000e' >foo1
178*9a7741deSElliott Hughes$awk 'BEGIN { printf "%.10d:%.10x\n", 5, 14 }' >foo2
179*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk intprec'
180*9a7741deSElliott Hughes
181*9a7741deSElliott Hughes# litoct:
182*9a7741deSElliott Hughes./echo 'axb
183*9a7741deSElliott Hughesab
184*9a7741deSElliott Hughesa*b' >foo
185*9a7741deSElliott Hughes./echo 'no match
186*9a7741deSElliott Hughesno match
187*9a7741deSElliott Hughesmatch' >foo1
188*9a7741deSElliott Hughes$awk '{ if (/a\52b/) print "match" ; else print "no match" }' foo >foo2
189*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk litoct'
190*9a7741deSElliott Hughes
191*9a7741deSElliott Hughes# math:
192*9a7741deSElliott Hughes./echo 'cos(0.785398) = 0.707107
193*9a7741deSElliott Hughessin(0.785398) = 0.707107
194*9a7741deSElliott Hughese = 2.718282
195*9a7741deSElliott Hugheslog(e) = 1.000000
196*9a7741deSElliott Hughessqrt(pi ^ 2) = 3.141593
197*9a7741deSElliott Hughesatan2(1, 1) = 0.785398' >foo1
198*9a7741deSElliott Hughes$awk 'BEGIN {
199*9a7741deSElliott Hughes	pi = 3.1415927
200*9a7741deSElliott Hughes	printf "cos(%f) = %f\n", pi/4, cos(pi/4)
201*9a7741deSElliott Hughes	printf "sin(%f) = %f\n", pi/4, sin(pi/4)
202*9a7741deSElliott Hughes	e = exp(1)
203*9a7741deSElliott Hughes	printf "e = %f\n", e
204*9a7741deSElliott Hughes	printf "log(e) = %f\n", log(e)
205*9a7741deSElliott Hughes	printf "sqrt(pi ^ 2) = %f\n", sqrt(pi ^ 2)
206*9a7741deSElliott Hughes	printf "atan2(1, 1) = %f\n", atan2(1, 1)
207*9a7741deSElliott Hughes}' >foo2
208*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk math'
209*9a7741deSElliott Hughes
210*9a7741deSElliott Hughes# nlfldsep:
211*9a7741deSElliott Hughes./echo 'some stuff
212*9a7741deSElliott Hughesmore stuffA
213*9a7741deSElliott Hughesjunk
214*9a7741deSElliott HughesstuffA
215*9a7741deSElliott Hughesfinal' >foo
216*9a7741deSElliott Hughes./echo '4
217*9a7741deSElliott Hughessome
218*9a7741deSElliott Hughesstuff
219*9a7741deSElliott Hughesmore
220*9a7741deSElliott Hughesstuff
221*9a7741deSElliott Hughes
222*9a7741deSElliott Hughes2
223*9a7741deSElliott Hughesjunk
224*9a7741deSElliott Hughesstuff
225*9a7741deSElliott Hughes
226*9a7741deSElliott Hughes1
227*9a7741deSElliott Hughesfinal
228*9a7741deSElliott Hughes' >foo1
229*9a7741deSElliott Hughes$awk 'BEGIN { RS = "A" }
230*9a7741deSElliott Hughes{print NF; for (i = 1; i <= NF; i++) print $i ; print ""}
231*9a7741deSElliott Hughes' foo >foo2
232*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk nlfldsep'
233*9a7741deSElliott Hughes
234*9a7741deSElliott Hughes# numsubstr:
235*9a7741deSElliott Hughes./echo '5000
236*9a7741deSElliott Hughes10000
237*9a7741deSElliott Hughes5000' >foo
238*9a7741deSElliott Hughes./echo '000
239*9a7741deSElliott Hughes1000
240*9a7741deSElliott Hughes000' >foo1
241*9a7741deSElliott Hughes$awk '{ print substr(1000+$1, 2) }' foo >foo2
242*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk numsubstr'
243*9a7741deSElliott Hughes
244*9a7741deSElliott Hughes# pcntplus:
245*9a7741deSElliott Hughes./echo '+3 4' >foo1
246*9a7741deSElliott Hughes$awk 'BEGIN { printf "%+d %d\n", 3, 4 }' >foo2
247*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk pcntplus'
248*9a7741deSElliott Hughes
249*9a7741deSElliott Hughes# prt1eval:
250*9a7741deSElliott Hughes./echo 1 >foo1
251*9a7741deSElliott Hughes$awk 'function tst () {
252*9a7741deSElliott Hughes	sum += 1
253*9a7741deSElliott Hughes	return sum
254*9a7741deSElliott Hughes}
255*9a7741deSElliott HughesBEGIN { OFMT = "%.0f" ; print tst() }
256*9a7741deSElliott Hughes' >foo2
257*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk prt1eval'
258*9a7741deSElliott Hughes
259*9a7741deSElliott Hughes# reparse:
260*9a7741deSElliott Hughes./echo '1 axbxc 2' >foo
261*9a7741deSElliott Hughes./echo '1
262*9a7741deSElliott Hughes1 a b c 2
263*9a7741deSElliott Hughes1 a b' >foo1
264*9a7741deSElliott Hughes$awk '{	gsub(/x/, " ")
265*9a7741deSElliott Hughes	$0 = $0
266*9a7741deSElliott Hughes	print $1
267*9a7741deSElliott Hughes	print $0
268*9a7741deSElliott Hughes	print $1, $2, $3
269*9a7741deSElliott Hughes}' foo >foo2
270*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk reparse'
271*9a7741deSElliott Hughes
272*9a7741deSElliott Hughes# rswhite:
273*9a7741deSElliott Hughes./echo '    a b
274*9a7741deSElliott Hughesc d' >foo
275*9a7741deSElliott Hughes./echo '<    a b
276*9a7741deSElliott Hughesc d>' >foo1
277*9a7741deSElliott Hughes$awk 'BEGIN { RS = "" }
278*9a7741deSElliott Hughes{ printf("<%s>\n", $0) }' foo  >foo2
279*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk rswhite'
280*9a7741deSElliott Hughes
281*9a7741deSElliott Hughes# splitvar:
282*9a7741deSElliott Hughes./echo 'Here===Is=Some=====Data' >foo
283*9a7741deSElliott Hughes./echo 4 >foo1
284*9a7741deSElliott Hughes$awk '{	sep = "=+"
285*9a7741deSElliott Hughes	n = split($0, a, sep)
286*9a7741deSElliott Hughes	print n
287*9a7741deSElliott Hughes}' foo >foo2
288*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk splitvar'
289*9a7741deSElliott Hughes
290*9a7741deSElliott Hughes# splitwht:
291*9a7741deSElliott Hughes./echo '4
292*9a7741deSElliott Hughes5' >foo1
293*9a7741deSElliott Hughes$awk 'BEGIN {
294*9a7741deSElliott Hughes	str = "a   b\t\tc d"
295*9a7741deSElliott Hughes	n = split(str, a, " ")
296*9a7741deSElliott Hughes	print n
297*9a7741deSElliott Hughes	m = split(str, b, / /)
298*9a7741deSElliott Hughes	print m
299*9a7741deSElliott Hughes}' >foo2
300*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk splitwht'
301*9a7741deSElliott Hughes
302*9a7741deSElliott Hughes# sprintfc:
303*9a7741deSElliott Hughes./echo '65
304*9a7741deSElliott Hughes66
305*9a7741deSElliott Hughesfoo' >foo
306*9a7741deSElliott Hughes./echo 'A 65
307*9a7741deSElliott HughesB 66
308*9a7741deSElliott Hughesf foo' >foo1
309*9a7741deSElliott Hughes$awk '{ print sprintf("%c", $1), $1 }' foo >foo2
310*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk sprintfc'
311*9a7741deSElliott Hughes
312*9a7741deSElliott Hughes# substr:
313*9a7741deSElliott Hughes./echo 'xxA
314*9a7741deSElliott Hughesxxab
315*9a7741deSElliott Hughesxxbc
316*9a7741deSElliott Hughesxxab
317*9a7741deSElliott Hughesxx
318*9a7741deSElliott Hughesxx
319*9a7741deSElliott Hughesxxab
320*9a7741deSElliott Hughesxx
321*9a7741deSElliott Hughesxxef
322*9a7741deSElliott Hughesxx' >foo1
323*9a7741deSElliott Hughes$awk 'BEGIN {
324*9a7741deSElliott Hughes	x = "A"
325*9a7741deSElliott Hughes	printf("xx%-39s\n", substr(x,1,39))
326*9a7741deSElliott Hughes	print "xx" substr("abcdef", 0, 2)
327*9a7741deSElliott Hughes	print "xx" substr("abcdef", 2.3, 2)
328*9a7741deSElliott Hughes	print "xx" substr("abcdef", -1, 2)
329*9a7741deSElliott Hughes	print "xx" substr("abcdef", 1, 0)
330*9a7741deSElliott Hughes	print "xx" substr("abcdef", 1, -3)
331*9a7741deSElliott Hughes	print "xx" substr("abcdef", 1, 2.3)
332*9a7741deSElliott Hughes	print "xx" substr("", 1, 2)
333*9a7741deSElliott Hughes	print "xx" substr("abcdef", 5, 5)
334*9a7741deSElliott Hughes	print "xx" substr("abcdef", 7, 2)
335*9a7741deSElliott Hughes	exit (0)
336*9a7741deSElliott Hughes}' >foo2
337*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk substr'
338*9a7741deSElliott Hughes
339*9a7741deSElliott Hughes# fldchg:
340*9a7741deSElliott Hughes./echo 'aa aab c d e f' >foo
341*9a7741deSElliott Hughes./echo '1: + +b c d e f
342*9a7741deSElliott Hughes2: + +b <c> d e f
343*9a7741deSElliott Hughes2a:%+%+b%<c>%d%e' >foo1
344*9a7741deSElliott Hughes$awk '{	gsub("aa", "+")
345*9a7741deSElliott Hughes	print "1:", $0
346*9a7741deSElliott Hughes	$3 = "<" $3 ">"
347*9a7741deSElliott Hughes	print "2:", $0
348*9a7741deSElliott Hughes	print "2a:" "%" $1 "%" $2 "%" $3 "%" $4 "%" $5
349*9a7741deSElliott Hughes}' foo >foo2
350*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk fldchg'
351*9a7741deSElliott Hughes
352*9a7741deSElliott Hughes# fldchgnf:
353*9a7741deSElliott Hughes./echo 'a b c d' >foo
354*9a7741deSElliott Hughes./echo 'a::c:d
355*9a7741deSElliott Hughes4' >foo1
356*9a7741deSElliott Hughes$awk '{ OFS = ":"; $2 = ""; print $0; print NF }' foo >foo2
357*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk fldchgnf'
358*9a7741deSElliott Hughes
359*9a7741deSElliott Hughes# funstack:
360*9a7741deSElliott Hughes# ./echo '	funstack test takes 5-10 sec, replicates part of T.beebe'
361*9a7741deSElliott Hughes$awk -f funstack.awk funstack.in >foo 2>&1
362*9a7741deSElliott Hughescmp -s foo funstack.ok || ./echo 'BAD: T.gawk funstack'
363*9a7741deSElliott Hughes
364*9a7741deSElliott Hughes# OFMT from arnold robbins 6/02:
365*9a7741deSElliott Hughes#	5.7 with OFMT = %0.f is 6
366*9a7741deSElliott Hughes./echo '6' >foo1
367*9a7741deSElliott Hughes$awk 'BEGIN {
368*9a7741deSElliott Hughes	OFMT = "%.0f"
369*9a7741deSElliott Hughes	print 5.7
370*9a7741deSElliott Hughes}' >foo2
371*9a7741deSElliott Hughescmp -s foo1 foo2 || ./echo 'BAD: T.gawk ofmt'
372*9a7741deSElliott Hughes
373*9a7741deSElliott Hughes
374*9a7741deSElliott Hughes### don't know what this is supposed to do now.
375*9a7741deSElliott Hughes### # convfmt:
376*9a7741deSElliott Hughes### ./echo 'a =  123.46
377*9a7741deSElliott Hughes### a =  123.456
378*9a7741deSElliott Hughes### a =  123.456' >foo1
379*9a7741deSElliott Hughes### $awk 'BEGIN {
380*9a7741deSElliott Hughes### 	CONVFMT = "%2.2f"
381*9a7741deSElliott Hughes### 	a = 123.456
382*9a7741deSElliott Hughes### 	b = a ""                # give a string value also
383*9a7741deSElliott Hughes### 	a += 0                  # make a numeric only again
384*9a7741deSElliott Hughes### 	print "a = ", a
385*9a7741deSElliott Hughes### 	CONVFMT = "%.6g"
386*9a7741deSElliott Hughes### 	print "a = ", a
387*9a7741deSElliott Hughes### 	a += 0                  # make a numeric only again
388*9a7741deSElliott Hughes### 	print "a = ", a    # use a as string
389*9a7741deSElliott Hughes### }' >foo2
390*9a7741deSElliott Hughes### cmp -s foo1 foo2 || ./echo 'BAD: T.gawk convfmt'
391