Results for assoc.test.sh

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

Details on runs that didn't PASS

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

stdout:
foo
spam eggs
k1
k2
[]
[]
stderr:
bash-4.4: line 6: assoc: foo: must use subscript when assigning associative array
bash-4.4: line 6: assoc: 'spam eggs': must use subscript when assigning associative array
bash-42 Can't initialize assoc array with indexed array

stdout:
status=0
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-43 Initializing indexed array with assoc array

stdout:
status=0
['3']
stderr:
bash-417 lookup by unquoted string doesn't work in OSH because it's a variable

stdout:
c
stderr:
bash-418 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:
osh21 Append to associative array value A['x']+='suffix'

[osh stdout] Expected "['foobarbar']\n", got ''
[osh status] Expected 0, got 1
[osh stderr] Found 'Traceback (most recent'

stdout:
stderr: 
Traceback (most recent call last):
  File "/home/uke/oil/bin/oils_for_unix.py", line 202, in <module>
    sys.exit(main(sys.argv))
  File "/home/uke/oil/bin/oils_for_unix.py", line 171, in main
    return AppBundleMain(argv)
  File "/home/uke/oil/bin/oils_for_unix.py", line 141, in AppBundleMain
    return shell.Main('osh', arg_r, environ, login_shell, loader, readline)
  File "/home/uke/oil/core/shell.py", line 1213, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/uke/oil/core/main_loop.py", line 375, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags)
  File "/home/uke/oil/osh/cmd_eval.py", line 2109, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/uke/oil/osh/cmd_eval.py", line 1908, in _Execute
    status = self._Dispatch(node, cmd_st)
  File "/home/uke/oil/osh/cmd_eval.py", line 1645, in _Dispatch
    status = self._DoShAssignment(node, cmd_st)
  File "/home/uke/oil/osh/cmd_eval.py", line 988, in _DoShAssignment
    node.left)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 130, in OldValue
    cell = mem.GetCellDeref(var_name)
  File "/home/uke/oil/core/state.py", line 2318, in GetCellDeref
    cell, _ = self._ResolveNameOrRef(name, which_scopes)
ValueError: too many values to unpack
bash-422 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:
osh23 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
osh25 (( A[5] += 42 ))

[osh stdout] Expected '16\n', got ''
[osh status] Expected 0, got 1
[osh stderr] Found 'Traceback (most recent'

stdout:
stderr: 
Traceback (most recent call last):
  File "/home/uke/oil/bin/oils_for_unix.py", line 202, in <module>
    sys.exit(main(sys.argv))
  File "/home/uke/oil/bin/oils_for_unix.py", line 171, in main
    return AppBundleMain(argv)
  File "/home/uke/oil/bin/oils_for_unix.py", line 141, in AppBundleMain
    return shell.Main('osh', arg_r, environ, login_shell, loader, readline)
  File "/home/uke/oil/core/shell.py", line 1213, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/uke/oil/core/main_loop.py", line 375, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags)
  File "/home/uke/oil/osh/cmd_eval.py", line 2109, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/uke/oil/osh/cmd_eval.py", line 1908, in _Execute
    status = self._Dispatch(node, cmd_st)
  File "/home/uke/oil/osh/cmd_eval.py", line 1681, in _Dispatch
    i = self.arith_ev.EvalToBigInt(node.child)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 553, in EvalToBigInt
    val = self.Eval(node)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 648, in Eval
    old_big, lval = self._EvalLhsAndLookupArith(node.left)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 520, in _EvalLhsAndLookupArith
    location.TokenForArith(node))
  File "/home/uke/oil/osh/sh_expr_eval.py", line 130, in OldValue
    cell = mem.GetCellDeref(var_name)
  File "/home/uke/oil/core/state.py", line 2318, in GetCellDeref
    cell, _ = self._ResolveNameOrRef(name, which_scopes)
ValueError: too many values to unpack
osh26 (( A[5] += 42 )) with empty cell

[osh stdout] Expected '6\n', got ''
[osh status] Expected 0, got 1
[osh stderr] Found 'Traceback (most recent'

stdout:
stderr: 
Traceback (most recent call last):
  File "/home/uke/oil/bin/oils_for_unix.py", line 202, in <module>
    sys.exit(main(sys.argv))
  File "/home/uke/oil/bin/oils_for_unix.py", line 171, in main
    return AppBundleMain(argv)
  File "/home/uke/oil/bin/oils_for_unix.py", line 141, in AppBundleMain
    return shell.Main('osh', arg_r, environ, login_shell, loader, readline)
  File "/home/uke/oil/core/shell.py", line 1213, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/uke/oil/core/main_loop.py", line 375, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags)
  File "/home/uke/oil/osh/cmd_eval.py", line 2109, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/uke/oil/osh/cmd_eval.py", line 1908, in _Execute
    status = self._Dispatch(node, cmd_st)
  File "/home/uke/oil/osh/cmd_eval.py", line 1681, in _Dispatch
    i = self.arith_ev.EvalToBigInt(node.child)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 553, in EvalToBigInt
    val = self.Eval(node)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 648, in Eval
    old_big, lval = self._EvalLhsAndLookupArith(node.left)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 520, in _EvalLhsAndLookupArith
    location.TokenForArith(node))
  File "/home/uke/oil/osh/sh_expr_eval.py", line 130, in OldValue
    cell = mem.GetCellDeref(var_name)
  File "/home/uke/oil/core/state.py", line 2318, in GetCellDeref
    cell, _ = self._ResolveNameOrRef(name, which_scopes)
ValueError: too many values to unpack
bash-427 setting key to itself (from bash-bug mailing list)

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

stdout:
stderr: 
  A['x']=1
  ^~
[ stdin ]:2: fatal: Can't assign to readonly associative array
bash-430 bash mangles array #1

stdout:
v2
v2
stderr:
bash-431 bash mangles array and brace #2

stdout:
[k2]=-a-
stderr:
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:
bash-437 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 ")
osh38 Implicit increment of keys

[osh stdout] Expected "['30', '31', '40', '41']\n['a', 'b', 'x', 'y']\n" Got ''
[osh status] Expected 0, got 2

stdout:
stderr: 
  declare -a arr=( [30]=a b [40]=x y)
                          ^
[ stdin ]:1: Expected associative array pair
osh40 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:
osh43 BashAssoc a+=()

[osh stdout] Expected 'apple is red\norange is orange\nlemon is yellow\nbanana is yellow\n' Got ''
[osh status] Expected 0, got 1
[osh stderr] Found 'Traceback (most recent'

stdout:
stderr: 
Traceback (most recent call last):
  File "/home/uke/oil/bin/oils_for_unix.py", line 202, in <module>
    sys.exit(main(sys.argv))
  File "/home/uke/oil/bin/oils_for_unix.py", line 171, in main
    return AppBundleMain(argv)
  File "/home/uke/oil/bin/oils_for_unix.py", line 141, in AppBundleMain
    return shell.Main('osh', arg_r, environ, login_shell, loader, readline)
  File "/home/uke/oil/core/shell.py", line 1213, in Main
    cmd_flags=cmd_eval.IsMainProgram)
  File "/home/uke/oil/core/main_loop.py", line 375, in Batch
    is_return, is_fatal = cmd_ev.ExecuteAndCatch(node, cmd_flags)
  File "/home/uke/oil/osh/cmd_eval.py", line 2109, in ExecuteAndCatch
    status = self._Execute(node)
  File "/home/uke/oil/osh/cmd_eval.py", line 1908, in _Execute
    status = self._Dispatch(node, cmd_st)
  File "/home/uke/oil/osh/cmd_eval.py", line 1645, in _Dispatch
    status = self._DoShAssignment(node, cmd_st)
  File "/home/uke/oil/osh/cmd_eval.py", line 988, in _DoShAssignment
    node.left)
  File "/home/uke/oil/osh/sh_expr_eval.py", line 130, in OldValue
    cell = mem.GetCellDeref(var_name)
  File "/home/uke/oil/core/state.py", line 2318, in GetCellDeref
    cell, _ = self._ResolveNameOrRef(name, which_scopes)
ValueError: too many values to unpack
bash-444 BashAssoc ${a[@]@Q}

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