Skip to content

Show diff only when it helps#802

Closed
shivamdixit wants to merge 2 commits into
qunitjs:masterfrom
leobalter:shivamdixit-335-show-diff-only-when-it-helps
Closed

Show diff only when it helps#802
shivamdixit wants to merge 2 commits into
qunitjs:masterfrom
leobalter:shivamdixit-335-show-diff-only-when-it-helps

Conversation

@shivamdixit

Copy link
Copy Markdown
Contributor

Follow up of #786

shivamdixit and others added 2 commits March 27, 2015 14:59
Don't show diff if expected and actual values are completely different
and there is nothing in common

Fixes qunitjs#335
@leobalter

Copy link
Copy Markdown
Member

Note: this is a follow up to #786 and also address an issue introduced on the last changes showing a whacky falstrue diff when one of the assertion values (actual or expected) was a Boolean.

@shivamdixit

Copy link
Copy Markdown
Contributor Author

Seems like the test timed out.

@leobalter

Copy link
Copy Markdown
Member

it worked now

@shivamdixit

Copy link
Copy Markdown
Contributor Author

qunit7

Booleans inside objects/arrays are still displayed like falstrue.

@shivamdixit

Copy link
Copy Markdown
Contributor Author

Ping.

@jzaefferer

Copy link
Copy Markdown
Member

The hack to show true/false differently is bad. This is likely to blow up with a similar combination of single word pairs, or maybe with numbers.

We want to character-by-character diff for syntax, but maybe not for literals like booleans?

Since we already landed the new diff, can we keep the "show diff only when it helps" and "show better diff for booleans" apart?

@leobalter

Copy link
Copy Markdown
Member

the regexp works only for Booleans, as strings are represented between double quotes and the regexp will search from the start to the end of the value: /^(true|false)$/.

@leobalter

Copy link
Copy Markdown
Member

btw, falstrue is a good name for a band.

@leobalter

Copy link
Copy Markdown
Member

as told on the biweekly meeting, the boolean regexp check is good as-is and @jzaefferer agreed to land it.

@shivamdixit

Copy link
Copy Markdown
Contributor Author

Great. So this PR is ready to be merged?

@leobalter

Copy link
Copy Markdown
Member

LGTM, I'll just wait for @jzaefferer 👍 here to confirm. Then I'll squash the commits and merge them.

Comment thread reporter/html.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix the <code>QUnit.dump.maxDepth</code> to use QUnit.config.maxDepth as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried to change it to QUnit.config.maxDepth but strangely it din't work, whereas using QUnit.dump.maxDepth works fine. I guess this is happening because dump.maxDepth is initialized with default config.maxDepth in file dump.js and then the value of config.maxDepth is changed. Hence I got a message which looks like:

Diff suppressed as the depth of object is more than current max depth (infinity)

However specifying maxDepth in GET parameters works fine because if parameters are present, the value of config.maxDepth is updated in file core.js before initialization in dump.js.

@jzaefferer

Copy link
Copy Markdown
Member

Noticed two things, not sure why I missed them before.

@jzaefferer

Copy link
Copy Markdown
Member

Squashed the two commits into one and merged. Thanks again!

@leobalter leobalter deleted the shivamdixit-335-show-diff-only-when-it-helps branch May 15, 2015 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants