xref: /aosp_15_r20/external/one-true-awk/testdir/T.delete (revision 9a7741de182b2776d7b30d6355f2585c0780a51b)
1*9a7741deSElliott Hughesecho T.delete: misc tests of array deletion
2*9a7741deSElliott Hughes
3*9a7741deSElliott Hughesawk=${awk-../a.out}
4*9a7741deSElliott Hughes
5*9a7741deSElliott Hughesecho '1 2 3 4
6*9a7741deSElliott Hughes1 2 3
7*9a7741deSElliott Hughes1
8*9a7741deSElliott Hughes' >foo0
9*9a7741deSElliott Hughesecho '4 3 0
10*9a7741deSElliott Hughes3 2 0
11*9a7741deSElliott Hughes1 0 0
12*9a7741deSElliott Hughes0 0 0' >foo2
13*9a7741deSElliott Hughes$awk '
14*9a7741deSElliott Hughes{	n = split($0, x)
15*9a7741deSElliott Hughes	delete x[1]
16*9a7741deSElliott Hughes	n1 = 0;	for (i in x) n1++
17*9a7741deSElliott Hughes	delete x;
18*9a7741deSElliott Hughes	n2 = 0; for (i in x) n2++
19*9a7741deSElliott Hughes	print n, n1, n2
20*9a7741deSElliott Hughes}' foo0 >foo1
21*9a7741deSElliott Hughesdiff foo1 foo2 || echo 'BAD: T.delete (1)'
22