]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/vim-lsp/test/lsp/utils/diff.vimspec

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'd49e95aa7ba744f0a7f544aca43afdb6aab41f24' as '.vim/bundle/asyncomplete...
[etc/vim.git] / .vim / bundle / vim-lsp / test / lsp / utils / diff.vimspec
1 Describe lsp#utils#diff
2
3     Describe lsp#utils#diff#compute
4         It should return diff of one letter
5             let lines1 = [
6             \  'foo',
7             \  'bar',
8             \  'baz',
9             \]
10             let lines2 = [
11             \  'foo',
12             \  'baR',
13             \  'baz',
14             \]
15             let want = {
16             \  'range': {
17             \    'start': { 'line': 1, 'character': 2 },
18             \    'end': { 'line': 1, 'character': 3 },
19             \  },
20             \  'text': 'R',
21             \  'rangeLength': 1
22             \}
23             let got = lsp#utils#diff#compute(lines1, lines2)
24             Assert Equals(got, want)
25         End
26
27         It should return diff of multi-lines
28             let lines1 = [
29             \  'foo',
30             \  'bar',
31             \  'baz',
32             \]
33             let lines2 = [
34             \  'Foo',
35             \  'baR',
36             \  'baz',
37             \]
38             let want = {
39             \  'range': {
40             \    'start': { 'line': 0, 'character': 0 },
41             \    'end': { 'line': 1, 'character': 3, }
42             \  },
43             \  'text': "Foo\nbaR",
44             \  "rangeLength": 7
45             \}
46             let got = lsp#utils#diff#compute(lines1, lines2)
47             Assert Equals(got, want)
48         End
49
50         It should return diff for empty list
51             let lines1 = []
52             let lines2 = [
53             \  'foo',
54             \  'bar',
55             \  'baz',
56             \]
57             let want = {
58             \  'range': {
59             \    'start': { 'line': 0, 'character': 0 },
60             \    'end': { 'line': 0, 'character': 0, }
61             \  },
62             \  'text': "foo\nbar\nbaz\n",
63             \  "rangeLength": 0
64             \}
65             let got = lsp#utils#diff#compute(lines1, lines2)
66             Assert Equals(got, want)
67
68             let lines1 = [
69             \  'foo',
70             \  'bar',
71             \  'baz',
72             \]
73             let lines2 = []
74             let want = {
75             \  'range': {
76             \    'start': { 'line': 0, 'character': 0 },
77             \    'end': { 'line': 3, 'character': 0, }
78             \  },
79             \  'text': '',
80             \  "rangeLength": 12
81             \}
82             let got = lsp#utils#diff#compute(lines1, lines2)
83             Assert Equals(got, want)
84         End
85     End
86 End