.
----------------------------------------------------------------------
Ran 1 test in 0.013s

OK

--- foo

{<Id.Lit_Chars foo>}

--- 'hi'

{(SQ hi)}

--- $var

{($ var)}

--- ${var}

{(${ Id.VSub_Name var)}

---  "$var" 

{(DQ ($ var))}

---  "${var}" 

{(DQ (${ Id.VSub_Name var))}

---  $((1+2)) 

{
  (word_part.ArithSub
    left: <Id.Left_DollarDParen "$((">
    anode: 
      (arith_expr.Binary
        op: <Id.Arith_Plus "+">
        left: {<Id.Lit_Digits 1>}
        right: {<Id.Lit_Digits 2>}
      )
    right: <Id.Right_DollarDParen ")">
  )
}

---  $(echo hi) 

{
  (CommandSub
    left_token: <Id.Left_DollarParen "$(">
    child: 
      (command.Simple
        blame_tok: <Id.Lit_Chars echo>
        more_env: []
        words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars hi>}]
        is_last_cmd: F
      )
    right: <Id.Eof_RParen ")">
  )
}

---  "$((1+2))" 

{
  (DQ 
    (word_part.ArithSub
      left: <Id.Left_DollarDParen "$((">
      anode: 
        (arith_expr.Binary
          op: <Id.Arith_Plus "+">
          left: {<Id.Lit_Digits 1>}
          right: {<Id.Lit_Digits 2>}
        )
      right: <Id.Right_DollarDParen ")">
    )
  )
}

---  "$(echo hi)" 

{
  (DQ 
    (CommandSub
      left_token: <Id.Left_DollarParen "$(">
      child: 
        (command.Simple
          blame_tok: <Id.Lit_Chars echo>
          more_env: []
          words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars hi>}]
          is_last_cmd: F
        )
      right: <Id.Eof_RParen ")">
    )
  )
}

---  $src/file 

{($ src) <Id.Lit_Slash /> <Id.Lit_Chars file>}

---  ${src}/file 

{(${ Id.VSub_Name src) <Id.Lit_Slash /> <Id.Lit_Chars file>}

---  "$src/file" 

{(DQ ($ src) <Id.Lit_Chars /file>)}

---  "${src}/file" 

{(DQ (${ Id.VSub_Name src) <Id.Lit_Chars /file>)}

---  $((1+2))$(echo hi) 

{
  (word_part.ArithSub
    left: <Id.Left_DollarDParen "$((">
    anode: 
      (arith_expr.Binary
        op: <Id.Arith_Plus "+">
        left: {<Id.Lit_Digits 1>}
        right: {<Id.Lit_Digits 2>}
      )
    right: <Id.Right_DollarDParen ")">
  ) 
  (CommandSub
    left_token: <Id.Left_DollarParen "$(">
    child: 
      (command.Simple
        blame_tok: <Id.Lit_Chars echo>
        more_env: []
        words: [{<Id.Lit_Chars echo>} {<Id.Lit_Chars hi>}]
        is_last_cmd: F
      )
    right: <Id.Eof_RParen ")">
  )
}

---  ~/src 

{<Id.Lit_Tilde "~"> <Id.Lit_Slash /> <Id.Lit_Chars src>}

---  ~bob/foo 

{<Id.Lit_Tilde "~"> <Id.Lit_Chars bob> <Id.Lit_Slash /> <Id.Lit_Chars foo>}

--- notleading~

{<Id.Lit_Chars notleading> <Id.Lit_Tilde "~">}

---  "~/src" 

{(DQ <Id.Lit_Chars "~/src">)}

---  "~bob/foo" 

{(DQ <Id.Lit_Chars "~bob/foo">)}