(command.CommandList
  children: [
    (command.Sentence child:(C {<Id.KW_Set set>} {<-u>}) terminator:<Id.Op_Semi _>)
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [
        (C {<Id.Lit_LBracket '['>} 
          {
            (braced_var_sub
              token: <Id.VSub_Name COMMON_SH>
              suffix_op: (suffix_op.Unary op_id:Id.VTest_Plus arg_word:{<true>})
            )
          } {<Id.Lit_RBracket ']'>}
        )
        (command.ControlFlow token:<Id.ControlFlow_Return return>)
      ]
    )
    (C {<declare>} {<-g>} {<Id.Lit_VarLike 'COMMON_SH='> <true>})
    (command.ShFunction
      name: stderr
      body: 
        (command.BraceGroup
          children: [
            (command.Simple
              words: [{<echo>} {(DQ (${ Id.VSub_At '@'))}]
              redirects: [(redir.Redir op:<Id.Redir_GreatAnd '2>&'> fd:2 arg_word:{<1>})]
            )
          ]
        )
    )
    (command.ShFunction
      name: functionExists
      body: 
        (command.BraceGroup
          children: [
            (C {<declare>} {<Id.Lit_VarLike 'functionName='> (DQ (${ Id.VSub_Number 1))})
            (C {<declare>} 
              {<Id.Lit_VarLike 'type='> 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  command_list: 
                    (command.CommandList
                      children: [(C {<type>} {<-t>} {(DQ (${ Id.VSub_Name functionName))})]
                    )
                )
              }
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobNEqual
                              left: {($ Id.VSub_QMark '$?')}
                              right: {<0>}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})]
                  spids: [110 123]
                )
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_GlobDEqual
                              left: {($ Id.VSub_DollarName '$type')}
                              right: {(DQ <function>)}
                            )
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})]
                  spids: [135 150]
                )
              ]
              else_action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})]
            )
          ]
        )
    )
    (C {<declare>} {<-g>} {<-A>} 
      {<Id.Lit_VarLike 'ASSERT_RESULTS='> 
        (word_part.AssocArrayLiteral
          left: <Id.Op_LParen _>
          pairs: [{<total>} {<0>} {<passed>} {<0>} {<failed>} {<0>}]
        )
      }
    )
    (command.ShFunction
      name: 'assert::equals'
      body: 
        (command.BraceGroup
          children: [
            (C {<declare>} {<Id.Lit_VarLike 'expect='> ($ Id.VSub_Number '$1')})
            (C {<declare>} {<Id.Lit_VarLike 'actual='> ($ Id.VSub_Number '$2')})
            (C {<declare>} 
              {<Id.Lit_VarLike 'message='> 
                (braced_var_sub
                  token: <Id.VSub_At '@'>
                  suffix_op: (suffix_op.Slice begin:(arith_expr.ArithWord w:{<Id.Lit_Digits 3>}))
                )
              }
            )
            (command.DParen
              child: 
                (arith_expr.BinaryAssign
                  op_id: Id.Arith_PlusEqual
                  left: 
                    (sh_lhs_expr.IndexedName
                      name: ASSERT_RESULTS
                      index: (arith_expr.VarRef token:<Id.Lit_ArithVarLike total>)
                    )
                  right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                )
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {(DQ ($ Id.VSub_DollarName '$expect'))} 
                          {<Id.KW_Bang '!'> <Id.Lit_Equals '='>} {(DQ ($ Id.VSub_DollarName '$actual'))} {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (C {<echo>} 
                      {
                        (DQ <"FAILED ('"> ($ Id.VSub_DollarName '$expect') <"' != '"> 
                          ($ Id.VSub_DollarName '$actual') <"') "> ($ Id.VSub_DollarName '$message')
                        )
                      }
                    )
                    (C {<log>} 
                      {
                        (DQ <"FAILED ('"> ($ Id.VSub_DollarName '$expect') <"' != '"> 
                          ($ Id.VSub_DollarName '$actual') <"') "> ($ Id.VSub_DollarName '$message')
                        )
                      }
                    )
                    (command.DParen
                      child: 
                        (arith_expr.BinaryAssign
                          op_id: Id.Arith_PlusEqual
                          left: 
                            (sh_lhs_expr.IndexedName
                              name: ASSERT_RESULTS
                              index: (arith_expr.VarRef token:<Id.Lit_ArithVarLike failed>)
                            )
                          right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                        )
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Return return>
                      arg_word: {<1>}
                    )
                  ]
                  spids: [243 261]
                )
              ]
            )
            (C {<echo>} {(DQ <'PASSED '> ($ Id.VSub_DollarName '$message'))})
            (command.DParen
              child: 
                (arith_expr.BinaryAssign
                  op_id: Id.Arith_PlusEqual
                  left: 
                    (sh_lhs_expr.IndexedName
                      name: ASSERT_RESULTS
                      index: (arith_expr.VarRef token:<Id.Lit_ArithVarLike passed>)
                    )
                  right: (arith_expr.ArithWord w:{<Id.Lit_Digits 1>})
                )
            )
            (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})
          ]
        )
    )
    (command.ShFunction
      name: 'assert::report'
      body: 
        (command.BraceGroup
          children: [
            (C {<echo>} 
              {
                (DQ <'TESTS [total='> 
                  (braced_var_sub
                    token: <Id.VSub_Name ASSERT_RESULTS>
                    bracket_op: 
                      (bracket_op.ArrayIndex
                        expr: (arith_expr.VarRef token:<Id.Lit_ArithVarLike total>)
                      )
                  ) <'] [passed='> 
                  (braced_var_sub
                    token: <Id.VSub_Name ASSERT_RESULTS>
                    bracket_op: 
                      (bracket_op.ArrayIndex
                        expr: (arith_expr.VarRef token:<Id.Lit_ArithVarLike passed>)
                      )
                  ) <'] [failed='> 
                  (braced_var_sub
                    token: <Id.VSub_Name ASSERT_RESULTS>
                    bracket_op: 
                      (bracket_op.ArrayIndex
                        expr: (arith_expr.VarRef token:<Id.Lit_ArithVarLike failed>)
                      )
                  ) <']'>
                )
              }
            )
          ]
        )
    )
  ]
)