Results for assoc.test.sh

statusbashosh
pass 2123
ok 02
N-I 02
BUG 70
FAIL 01
total2828
casebashoshdescription
0pass pass Literal syntax ([x]=y)
1BUG pass set associative array to indexed array literal (very surprising bash behavior)
details
2BUG pass Can't initialize assoc array with indexed array
details
3BUG pass Initializing indexed array with assoc array
details
4pass pass create empty assoc array, put, then get
5pass pass retrieve keys with !
6pass pass retrieve values with ${A[@]}
7pass FAIL coerce to string with ${A[*]}, etc.
details
8pass pass ${A[@]/b/B}
9pass pass ${A[@]#prefix}
10pass ok ${assoc} disallowed in OSH, like ${assoc[0]} in bash
details
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 N-I Associative array expressions inside (( )) with keys that look like numbers
details
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
44 passed, 2 OK, 2 not implemented, 7 BUG, 1 failed, 0 timeouts, 0 cases skipped
1 failed under osh

Details on runs that didn't PASS

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

stdout:
foo
spam eggs
k1
k2
[]
[]
stderr:
/home/andy/git/oilshell/oil/_tmp/spec-bin/bash: line 4: assoc: foo: must use subscript when assigning associative array
/home/andy/git/oilshell/oil/_tmp/spec-bin/bash: line 4: assoc: 'spam eggs': must use subscript when assigning associative array
bash2 Can't initialize assoc array with indexed array

stdout:
status=0
stderr:
/home/andy/git/oilshell/oil/_tmp/spec-bin/bash: line 1: A: 1: must use subscript when assigning associative array
/home/andy/git/oilshell/oil/_tmp/spec-bin/bash: line 1: A: 2: must use subscript when assigning associative array
/home/andy/git/oilshell/oil/_tmp/spec-bin/bash: line 1: A: 3: must use subscript when assigning associative array
bash3 Initializing indexed array with assoc array

stdout:
status=0
['3']
stderr:
osh7 coerce to string with ${A[*]}, etc.

[osh stdout] Expected "['xx yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n", got "['xx', 'yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n"

stdout:
['xx', 'yy']
['X X Y Y']
['xx', 'yy']
['X', 'X', 'Y', 'Y']
stderr:
osh10 ${assoc} disallowed in OSH, like ${assoc[0]} in bash

stdout:
stderr: 
  echo "${a}"
        ^~
[ stdin ]:3: fatal: Array 'a' can't be referred to as a scalar (without @ or *)
bash16 lookup by unquoted string doesn't work in OSH because it's a variable

stdout:
c
stderr:
bash17 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:
bash21 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:
stderr: 
  echo ${assoc[1]} ${assoc[2]} ${assoc}
                               ^~
[ stdin ]:4: fatal: Array 'assoc' can't be referred to as a scalar (without @ or *)
osh23 Associative array expressions inside (( )) with keys that look like numbers

stdout:
42
stderr:
  (( var = assoc[0] ))
  ^~
[ stdin ]:5: fatal: Can't evaluate associative arrays in arithmetic contexts
bash26 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