@@ -1552,6 +1552,41 @@ describe('patch/apply', function() {
15521552      expect ( applyPatch ( oldFile ,  diffFile ,  { fuzzFactor : 1 } ) ) . to . equal ( oldFile ) ; 
15531553    } ) ; 
15541554
1555+     describe ( 'when the last line is changed but both old & new version have no trailing newline...' ,  ( )  =>  { 
1556+       const  diffFile  =  'Index: file.txt\n'  + 
1557+         '===================================================================\n'  + 
1558+         '--- file.txt\n'  + 
1559+         '+++ file.txt\n'  + 
1560+         '@@ -1,4 +1,4 @@\n'  + 
1561+         ' foo\n'  + 
1562+         ' bar\n'  + 
1563+         ' baz\n'  + 
1564+         '-banana\n'  + 
1565+         '\\ No newline at end of file\n'  + 
1566+         '+babaco\n'  + 
1567+         '\\ No newline at end of file\n' ; 
1568+ 
1569+       it ( 'correctly applies the patch to the original source file' ,  ( )  =>  { 
1570+         const  oldFile  =  'foo\nbar\nbaz\nbanana' ; 
1571+         expect ( applyPatch ( oldFile ,  diffFile ) ) . to . equal ( 'foo\nbar\nbaz\nbabaco' ) ; 
1572+       } ) ; 
1573+ 
1574+       it ( 'fails if fuzzFactor=0 and the source file has an unexpected trailing newline' ,  ( )  =>  { 
1575+         const  oldFile  =  'foo\nbar\nbaz\nbanana\n' ; 
1576+         expect ( applyPatch ( oldFile ,  diffFile ) ) . to . equal ( false ) ; 
1577+       } ) ; 
1578+ 
1579+       it ( 'ignores an unexpected trailing newline if fuzzFactor > 0' ,  ( )  =>  { 
1580+         const  oldFile  =  'foo\nbar\nbaz\nbanana\n' ; 
1581+         expect ( applyPatch ( oldFile ,  diffFile ,  { fuzzFactor : 1 } ) ) . to . equal ( 'foo\nbar\nbaz\nbabaco\n' ) ; 
1582+       } ) ; 
1583+ 
1584+       it ( "ignores extra lines, even with fuzzFactor = 0, as long as there's no newline at EOF" ,  ( )  =>  { 
1585+         const  oldFile  =  'foo\nbar\nbaz\nbanana\nqux' ; 
1586+         expect ( applyPatch ( oldFile ,  diffFile ) ) . to . equal ( 'foo\nbar\nbaz\nbabaco\nqux' ) ; 
1587+       } ) ; 
1588+     } ) ; 
1589+ 
15551590    it ( 'rejects negative or non-integer fuzz factors' ,  ( )  =>  { 
15561591      expect ( ( )  =>  { 
15571592        applyPatch ( 
0 commit comments