Results for assoc.test.sh

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

Details on runs that didn't PASS

osh_.py1 set associative array to indexed array literal (very surprising bash behavior)

[osh_.py stdout] Expected "foo\nspam eggs\nk1\nk2\n['foo', 'spam eggs']\n['0', '1']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  for v in "${assoc[@]}"; do echo $v; done | sort
                                             ^~~~
[ stdin ]:2: 'sort' not found
  for v in "${!assoc[@]}"; do echo $v; done | sort
                                              ^~~~
[ stdin ]:3: 'sort' not found
  argv.py "${assoc[@]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
  argv.py "${!assoc[@]}"
  ^~~~~~~
[ stdin ]:6: 'argv.py' not found
osh_.cc1 set associative array to indexed array literal (very surprising bash behavior)

[osh_.cc stdout] Expected "foo\nspam eggs\nk1\nk2\n['foo', 'spam eggs']\n['0', '1']\n", got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.py3 Initializing indexed array with assoc array

[osh_.py stdout] Expected 'status=2\n[]\n', got 'status=2\n'
[osh_.py status] Expected 0, got 127

stdout:
status=2
stderr:
  declare -a a=([xx]=1 [yy]=2 [zz]=3)
             ^~
[ stdin ]:1: 'declare' Got -a but RHS isn't an array
  argv.py "${a[@]}"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh_.cc3 Initializing indexed array with assoc array

[osh_.cc stdout] Expected 'status=2\n[]\n', got 'status=2\n'
[osh_.cc status] Expected 0, got 127

stdout:
status=2
stderr:
  declare -a a=([xx]=1 [yy]=2 [zz]=3)
             ^~
[ stdin ]:1: 'declare' Got -a but RHS isn't an array
  argv.py "${a[@]}"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh_.py4 create empty assoc array, put, then get

[osh_.py stdout] Expected '[]\n[]\nbar\n', got 'bar\n'

stdout:
bar
stderr:
  argv.py "${A[@]}"
  ^~~~~~~
[ stdin ]:2: 'argv.py' not found
  argv.py "${!A[@]}"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh_.cc4 create empty assoc array, put, then get

[osh_.cc stdout] Expected '[]\n[]\nbar\n', got 'bar\n'

stdout:
bar
stderr:
  argv.py "${A[@]}"
  ^~~~~~~
[ stdin ]:2: 'argv.py' not found
  argv.py "${!A[@]}"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh_.py5 Empty value (doesn't use EmptyWord?)

[osh_.py stdout] Expected "['']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${A["k"]}"
  ^~~~~~~
[ stdin ]:2: 'argv.py' not found
osh_.cc5 Empty value (doesn't use EmptyWord?)

[osh_.cc stdout] Expected "['']\n", got ''
[osh_.cc status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${A["k"]}"
  ^~~~~~~
[ stdin ]:2: 'argv.py' not found
osh_.py6 retrieve keys with !

[osh_.py stdout] Expected 'a+1\nfoo\nx\n', got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  done | sort
         ^~~~
[ stdin ]:8: 'sort' not found
osh_.cc6 retrieve keys with !

[osh_.cc stdout] Expected 'a+1\nfoo\nx\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.py7 retrieve values with ${A[@]}

[osh_.py stdout] Expected 'b\nbar\nc\n', got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  done | sort
         ^~~~
[ stdin ]:8: 'sort' not found
osh_.cc7 retrieve values with ${A[@]}

[osh_.cc stdout] Expected 'b\nbar\nc\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh8 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_.py8 coerce to string with ${A[*]}, etc.

[osh_.py stdout] Expected "['xx yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${A[*]}"
  ^~~~~~~
[ stdin ]:4: 'argv.py' not found
  argv.py "${!A[*]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
  argv.py ${A[@]}
  ^~~~~~~
[ stdin ]:6: 'argv.py' not found
  argv.py ${!A[@]}
  ^~~~~~~
[ stdin ]:7: 'argv.py' not found
osh_.cc8 coerce to string with ${A[*]}, etc.

[osh_.cc stdout] Expected "['xx yy']\n['X X Y Y']\n['xx', 'yy']\n['X', 'X', 'Y', 'Y']\n", got ''
[osh_.cc status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${A[*]}"
  ^~~~~~~
[ stdin ]:4: 'argv.py' not found
  argv.py "${!A[*]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
  argv.py ${A[@]}
  ^~~~~~~
[ stdin ]:6: 'argv.py' not found
  argv.py ${!A[@]}
  ^~~~~~~
[ stdin ]:7: 'argv.py' not found
osh_.py9 ${A[@]/b/B}

[osh_.py stdout] Expected 'BBB\nccc\nddd\n', got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  done | sort
         ^~~~
[ stdin ]:7: 'sort' not found
osh_.cc9 ${A[@]/b/B}

[osh_.cc stdout] Expected 'BBB\nccc\nddd\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.py10 ${A[@]#prefix}

[osh_.py stdout] Expected 'hree\none\nwo\n', got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  done | sort
         ^~~~
[ stdin ]:7: 'sort' not found
osh_.cc10 ${A[@]#prefix}

[osh_.cc stdout] Expected 'hree\none\nwo\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh11 ${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_.py11 ${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_.cc11 ${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_.py19 Array stored in associative array gets converted to string (without strict_array)

[osh_.py stdout] Expected "['1 2 3']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${d['key']}"
  ^~~~~~~
[ stdin ]:4: 'argv.py' not found
osh_.cc19 Array stored in associative array gets converted to string (without strict_array)

[osh_.cc stdout] Expected "['1 2 3']\n", got ''
[osh_.cc status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${d['key']}"
  ^~~~~~~
[ stdin ]:4: 'argv.py' not found
osh_.py20 Indexed array as key of associative array coerces to string (without shopt -s strict_array)

[osh_.py stdout] Expected 'foo\n1 2 3\n42\n', got 'foo\n'
[osh_.py status] Expected 0, got 127

stdout:
foo
stderr:
  done | sort
         ^~~~
[ stdin ]:8: 'sort' not found
osh_.cc20 Indexed array as key of associative array coerces to string (without shopt -s strict_array)

[osh_.cc stdout] Expected 'foo\n1 2 3\n42\n', got 'foo\n'
[osh_.cc status] Expected 0, got -6

stdout:
foo
stderr:
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.py21 Append to associative array value A['x']+='suffix'

[osh_.py stdout] Expected "['foobarbar']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${A["x"]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
osh_.cc21 Append to associative array value A['x']+='suffix'

[osh_.cc stdout] Expected "['foobarbar']\n", got ''
[osh_.cc status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${A["x"]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
osh23 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_.py23 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_.cc23 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 *)
osh28 readonly associative array can't be modified

stdout:
stderr: 
  A['x']=1
  ^~
[ stdin ]:2: fatal: Can't assign to readonly associative array
osh_.py28 readonly associative array can't be modified

stdout:
stderr: 
  A['x']=1
  ^~
[ stdin ]:2: fatal: Can't assign to readonly associative array
osh_.cc28 readonly associative array can't be modified

stdout:
stderr: 
  A['x']=1
  ^~
[ stdin ]:2: fatal: Can't assign to readonly associative array
osh_.cc33 unset -v and assoc array

[osh_.cc stdout] Expected 'len=1\nlen=0\nlen=1\nlen=0\nlen=1\nlen=0\n', got 'len=1\nlen=0\nlen=1\nlen=0\nlen=1\n'
[osh_.cc status] Expected 0, got -6

stdout:
len=1
len=0
len=1
len=0
len=1
stderr:
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh34 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:
osh_.py34 nameref and assoc array

[osh_.py 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:
osh_.cc34 nameref and assoc array

[osh_.cc 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:
osh35 ${!ref} and assoc array

[osh stdout] Expected 'values: val\nref val\nref val\n', got 'values: val\nref\nref\n'

stdout:
values: val
ref
ref
stderr:
osh_.py35 ${!ref} and assoc array

[osh_.py stdout] Expected 'values: val\nref val\nref val\n', got 'values: val\nref\nref\n'

stdout:
values: val
ref
ref
stderr:
osh_.cc35 ${!ref} and assoc array

[osh_.cc stdout] Expected 'values: val\nref val\nref val\n', got 'values: val\nref\nref\n'

stdout:
values: val
ref
ref
stderr:
osh36 printf -v and assoc array

[osh stdout] Expected 'values: val\nvalues: /val2/\nvalues: /val3/\n', got 'values: val\nvalues: val\nvalues: val\n'

stdout:
values: val
values: val
values: val
stderr:
  printf -v 'assoc["K"]' '/%s/' val2
  ^~~~~~
[ stdin ]:6: 'printf' -v expected a variable name.  shopt -s eval_unsafe_arith allows expressions
  printf -v 'assoc[$key]' '/%s/' val3
  ^~~~~~
[ stdin ]:9: 'printf' -v expected a variable name.  shopt -s eval_unsafe_arith allows expressions
osh_.py36 printf -v and assoc array

[osh_.py stdout] Expected 'values: val\nvalues: /val2/\nvalues: /val3/\n', got 'values: val\nvalues: val\nvalues: val\n'

stdout:
values: val
values: val
values: val
stderr:
  printf -v 'assoc["K"]' '/%s/' val2
  ^~~~~~
[ stdin ]:6: 'printf' -v expected a variable name.  shopt -s eval_unsafe_arith allows expressions
  printf -v 'assoc[$key]' '/%s/' val3
  ^~~~~~
[ stdin ]:9: 'printf' -v expected a variable name.  shopt -s eval_unsafe_arith allows expressions
osh_.cc36 printf -v and assoc array

[osh_.cc stdout] Expected 'values: val\nvalues: /val2/\nvalues: /val3/\n', got 'values: val\nvalues: val\nvalues: val\n'

stdout:
values: val
values: val
values: val
stderr:
  printf -v 'assoc["K"]' '/%s/' val2
  ^~~~~~
[ stdin ]:6: 'printf' -v expected a variable name.  shopt -s eval_unsafe_arith allows expressions
  printf -v 'assoc[$key]' '/%s/' val3
  ^~~~~~
[ stdin ]:9: 'printf' -v expected a variable name.  shopt -s eval_unsafe_arith allows expressions
osh_.py37 bash bug: (( A["$key"] = 1 )) doesn't work

[osh_.py stdout] Expected "['\\\\']\n['42']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${!A[@]}"
  ^~~~~~~
[ stdin ]:4: 'argv.py' not found
  argv.py "${A[@]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
osh_.cc37 bash bug: (( A["$key"] = 1 )) doesn't work

[osh_.cc stdout] Expected "['\\\\']\n['42']\n", got ''
[osh_.cc status] Expected 0, got 127

stdout:
stderr: 
  argv.py "${!A[@]}"
  ^~~~~~~
[ stdin ]:4: 'argv.py' not found
  argv.py "${A[@]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found