xref: /illumos-gate/usr/src/test/util-tests/tests/awk/gnu/aryunasgn.awk (revision e6d6c189fa3a95d7aa27bbe0aeacf7c1a6b57c8c)
1*e6d6c189SCody Peter MelloBEGIN {
2*e6d6c189SCody Peter Mello    a[i] = "null"                         # i is initially undefined
3*e6d6c189SCody Peter Mello    for (i in a) {                        # i is null string
4*e6d6c189SCody Peter Mello        print length(i), a[i] # , typeof(i)  # 0 null
5*e6d6c189SCody Peter Mello        print (i==0), (i=="")             # 1 1  should be  0 1
6*e6d6c189SCody Peter Mello    }
7*e6d6c189SCody Peter Mello    print a[""]                           # null
8*e6d6c189SCody Peter Mello    print a[0]                            #
9*e6d6c189SCody Peter Mello
10*e6d6c189SCody Peter Mello    b[$2] = "null also"                   # $2 is also undefined
11*e6d6c189SCody Peter Mello    for (j in b) {
12*e6d6c189SCody Peter Mello        print length(j), a[j] # , typeof(i)  # 0 null
13*e6d6c189SCody Peter Mello        print (j==0), (j=="")             # 1 1  should be  0 1
14*e6d6c189SCody Peter Mello    }
15*e6d6c189SCody Peter Mello    print b[""]                           # null
16*e6d6c189SCody Peter Mello    print b[0]                            #
17*e6d6c189SCody Peter Mello}
18