(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ (Token id:Id.Lit_Chars val:'add -e basic tests' span_id:15))}
          spids: [13]
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:(Token id:Id.Redir_Great val:'>' span_id:26) fd:-1 arg_word:{(file)})
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:30)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 46
          stdin_parts: [
            ('LO, praise of the prowess of people-kings\n')
            ('of spear-armed Danes, in days long sped,\n')
            ('we have heard, and what honor the athelings won!\n')
            ('Oft Scyld the Scefing from squadroned foes,\n')
            ('from many a tribe, the mead-bench tore,\n')
            ('awing the earls. Since erst he lay\n')
            ('friendless, a foundling, fate repaid him:\n')
            ('for he waxed under welkin, in wealth he throve,\n')
            ('till before him the folk, both far and near,\n')
            ('who house by the whale-path, heard his mandate,\n')
            ('gave him gifts:  a good king he!\n')
          ]
        )
      ]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:50)
          fd: -1
          arg_word: {(second-part)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:54)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 65
          stdin_parts: [
            ('To him an heir was afterward born,\n')
            ('a son in his halls, whom heaven sent\n')
            ('to favor the folk, feeling their woe\n')
            ('that erst they had lacked an earl for leader\n')
            ('so long a while; the Lord endowed him,\n')
            ("the Wielder of Wonder, with world's renown.\n")
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:setup span_id:70))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:74) (Token id:Id.Lit_Chars val:'\n' span_id:75) 
          (Token id:Id.Lit_Chars val:'\tgit add file &&\n' span_id:76) (Token id:Id.Lit_Chars val:'\ttest_tick &&\n' span_id:77) 
          (Token id:Id.Lit_Chars val:'\tgit commit -m initial file\n' span_id:78) (Token id:Id.Lit_Chars val:'\n' span_id:79)
        )
      }
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:85)
          fd: -1
          arg_word: {(expected-patch)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:89)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 116
          stdin_parts: [
            ('diff --git a/file b/file\n')
            ('index b9834b5..9020acb 100644\n')
            ('--- a/file\n')
            ('+++ b/file\n')
            ('@@ -1,11 +1,6 @@\n')
            ('-LO, praise of the prowess of people-kings\n')
            ('-of spear-armed Danes, in days long sped,\n')
            ('-we have heard, and what honor the athelings won!\n')
            ('-Oft Scyld the Scefing from squadroned foes,\n')
            ('-from many a tribe, the mead-bench tore,\n')
            ('-awing the earls. Since erst he lay\n')
            ('-friendless, a foundling, fate repaid him:\n')
            ('-for he waxed under welkin, in wealth he throve,\n')
            ('-till before him the folk, both far and near,\n')
            ('-who house by the whale-path, heard his mandate,\n')
            ('-gave him gifts:  a good king he!\n')
            ('+To him an heir was afterward born,\n')
            ('+a son in his halls, whom heaven sent\n')
            ('+to favor the folk, feeling their woe\n')
            ('+that erst they had lacked an earl for leader\n')
            ('+so long a while; the Lord endowed him,\n')
            ("+the Wielder of Wonder, with world's renown.\n")
          ]
        )
      ]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:(Token id:Id.Redir_Great val:'>' span_id:120) fd:-1 arg_word:{(patch)})
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:124)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 141
          stdin_parts: [
            ('diff --git a/file b/file\n')
            ('index b9834b5..ef6e94c 100644\n')
            ('--- a/file\n')
            ('+++ b/file\n')
            ('@@ -3,1 +3,333 @@ of spear-armed Danes, in days long sped,\n')
            (' we have heard, and what honor the athelings won!\n')
            ('+\n')
            (' Oft Scyld the Scefing from squadroned foes,\n')
            ('@@ -2,7 +1,5 @@ awing the earls. Since erst he lay\n')
            (' friendless, a foundling, fate repaid him:\n')
            ('+\n')
            (' for he waxed under welkin, in wealth he throve,\n')
          ]
        )
      ]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:145)
          fd: -1
          arg_word: {(expected)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:149)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 171
          stdin_parts: [
            ('diff --git a/file b/file\n')
            ('index b9834b5..ef6e94c 100644\n')
            ('--- a/file\n')
            ('+++ b/file\n')
            ('@@ -1,10 +1,12 @@\n')
            (' LO, praise of the prowess of people-kings\n')
            (' of spear-armed Danes, in days long sped,\n')
            (' we have heard, and what honor the athelings won!\n')
            ('+\n')
            (' Oft Scyld the Scefing from squadroned foes,\n')
            (' from many a tribe, the mead-bench tore,\n')
            (' awing the earls. Since erst he lay\n')
            (' friendless, a foundling, fate repaid him:\n')
            ('+\n')
            (' for he waxed under welkin, in wealth he throve,\n')
            (' till before him the folk, both far and near,\n')
            (' who house by the whale-path, heard his mandate,\n')
          ]
        )
      ]
    )
    (command.Simple
      words: [{(echo)} {(DQ ('#!') ($ Id.VSub_DollarName '$SHELL_PATH'))}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:180)
          fd: -1
          arg_word: {(fake-editor.sh)}
        )
      ]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_DGreat val:'>>' span_id:185)
          fd: -1
          arg_word: {(fake-editor.sh)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:189)
          fd: -1
          here_begin: 
            {(word_part.EscapedLiteral token:(Token id:Id.Lit_EscapedChar val:'\\E' span_id:190)) 
              (OF)
            }
          here_end_span_id: 195
          stdin_parts: [('mv -f "$1" orig-patch &&\n') ('mv -f patch "$1"\n')]
        )
      ]
    )
    (C {(test_set_editor)} 
      {
        (DQ 
          (command_sub
            left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:200)
            command_list: (command.CommandList children:[(C {(pwd)})])
          ) (/fake-editor.sh)
        )
      }
    )
    (C {(chmod)} {(a) (Id.Lit_Other '+') (x)} {(fake-editor.sh)})
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'add -e' span_id:218))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:222) (Token id:Id.Lit_Chars val:'\n' span_id:223) 
          (Token id:Id.Lit_Chars val:'\tcp second-part file &&\n' span_id:224) (Token id:Id.Lit_Chars val:'\tgit add -e &&\n' span_id:225) 
          (Token id:Id.Lit_Chars val:'\ttest_cmp second-part file &&\n' span_id:226) (Token id:Id.Lit_Chars val:'\ttest_cmp orig-patch expected-patch &&\n' span_id:227) 
          (Token id:Id.Lit_Chars val:'\tgit diff --cached > out &&\n' span_id:228) (Token id:Id.Lit_Chars val:'\ttest_cmp out expected\n' span_id:229) 
          (Token id:Id.Lit_Chars val:'\n' span_id:230)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'add -e notices editor failure' span_id:237))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:241) 
          (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:242) (Token id:Id.Lit_Chars val:'\techo change >>file &&\n' span_id:243) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail env GIT_EDITOR=false git add -e &&\n'
            span_id: 244
          ) (Token id:Id.Lit_Chars val:'\ttest_expect_code 1 git diff --exit-code\n' span_id:245)
        )
      }
    )
    (C {(test_done)})
  ]
)