]> git.madduck.net Git - etc/vim.git/blobdiff - .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 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / vim-lsp / test / lsp / utils / diff.vimspec
diff --git a/.vim/bundle/vim-lsp/test/lsp/utils/diff.vimspec b/.vim/bundle/vim-lsp/test/lsp/utils/diff.vimspec
new file mode 100644 (file)
index 0000000..8bdfeea
--- /dev/null
@@ -0,0 +1,86 @@
+Describe lsp#utils#diff
+
+    Describe lsp#utils#diff#compute
+        It should return diff of one letter
+            let lines1 = [
+            \  'foo',
+            \  'bar',
+            \  'baz',
+            \]
+            let lines2 = [
+            \  'foo',
+            \  'baR',
+            \  'baz',
+            \]
+            let want = {
+            \  'range': {
+            \    'start': { 'line': 1, 'character': 2 },
+            \    'end': { 'line': 1, 'character': 3 },
+            \  },
+            \  'text': 'R',
+            \  'rangeLength': 1
+            \}
+            let got = lsp#utils#diff#compute(lines1, lines2)
+            Assert Equals(got, want)
+        End
+
+        It should return diff of multi-lines
+            let lines1 = [
+            \  'foo',
+            \  'bar',
+            \  'baz',
+            \]
+            let lines2 = [
+            \  'Foo',
+            \  'baR',
+            \  'baz',
+            \]
+            let want = {
+            \  'range': {
+            \    'start': { 'line': 0, 'character': 0 },
+            \    'end': { 'line': 1, 'character': 3, }
+            \  },
+            \  'text': "Foo\nbaR",
+            \  "rangeLength": 7
+            \}
+            let got = lsp#utils#diff#compute(lines1, lines2)
+            Assert Equals(got, want)
+        End
+
+        It should return diff for empty list
+            let lines1 = []
+            let lines2 = [
+            \  'foo',
+            \  'bar',
+            \  'baz',
+            \]
+            let want = {
+            \  'range': {
+            \    'start': { 'line': 0, 'character': 0 },
+            \    'end': { 'line': 0, 'character': 0, }
+            \  },
+            \  'text': "foo\nbar\nbaz\n",
+            \  "rangeLength": 0
+            \}
+            let got = lsp#utils#diff#compute(lines1, lines2)
+            Assert Equals(got, want)
+
+            let lines1 = [
+            \  'foo',
+            \  'bar',
+            \  'baz',
+            \]
+            let lines2 = []
+            let want = {
+            \  'range': {
+            \    'start': { 'line': 0, 'character': 0 },
+            \    'end': { 'line': 3, 'character': 0, }
+            \  },
+            \  'text': '',
+            \  "rangeLength": 12
+            \}
+            let got = lsp#utils#diff#compute(lines1, lines2)
+            Assert Equals(got, want)
+        End
+    End
+End