Skip to content

AssertEqual: better display of unequal dicts/list - #120

Merged
junegunn merged 1 commit into
junegunn:masterfrom
blueyed:better-display-of-dict-or-list-mismatch
Feb 25, 2017
Merged

junegunn merged 1 commit into
junegunn:masterfrom
blueyed:better-display-of-dict-or-list-mismatch

Conversation

@blueyed

@blueyed blueyed commented Feb 24, 2017

Copy link
Copy Markdown
Collaborator

This adds a newline (with indentation) before each value to make it
easier to visually grasp the change.

This adds a newline (with indentation) before each value to make it
easier to visually grasp the change.
@junegunn
junegunn merged commit 05d91b6 into junegunn:master Feb 25, 2017
@junegunn

Copy link
Copy Markdown
Owner

Looks useful, thanks!

@blueyed
blueyed deleted the better-display-of-dict-or-list-mismatch branch February 25, 2017 18:26
@adriaanzon

Copy link
Copy Markdown

This renders like this for me:

(12/12) [EXECUTE] (X) Unequal Lists^@      ['bar'] should be equal to ^@      ['foo']

@blueyed

blueyed commented Feb 28, 2017 •

Copy link
Copy Markdown
Collaborator Author

@adriaanzon
Vim/Neovim?
Windows/MacOS?
interactive or not?

@adriaanzon

adriaanzon commented Feb 28, 2017 •

Copy link
Copy Markdown

On both vim and neovim, using Arch Linux.

This happens in interactive vim sessions.

I wasn't aware that there's also output in non-interactive vim-sessions, because neovim doesn't output anything when exiting vim immediately using :Vader!. Using /usr/bin/vim -c Vader! ..., the output renders fine.

@junegunn

Copy link
Copy Markdown
Owner

Hmm, sorry for not paying close attention. I'd like the output of the interactive session to be fixed. A quick and dirty patch:

diff --git a/autoload/vader.vim b/autoload/vader.vim
index 9036654..8bb5506 100644
--- a/autoload/vader.vim
+++ b/autoload/vader.vim
@@ -25,8 +25,13 @@ let s:register = {}
 let s:register_undefined = []
 let s:indent = 2
 
+function! vader#interactive()
+  return !s:bang
+endfunction
+
 function! vader#run(bang, ...) range
   let s:error_line = 0
+  let s:bang = a:bang
 
   if a:lastline - a:firstline > 0
     if a:0 > 1
diff --git a/autoload/vader/assert.vim b/autoload/vader/assert.vim
index 2e29b86..7c25a69 100644
--- a/autoload/vader/assert.vim
+++ b/autoload/vader/assert.vim
@@ -76,7 +76,7 @@ function! vader#assert#equal(...)
   call s:check_types(Exp, Got)
   if Exp !=# Got
     let type = type(Exp)
-    let msg = (type == type({}) || type == type([]))
+    let msg = ((type == type({}) || type == type([])) && !vader#interactive())
           \ ? printf("Unequal %ss\n      %%s should be equal to \n      %%s", get(s:type_names, type))
           \ : "%s should be equal to %s"
     throw get(a:000, 2, printf(msg, string(Got), string(Exp)))

blueyed added a commit to blueyed/vader.vim that referenced this pull request Mar 11, 2017
blueyed added a commit to blueyed/vader.vim that referenced this pull request Mar 11, 2017
blueyed added a commit to blueyed/vader.vim that referenced this pull request Mar 11, 2017
blueyed added a commit to blueyed/vader.vim that referenced this pull request Apr 21, 2017
blueyed added a commit to blueyed/vader.vim that referenced this pull request Mar 25, 2018
blueyed added a commit to blueyed/vader.vim that referenced this pull request Mar 25, 2018
hupfdule pushed a commit to hupfdule/vader.vim that referenced this pull request May 6, 2020
This adds a newline (with indentation) before each value to make it
easier to visually grasp the change.
hupfdule pushed a commit to hupfdule/vader.vim that referenced this pull request May 28, 2020
This adds a newline (with indentation) before each value to make it
easier to visually grasp the change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants