Results for array-assoc.test.sh

statusbash-4osh
pass 3438
ok 11
N-I 11
BUG 60
FAIL 02
total4242
casebash-4oshdescription
0pass pass Literal syntax ([x]=y)
1N-I pass set associative array to indexed array literal (very surprising bash behavior)
details
2BUG pass Can initialize assoc array with the "(key value ...)" sequence
details
3pass pass create empty assoc array, put, then get
4pass pass Empty value (doesn't use EmptyWord?)
5pass pass retrieve keys with !
6pass pass retrieve values with ${A[@]}
7pass pass coerce to string with ${A[*]}, etc.
8pass pass ${A[@]/b/B}
9pass pass ${A[@]#prefix}
10pass pass ${assoc} is like ${assoc[0]}
11pass pass length ${#a[@]}
12pass pass lookup with ${a[0]} -- "0" is a string
13pass pass lookup with double quoted strings "mykey"
14pass pass lookup with single quoted string
15pass pass lookup with unquoted $key and quoted "$i$i"
16BUG pass lookup by unquoted string doesn't work in OSH because it's a variable
details
17BUG pass bash bug: "i+1" and i+1 are the same key
details
18pass pass Array stored in associative array gets converted to string (without strict_array)
19pass pass Indexed array as key of associative array coerces to string (without shopt -s strict_array)
20pass pass Append to associative array value A['x']+='suffix'
21BUG pass Slice of associative array doesn't make sense in bash
details
22pass N-I bash variable can have an associative array part and a string part
details
23pass pass Associative array expressions inside (( )) with keys that look like numbers
24pass pass (( A[5] += 42 ))
25pass pass (( A[5] += 42 )) with empty cell
26BUG pass setting key to itself (from bash-bug mailing list)
details
27pass ok readonly associative array can't be modified
details
28pass pass associative array and brace expansion
29pass pass declare -A A=() allowed
30pass pass unset -v and assoc array
31pass FAIL nameref and assoc array
details
32pass pass ${!ref} and assoc array
33pass pass printf -v and assoc array
34BUG pass bash bug: (( A["$key"] = 1 )) doesn't work
details
35pass pass Implicit increment of keys
36pass pass test -v assoc[key]
37pass FAIL test -v with dynamic parsing
details
38pass pass [[ -v assoc[key] ]]
39pass pass [[ -v assoc[key] ]] syntax errors
40pass pass BashAssoc a+=()
41ok pass BashAssoc ${a[@]@Q}
details
72 passed, 2 OK, 2 not implemented, 6 BUG, 2 failed, 0 timeouts, 0 cases skipped
2 failed under osh

Details on runs that didn't PASS

bash-41 set associative array to indexed array literal (very surprising bash behavior)

stdout:
declare -A assoc=([k1]="foo" [k2]="spam eggs" )
declare -A assoc=()
stderr:
bash-4.4: line 5: assoc: foo: must use subscript when assigning associative array
bash-4.4: line 5: assoc: 'spam eggs': must use subscript when assigning associative array
bash-42 Can initialize assoc array with the "(key value ...)" sequence

stdout:
status=0
declare -A A=()
stderr:
bash-4.4: line 1: A: 1: must use subscript when assigning associative array
bash-4.4: line 1: A: 2: must use subscript when assigning associative array
bash-4.4: line 1: A: 3: must use subscript when assigning associative array
bash-416 lookup by unquoted string doesn't work in OSH because it's a variable

stdout:
c
stderr:
bash-417 bash bug: "i+1" and i+1 are the same key

stdout:
array[i]=6
array[i+1]=7
assoc[i]=string
assoc[i+1]=string+1
assoc[i]=string
assoc[i+1]=string+1
stderr:
bash-421 Slice of associative array doesn't make sense in bash

stdout:
['2', '1', '5']
['2', '1', '5']
['1', '5', '4']
['5', '4', '3']
['4', '3']
['3']
stderr:
osh22 bash variable can have an associative array part and a string part

stdout:
1 2
1 2 zero
stderr:
  echo ${assoc[1]} ${assoc[2]} ${assoc}
         ^~~~~
[ stdin ]:8: fatal: Can't index string 'assoc' with integer
bash-426 setting key to itself (from bash-bug mailing list)

stdout:
value1
value2
stderr:
osh27 readonly associative array can't be modified

stdout:
stderr: 
  A['x']=1
  ^~
[ stdin ]:2: fatal: Can't assign to readonly associative array
osh31 nameref and assoc array

[osh stdout] Expected 'values: val\nbefore val\nafter val2\nvalues: val2\n---\nbefore val2\nafter val3\nvalues: val3\n' Got 'values: val\nbefore A["K"]\nafter val2\nvalues: val\n---\nbefore A[$key]\nafter val3\nvalues: val\n'

stdout:
values: val
before A["K"]
after val2
values: val
---
before A[$key]
after val3
values: val
stderr:
bash-434 bash bug: (( A["$key"] = 1 )) doesn't work

stdout:
[]
[]
stderr:
bash-4.4: line 6: ((: A[\] = 42 : bad array subscript (error token is "A[\] = 42 ")
osh37 test -v with dynamic parsing

[osh stdout] Expected 'empty=0\nk=0\nnonexistent=1\n', got 'empty=1\nk=1\nnonexistent=1\n'

stdout:
empty=1
k=1
nonexistent=1
stderr:
bash-441 BashAssoc ${a[@]@Q}

stdout:
['[]*?' ''\'''\''' '"' '()<>&|']
['[]*?' ''\'''\''' '"' '()<>&|']
stderr: