123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960 |
- local helpers = require('test.functional.helpers')(after_each)
- local Screen = require('test.functional.ui.screen')
- local feed = helpers.feed
- local clear = helpers.clear
- local write_file = helpers.write_file
- describe('Diff mode screen', function()
- local fname = 'Xtest-functional-diff-screen-1'
- local fname_2 = fname .. '.2'
- local screen
- local reread = function()
- feed(':e<cr><c-w>w:e<cr><c-w>w')
- end
- setup(function()
- clear()
- os.remove(fname)
- os.remove(fname_2)
- end)
- teardown(function()
- os.remove(fname)
- os.remove(fname_2)
- end)
- before_each(function()
- clear()
- feed(':e ' .. fname_2 .. '<cr>')
- feed(':vnew ' .. fname .. '<cr>')
- feed(':diffthis<cr>')
- feed('<c-w>w:diffthis<cr><c-w>w')
- screen = Screen.new(40, 16)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [3] = {reverse = true},
- [4] = {background = Screen.colors.LightBlue},
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {bold = true, reverse = true},
- [8] = {bold = true, background = Screen.colors.Red},
- [9] = {background = Screen.colors.LightMagenta},
- })
- end)
- it('Add a line in beginning of file 2', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1: }{2:------------------}{3:│}{1: }{4:0 }|
- {1: }^1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }{2:------------------}{3:│}{1: }{4:0 }|
- {1: }^1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line in beginning of file 1', function()
- write_file(fname, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(":set diffopt=filler<cr>")
- screen:expect([[
- {1: }{4:^0 }{3:│}{1: }{2:-----------------}|
- {1: }1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(":set diffopt+=internal<cr>")
- screen:expect([[
- {1: }{4:^0 }{3:│}{1: }{2:-----------------}|
- {1: }1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line at the end of file 2', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- reread()
- feed(":set diffopt=filler<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{2:------------------}{3:│}{1: }{4:11 }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(":set diffopt+=internal<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{2:------------------}{3:│}{1: }{4:11 }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line at the end of file 1', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(":set diffopt=filler<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{4:11 }{3:│}{1: }{2:-----------------}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(":set diffopt+=internal<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{4:11 }{3:│}{1: }{2:-----------------}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line in the middle of file 2, remove on at the end of file 1', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- write_file(fname_2, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1: }^1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }{2:------------------}{3:│}{1: }{4:4 }|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{4:11 }{3:│}{1: }{2:-----------------}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }^1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }{2:------------------}{3:│}{1: }{4:4 }|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{4:11 }{3:│}{1: }{2:-----------------}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line in the middle of file 1, remove on at the end of file 2', function()
- write_file(fname, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1: }^1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }{4:4 }{3:│}{1: }{2:-----------------}|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{2:------------------}{3:│}{1: }{4:11 }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }^1 {3:│}{1: }1 |
- {1: }2 {3:│}{1: }2 |
- {1: }3 {3:│}{1: }3 |
- {1: }4 {3:│}{1: }4 |
- {1: }{4:4 }{3:│}{1: }{2:-----------------}|
- {1: }5 {3:│}{1: }5 |
- {1: }6 {3:│}{1: }6 |
- {1: }7 {3:│}{1: }7 |
- {1: }8 {3:│}{1: }8 |
- {1: }9 {3:│}{1: }9 |
- {1: }10 {3:│}{1: }10 |
- {1: }{2:------------------}{3:│}{1: }{4:11 }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- describe('normal/patience/histogram diff algorithm', function()
- setup(function()
- local f1 = [[#include <stdio.h>
- // Frobs foo heartily
- int frobnitz(int foo)
- {
- int i;
- for(i = 0; i < 10; i++)
- {
- printf("Your answer is: ");
- printf("%d\n", foo);
- }
- }
- int fact(int n)
- {
- if(n > 1)
- {
- return fact(n-1) * n;
- }
- return 1;
- }
- int main(int argc, char **argv)
- {
- frobnitz(fact(10));
- }]]
- write_file(fname, f1, false)
- local f2 = [[#include <stdio.h>
- int fib(int n)
- {
- if(n > 2)
- {
- return fib(n-1) + fib(n-2);
- }
- return 1;
- }
- // Frobs foo heartily
- int frobnitz(int foo)
- {
- int i;
- for(i = 0; i < 10; i++)
- {
- printf("%d\n", foo);
- }
- }
- int main(int argc, char **argv)
- {
- frobnitz(fib(10));
- }]]
- write_file(fname_2, f2, false)
- end)
- it('diffopt=+algorithm:myers', function()
- reread()
- feed(':set diffopt=internal,filler<cr>')
- screen:expect([[
- {1: }^#include <stdio.h>{3:│}{1: }#include <stdio.h|
- {1: } {3:│}{1: } |
- {1: }{8:// Frobs foo heart}{3:│}{1: }{8:int fib(int n)}{9: }|
- {1: }{4:int frobnitz(int f}{3:│}{1: }{2:-----------------}|
- {1: }{ {3:│}{1: }{ |
- {1: }{9: i}{8:nt i;}{9: }{3:│}{1: }{9: i}{8:f(n > 2)}{9: }|
- {1: }{4: for(i = 0; i <}{3:│}{1: }{2:-----------------}|
- {1: } { {3:│}{1: } { |
- {1: }{9: }{8:printf("Yo}{3:│}{1: }{9: }{8:return fi}|
- {1: }{4: printf("%d}{3:│}{1: }{2:-----------------}|
- {1: } } {3:│}{1: } } |
- {1: }{2:------------------}{3:│}{1: }{4: return 1; }|
- {1: }} {3:│}{1: }} |
- {1: } {3:│}{1: } |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler |
- ]])
- feed('G')
- screen:expect([[
- {1: }{2:------------------}{3:│}{1: }{4:int frobnitz(int }|
- {1: }{ {3:│}{1: }{ |
- {1: }{9: i}{8:f(n > 1)}{9: }{3:│}{1: }{9: i}{8:nt i;}{9: }|
- {1: }{2:------------------}{3:│}{1: }{4: for(i = 0; i }|
- {1: } { {3:│}{1: } { |
- {1: }{9: }{8:return fac}{3:│}{1: }{9: }{8:printf("%}|
- {1: } } {3:│}{1: } } |
- {1: }{4: return 1; }{3:│}{1: }{2:-----------------}|
- {1: }} {3:│}{1: }} |
- {1: } {3:│}{1: } |
- {1: }int main(int argc,{3:│}{1: }int main(int argc|
- {1: }{ {3:│}{1: }{ |
- {1: }{9: frobnitz(f}{8:act}{9:(}{3:│}{1: }{9: frobnitz(f}{8:ib}{9:(}|
- {1: }^} {3:│}{1: }} |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler |
- ]])
- end)
- it('diffopt+=algorithm:patience', function()
- reread()
- feed(':set diffopt=internal,filler,algorithm:patience<cr>')
- screen:expect([[
- {1: }^#include <stdio.h>{3:│}{1: }#include <stdio.h|
- {1: } {3:│}{1: } |
- {1: }{2:------------------}{3:│}{1: }{4:int fib(int n) }|
- {1: }{2:------------------}{3:│}{1: }{4:{ }|
- {1: }{2:------------------}{3:│}{1: }{4: if(n > 2) }|
- {1: }{2:------------------}{3:│}{1: }{4: { }|
- {1: }{2:------------------}{3:│}{1: }{4: return fi}|
- {1: }{2:------------------}{3:│}{1: }{4: } }|
- {1: }{2:------------------}{3:│}{1: }{4: return 1; }|
- {1: }{2:------------------}{3:│}{1: }{4:} }|
- {1: }{2:------------------}{3:│}{1: }{4: }|
- {1: }// Frobs foo heart{3:│}{1: }// Frobs foo hear|
- {1: }int frobnitz(int f{3:│}{1: }int frobnitz(int |
- {1: }{ {3:│}{1: }{ |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- feed('G')
- screen:expect([[
- {1: } {3:│}{1: } |
- {1: }{4:int fact(int n) }{3:│}{1: }{2:-----------------}|
- {1: }{4:{ }{3:│}{1: }{2:-----------------}|
- {1: }{4: if(n > 1) }{3:│}{1: }{2:-----------------}|
- {1: }{4: { }{3:│}{1: }{2:-----------------}|
- {1: }{4: return fac}{3:│}{1: }{2:-----------------}|
- {1: }{4: } }{3:│}{1: }{2:-----------------}|
- {1: }{4: return 1; }{3:│}{1: }{2:-----------------}|
- {1: }{4:} }{3:│}{1: }{2:-----------------}|
- {1: }{4: }{3:│}{1: }{2:-----------------}|
- {1: }int main(int argc,{3:│}{1: }int main(int argc|
- {1: }{ {3:│}{1: }{ |
- {1: }{9: frobnitz(f}{8:act}{9:(}{3:│}{1: }{9: frobnitz(f}{8:ib}{9:(}|
- {1: }^} {3:│}{1: }} |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- it('diffopt+=algorithm:histogram', function()
- reread()
- feed(':set diffopt=internal,filler,algorithm:histogram<cr>')
- screen:expect([[
- {1: }^#include <stdio.h>{3:│}{1: }#include <stdio.h|
- {1: } {3:│}{1: } |
- {1: }{2:------------------}{3:│}{1: }{4:int fib(int n) }|
- {1: }{2:------------------}{3:│}{1: }{4:{ }|
- {1: }{2:------------------}{3:│}{1: }{4: if(n > 2) }|
- {1: }{2:------------------}{3:│}{1: }{4: { }|
- {1: }{2:------------------}{3:│}{1: }{4: return fi}|
- {1: }{2:------------------}{3:│}{1: }{4: } }|
- {1: }{2:------------------}{3:│}{1: }{4: return 1; }|
- {1: }{2:------------------}{3:│}{1: }{4:} }|
- {1: }{2:------------------}{3:│}{1: }{4: }|
- {1: }// Frobs foo heart{3:│}{1: }// Frobs foo hear|
- {1: }int frobnitz(int f{3:│}{1: }int frobnitz(int |
- {1: }{ {3:│}{1: }{ |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- feed('G')
- screen:expect([[
- {1: } {3:│}{1: } |
- {1: }{4:int fact(int n) }{3:│}{1: }{2:-----------------}|
- {1: }{4:{ }{3:│}{1: }{2:-----------------}|
- {1: }{4: if(n > 1) }{3:│}{1: }{2:-----------------}|
- {1: }{4: { }{3:│}{1: }{2:-----------------}|
- {1: }{4: return fac}{3:│}{1: }{2:-----------------}|
- {1: }{4: } }{3:│}{1: }{2:-----------------}|
- {1: }{4: return 1; }{3:│}{1: }{2:-----------------}|
- {1: }{4:} }{3:│}{1: }{2:-----------------}|
- {1: }{4: }{3:│}{1: }{2:-----------------}|
- {1: }int main(int argc,{3:│}{1: }int main(int argc|
- {1: }{ {3:│}{1: }{ |
- {1: }{9: frobnitz(f}{8:act}{9:(}{3:│}{1: }{9: frobnitz(f}{8:ib}{9:(}|
- {1: }^} {3:│}{1: }} |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- end)
- describe('diffopt+=indent-heuristic', function()
- setup(function()
- local f1 = [[
- def finalize(values)
- values.each do |v|
- v.finalize
- end]]
- write_file(fname, f1, false)
- local f2 = [[
- def finalize(values)
- values.each do |v|
- v.prepare
- end
- values.each do |v|
- v.finalize
- end]]
- write_file(fname_2, f2, false)
- feed(':diffupdate!<cr>')
- end)
- it('internal', function()
- reread()
- feed(":set diffopt=internal,filler<cr>")
- screen:expect([[
- {1: }^def finalize(value{3:│}{1: }def finalize(valu|
- {1: } {3:│}{1: } |
- {1: } values.each do |{3:│}{1: } values.each do |
- {1: }{2:------------------}{3:│}{1: }{4: v.prepare }|
- {1: }{2:------------------}{3:│}{1: }{4: end }|
- {1: }{2:------------------}{3:│}{1: }{4: }|
- {1: }{2:------------------}{3:│}{1: }{4: values.each do }|
- {1: } v.finalize {3:│}{1: } v.finalize |
- {1: } end {3:│}{1: } end |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler |
- ]])
- end)
- it('indent-heuristic', function()
- reread()
- feed(':set diffopt=internal,filler,indent-heuristic<cr>')
- screen:expect([[
- {1: }^def finalize(value{3:│}{1: }def finalize(valu|
- {1: } {3:│}{1: } |
- {1: }{2:------------------}{3:│}{1: }{4: values.each do }|
- {1: }{2:------------------}{3:│}{1: }{4: v.prepare }|
- {1: }{2:------------------}{3:│}{1: }{4: end }|
- {1: }{2:------------------}{3:│}{1: }{4: }|
- {1: } values.each do |{3:│}{1: } values.each do |
- {1: } v.finalize {3:│}{1: } v.finalize |
- {1: } end {3:│}{1: } end |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- it('indent-heuristic random order', function()
- reread()
- feed(':set diffopt=internal,filler,indent-heuristic,algorithm:patience<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^def finalize(value{3:│}{1: }def finalize(valu|
- {1: } {3:│}{1: } |
- {1: }{2:------------------}{3:│}{1: }{4: values.each do }|
- {1: }{2:------------------}{3:│}{1: }{4: v.prepare }|
- {1: }{2:------------------}{3:│}{1: }{4: end }|
- {1: }{2:------------------}{3:│}{1: }{4: }|
- {1: } values.each do |{3:│}{1: } values.each do |
- {1: } v.finalize {3:│}{1: } v.finalize |
- {1: } end {3:│}{1: } end |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- end)
- it('Diff the same file', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1:+ }{5:^+-- 10 lines: 1···}{3:│}{1:+ }{5:+-- 10 lines: 1··}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1:+ }{5:^+-- 10 lines: 1···}{3:│}{1:+ }{5:+-- 10 lines: 1··}|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Diff an empty file', function()
- write_file(fname, "", false)
- write_file(fname_2, "", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1:- }^ {3:│}{1:- } |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1:- }^ {3:│}{1:- } |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('diffopt+=icase', function()
- write_file(fname, "a\nb\ncd\n", false)
- write_file(fname_2, "A\nb\ncDe\n", false)
- reread()
- feed(':set diffopt=filler,icase<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }A |
- {1: }b {3:│}{1: }b |
- {1: }{9:cd }{3:│}{1: }{9:cD}{8:e}{9: }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler,icase |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }A |
- {1: }b {3:│}{1: }b |
- {1: }{9:cd }{3:│}{1: }{9:cD}{8:e}{9: }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- describe('diffopt+=iwhite', function()
- setup(function()
- local f1 = 'int main()\n{\n printf("Hello, World!");\n return 0;\n}\n'
- write_file(fname, f1, false)
- local f2 = 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n'
- write_file(fname_2, f2, false)
- feed(':diffupdate!<cr>')
- end)
- it('external', function()
- reread()
- feed(':set diffopt=filler,iwhite<cr>')
- screen:expect([[
- {1: }^int main() {3:│}{1: }int main() |
- {1: }{ {3:│}{1: }{ |
- {1: }{2:------------------}{3:│}{1: }{4: if (0) }|
- {1: }{2:------------------}{3:│}{1: }{4: { }|
- {1: } printf("Hello, {3:│}{1: } printf("Hel|
- {1: } return 0; {3:│}{1: } return 0; |
- {1: }{2:------------------}{3:│}{1: }{4: } }|
- {1: }} {3:│}{1: }} |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler,iwhite |
- ]])
- end)
- it('internal', function()
- reread()
- feed(':set diffopt=filler,iwhite,internal<cr>')
- screen:expect([[
- {1: }^int main() {3:│}{1: }int main() |
- {1: }{ {3:│}{1: }{ |
- {1: }{2:------------------}{3:│}{1: }{4: if (0) }|
- {1: }{2:------------------}{3:│}{1: }{4: { }|
- {1: } printf("Hello, {3:│}{1: } printf("Hel|
- {1: } return 0; {3:│}{1: } return 0; |
- {1: }{2:------------------}{3:│}{1: }{4: } }|
- {1: }} {3:│}{1: }} |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler,iwhite,internal |
- ]])
- end)
- end)
- describe('diffopt+=iblank', function()
- setup(function()
- write_file(fname, 'a\n\n \ncd\nef\nxxx\n', false)
- write_file(fname_2, 'a\ncd\n\nef\nyyy\n', false)
- feed(':diffupdate!<cr>')
- end)
- it('generic', function()
- reread()
- feed(':set diffopt=internal,filler,iblank<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }a |
- {1: }{4: }{3:│}{1: }{2:-----------------}|
- {1: }{4: }{3:│}{1: }{2:-----------------}|
- {1: }cd {3:│}{1: }cd |
- {1: }ef {3:│}{1: } |
- {1: }{8:xxx}{9: }{3:│}{1: }ef |
- {1: }{6:~ }{3:│}{1: }{8:yyy}{9: }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler,iblank |
- ]])
- end)
- it('diffopt+=iwhite', function()
- reread()
- feed(':set diffopt=internal,filler,iblank,iwhite<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }a |
- {1: } {3:│}{1: }cd |
- {1: } {3:│}{1: } |
- {1: }cd {3:│}{1: }ef |
- {1: }ef {3:│}{1: }{8:yyy}{9: }|
- {1: }{8:xxx}{9: }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- it('diffopt+=iwhiteall', function()
- reread()
- feed(':set diffopt=internal,filler,iblank,iwhiteall<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }a |
- {1: } {3:│}{1: }cd |
- {1: } {3:│}{1: } |
- {1: }cd {3:│}{1: }ef |
- {1: }ef {3:│}{1: }{8:yyy}{9: }|
- {1: }{8:xxx}{9: }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- it('diffopt+=iwhiteeol', function()
- reread()
- feed(':set diffopt=internal,filler,iblank,iwhiteeol<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }a |
- {1: } {3:│}{1: }cd |
- {1: } {3:│}{1: } |
- {1: }cd {3:│}{1: }ef |
- {1: }ef {3:│}{1: }{8:yyy}{9: }|
- {1: }{8:xxx}{9: }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- end)
- describe('diffopt+=iwhite{eol,all}', function()
- setup(function()
- write_file(fname, 'a \nx\ncd\nef\nxx xx\nfoo\nbar\n', false)
- write_file(fname_2, 'a\nx\nc d\n ef\nxx xx\nfoo\n\nbar\n', false)
- feed(':diffupdate!<cr>')
- end)
- it('diffopt+=iwhiteeol', function()
- reread()
- feed(':set diffopt=internal,filler,iwhiteeol<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }a |
- {1: }x {3:│}{1: }x |
- {1: }{9:cd }{3:│}{1: }{9:c}{8: }{9:d }|
- {1: }{9:ef }{3:│}{1: }{8: }{9:ef }|
- {1: }{9:xx }{8: }{9:xx }{3:│}{1: }{9:xx xx }|
- {1: }foo {3:│}{1: }foo |
- {1: }{2:------------------}{3:│}{1: }{4: }|
- {1: }bar {3:│}{1: }bar |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- it('diffopt+=iwhiteall', function()
- reread()
- feed(':set diffopt=internal,filler,iwhiteall<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a {3:│}{1: }a |
- {1: }x {3:│}{1: }x |
- {1: }cd {3:│}{1: }c d |
- {1: }ef {3:│}{1: } ef |
- {1: }xx xx {3:│}{1: }xx xx |
- {1: }foo {3:│}{1: }foo |
- {1: }{2:------------------}{3:│}{1: }{4: }|
- {1: }bar {3:│}{1: }bar |
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {1: }{6:~ }{3:│}{1: }{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- end)
- end)
|