Results for assoc.test.sh

casebashoshosh_ALTdescription
0pass pass pass Literal syntax ([x]=y)
1pass FAIL FAIL set associative array to indexed array literal (bash anomaly)
detailsdetails
2BUG FAIL FAIL Can't initialize assoc array with indexed array
detailsdetailsdetails
3BUG FAIL FAIL Initializing indexed array with assoc array
detailsdetailsdetails
4pass pass pass create empty assoc array, put, then get
5pass pass pass retrieve keys with !
6pass pass pass retrieve values with ${A[@]}
7pass FAIL FAIL coerce to string with ${A[*]}, etc.
detailsdetails
8pass pass pass ${A[@]/b/B}
9pass pass pass ${A[@]#prefix}
10pass ok ok ${assoc} disallowed in OSH, like ${assoc[0]} in bash
detailsdetails
11pass pass pass length ${#a[@]}
12pass pass pass lookup with ${a[0]} -- "0" is a string
13pass pass pass lookup with double quoted strings "mykey"
14pass pass pass lookup with single quoted string
15pass pass pass lookup with unquoted $key and quoted "$i$i"
16BUG pass pass lookup by unquoted string doesn't work in OSH because it's a variable
details
17BUG pass pass bash bug: "i+1" and i+1 are the same key
details
18pass pass pass Array stored in associative array gets converted to string (without strict-array)
19pass pass pass Indexed array as key of associative array coerces to string (without shopt -s strict-array)
20pass pass pass Append to associative array value A['x']+='suffix'
21BUG pass pass Slice of associative array doesn't make sense in bash
details
22pass N-I N-I bash variable can have an associative array part and a string part
detailsdetails
23pass N-I N-I Associative array expressions inside (( )) with keys that look like numbers
detailsdetails
24pass pass pass (( A[5] += 42 ))
25pass pass pass (( A[5] += 42 )) with empty cell

59 passed, 2 ok, 4 known unimplemented, 5 known bugs, 4 failed, 0 skipped

Details on runs that didn't PASS

osh1 set associative array to indexed array literal (bash anomaly)

[osh stdout] Expected "['foo', 'spam eggs']\n['k1', 'k2']\n[]\n[]\n", got "[]\n[]\n['foo', 'spam eggs']\n['0', '1']\n"

stdout:
[]
[]
['foo', 'spam eggs']
['0', '1']
stderr:
osh_ALT1 set associative array to indexed array literal (bash anomaly)

[osh_ALT stdout] Expected "['foo', 'spam eggs']\n['k1', 'k2']\n[]\n[]\n", got "[]\n[]\n['foo', 'spam eggs']\n['0', '1']\n"

stdout:
[]
[]
['foo', 'spam eggs']
['0', '1']
stderr:
bash2 Can't initialize assoc array with indexed array

stdout:
stderr: 
_tmp/spec-bin/bash: line 1: A: 1: must use subscript when assigning associative array
_tmp/spec-bin/bash: line 1: A: 2: must use subscript when assigning associative array
_tmp/spec-bin/bash: line 1: A: 3: must use subscript when assigning associative array
osh2 Can't initialize assoc array with indexed array

[osh status] Expected 1, got 0

stdout:
stderr: 
osh_ALT2 Can't initialize assoc array with indexed array

[osh_ALT status] Expected 1, got 0

stdout:
stderr: 
bash3 Initializing indexed array with assoc array

stdout:
['3']
stderr:
osh3 Initializing indexed array with assoc array

[osh stdout] Expected u'', got "['2', '1', '3']\n"
[osh status] Expected 1, got 0

stdout:
['2', '1', '3']
stderr:
osh_ALT3 Initializing indexed array with assoc array

[osh_ALT stdout] Expected u'', got "['2', '1', '3']\n"
[osh_ALT status] Expected 1, got 0

stdout:
['2', '1', '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:
osh_ALT7 coerce to string with ${A[*]}, etc.

[osh_ALT 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 *)
osh_ALT10 ${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 *)
osh_ALT22 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
osh_ALT23 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