Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diffs for buffers #1132

Closed
vkurchatkin opened this issue Feb 12, 2014 · 5 comments
Closed

Diffs for buffers #1132

vkurchatkin opened this issue Feb 12, 2014 · 5 comments

Comments

@vkurchatkin
Copy link

Diffs for buffers seem to be broken:

require('should')

describe('comparing buffers', function () {
  it('should produce correct diff', function () {
    Buffer([0x01]).should.eql(Buffer([0x02]))
  })
})

This code produces the following:

  + expected - actual

       {
      +  "0": 2,
      -  "0": 1,
         "length": 1,
      +  "offset": 5752,
      -  "offset": 5744,
         "parent": {
           "0": 47,
           "1": 42,
           "2": 33,

It's almost ok, except I can see offset and parent, but all I really care is data.
But this example shows the worst scenario:

require('should')

describe('comparing buffers', function () {
  it('should produce correct diff', function () {
    Buffer([0x01]).should.eql(Buffer(0))
  })
})

Not only this diff is veeery long (it shows the whole parent, which is the pool, I assume), but also it takes significant time to be generated.

So, the question is, shouldn't diffs for Buffers be treated specially, to make them really useful?

@boneskull
Copy link
Contributor

Some people might want to see all that stuff? Can't you compare the data directly instead of the entire Buffer object?

@vkurchatkin
Copy link
Author

buffers are compared by data, not but reference, and should be diffed the same way, like strings. It's unlikely that someone is interested in offset and parent, because they are just implementation detail. And the real problem, once again, is that diff for buffers with different parents is useless and blocks process for significant amount of time.

@boneskull
Copy link
Contributor

I think we'd accept a PR for better Buffer diffs

@dasilvacontin
Copy link
Contributor

@a8m, any news?

@a8m
Copy link
Contributor

a8m commented Nov 16, 2014

waiting for @boneskull's attention

tandrewnichols pushed a commit to tandrewnichols/mocha that referenced this issue Dec 15, 2014
travisjeffery pushed a commit that referenced this issue Jan 18, 2015
[Fix]: Diff viewer(#1229, #1132, ...)
@boneskull boneskull removed the status: accepting prs Mocha can use your help with this one! label Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants