patch 8.2.3933: after ":cd" fails ":cd -" is incorrect

Problem:    After ":cd" fails ":cd -" is incorrect.
Solution:   Set the previous directory only after successfully changing
            directory. (Richard Doty, closes #9419, closes #8983)
diff --git a/src/testdir/test_cd.vim b/src/testdir/test_cd.vim
index 566e9f6..c2217c9 100644
--- a/src/testdir/test_cd.vim
+++ b/src/testdir/test_cd.vim
@@ -44,6 +44,13 @@
   cd -
   call assert_equal(path, getcwd())
 
+  " Test for :cd - after a failed :cd
+  call assert_fails('cd /nonexistent', 'E344:')
+  call assert_equal(path, getcwd())
+  cd -
+  call assert_equal(path_dotdot, getcwd())
+  cd -
+
   " Test for :cd - without a previous directory
   let lines =<< trim [SCRIPT]
     call assert_fails('cd -', 'E186:')