Patch 8.2.0899
Problem:    Assert_equalfile() does not give a hint about the difference.
Solution:   Display the last seen text.
Files:      src/testing.c, src/testdir/test_assert.vim


*** ../vim-8.2.0898/src/testing.c       2020-06-03 19:55:31.115092047 +0200
--- src/testing.c       2020-06-04 16:39:56.112078820 +0200
***************
*** 309,314 ****
--- 309,317 ----
      garray_T  ga;
      FILE      *fd1;
      FILE      *fd2;
+     char      line1[200];
+     char      line2[200];
+     int               lineidx = 0;
  
      if (fname1 == NULL || fname2 == NULL)
        return 0;
***************
*** 329,336 ****
        }
        else
        {
!           int c1, c2;
!           long count = 0;
  
            for (;;)
            {
--- 332,340 ----
        }
        else
        {
!           int     c1, c2;
!           long    count = 0;
!           long    linecount = 1;
  
            for (;;)
            {
***************
*** 347,359 ****
                    STRCPY(IObuff, "second file is shorter");
                    break;
                }
!               else if (c1 != c2)
                {
!                   vim_snprintf((char *)IObuff, IOSIZE,
!                                             "difference at byte %ld", count);
!                   break;
                }
                ++count;
            }
            fclose(fd1);
            fclose(fd2);
--- 351,381 ----
                    STRCPY(IObuff, "second file is shorter");
                    break;
                }
!               else
                {
!                   line1[lineidx] = c1;
!                   line2[lineidx] = c2;
!                   ++lineidx;
!                   if (c1 != c2)
!                   {
!                       vim_snprintf((char *)IObuff, IOSIZE,
!                                           "difference at byte %ld, line %ld",
!                                                            count, linecount);
!                       break;
!                   }
                }
                ++count;
+               if (c1 == NL)
+               {
+                   ++linecount;
+                   lineidx = 0;
+               }
+               else if (lineidx + 2 == (int)sizeof(line1))
+               {
+                   mch_memmove(line1, line1 + 100, lineidx - 100);
+                   mch_memmove(line2, line2 + 100, lineidx - 100);
+                   lineidx -= 100;
+               }
            }
            fclose(fd1);
            fclose(fd2);
***************
*** 372,377 ****
--- 394,412 ----
            ga_concat(&ga, (char_u *)": ");
        }
        ga_concat(&ga, IObuff);
+       if (lineidx > 0)
+       {
+           line1[lineidx] = NUL;
+           line2[lineidx] = NUL;
+           ga_concat(&ga, (char_u *)" after \"");
+           ga_concat(&ga, (char_u *)line1);
+           if (STRCMP(line1, line2) != 0)
+           {
+               ga_concat(&ga, (char_u *)"\" vs \"");
+               ga_concat(&ga, (char_u *)line2);
+           }
+           ga_concat(&ga, (char_u *)"\"");
+       }
        assert_error(&ga);
        ga_clear(&ga);
        return 1;
*** ../vim-8.2.0898/src/testdir/test_assert.vim 2020-06-03 19:55:31.115092047 
+0200
--- src/testdir/test_assert.vim 2020-06-04 16:51:56.630174938 +0200
***************
*** 78,88 ****
    call writefile(['1234X89'], 'Xone')
    call writefile(['1234Y89'], 'Xtwo')
    call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
!   call assert_match("difference at byte 4", v:errors[0])
    call remove(v:errors, 0)
  
    call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message'))
!   call assert_match("a message: difference at byte 4", v:errors[0])
    call remove(v:errors, 0)
  
    call delete('Xone')
--- 78,95 ----
    call writefile(['1234X89'], 'Xone')
    call writefile(['1234Y89'], 'Xtwo')
    call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
!   call assert_match('difference at byte 4, line 1 after "1234X" vs "1234Y"', 
v:errors[0])
!   call remove(v:errors, 0)
! 
!   call writefile([repeat('x', 234) .. 'X'], 'Xone')
!   call writefile([repeat('x', 234) .. 'Y'], 'Xtwo')
!   call assert_equal(1, assert_equalfile('Xone', 'Xtwo'))
!   let xes = repeat('x', 134)
!   call assert_match('difference at byte 234, line 1 after "' .. xes .. 'X" vs 
"' .. xes .. 'Y"', v:errors[0])
    call remove(v:errors, 0)
  
    call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message'))
!   call assert_match("a message: difference at byte 234, line 1 after", 
v:errors[0])
    call remove(v:errors, 0)
  
    call delete('Xone')
*** ../vim-8.2.0898/src/version.c       2020-06-04 15:52:06.095922759 +0200
--- src/version.c       2020-06-04 16:39:10.180208182 +0200
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     899,
  /**/

-- 
GOD: That is your purpose Arthur ... the Quest for the Holy Grail ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202006041453.054ErSoG755497%40masaka.moolenaar.net.

Raspunde prin e-mail lui