Skip to content

node.js simple tests #1

Description

@sokra

I tried to run this module with the Buffer tests from node
( https://github.com/joyent/node/blob/master/test/simple/test-buffer.js )

Tests run in Chrome 19.0.1084.52 m. May not all tests can be fixed...

I tried to omit duplicate errors.

This are the results:

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L33

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L48

TypeError: Object #<error> has no method 'copy'
    at Buffer.copy (buffer-browserify/index.js:598:22)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L186

AssertionError: "hello world" == "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"

writing and reading via buffer[number] does not work. This causes that error. (and that in L207)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L250

Error: Unknown encoding
    at Function.byteLength (buffer-browserify/index.js:58:13)
    at new Buffer (buffer-browserify/index.js:323:30)

Encodings: 'ucs2', 'utf-16le', 'binary'

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L320

the base64 decoder should ignores whitespace and illegal chars.

Invalid string. Length must be a multiple of 4

https://github.com/beatgammit/base64-js/blob/master/lib/b64.js#L10 should throw an Error not a string!

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L343

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L379 and more

Invalid string. Length must be a multiple of 4

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L432

TypeError: Object #<error> has no method 'binarySlice'
    at Buffer.toString (buffer-browserify/index.js:512:26)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L569

TypeError: Object #<error> has no method 'fill'
    at Buffer.fill (buffer-browserify/index.js:558:22)

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L605

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L623

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L706

https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L719

Activity

  1. toots commented on Jun 6, 2012

    @toots
    Owner

    Indeed, not all functionalities from node are covered yet. Will add them whenever possible. Feel free to submit a PR too :-)

  2. sokra commented on Jun 6, 2012

    @sokra
    ContributorAuthor

    no hurry. I just wanted to document it.

  3. ysangkok commented on Sep 19, 2012

    @ysangkok
    Contributor

    Is this report still current or has the library been superseded or something?

  4. toots commented on Sep 19, 2012

    @toots
    Owner

    The report is still current. The library is functional as it is but does not implement all functionalities from node yet.

  5. GraemeF commented on Oct 21, 2012

    @GraemeF

    As a relative JS noob I'm wondering if it's even possible to fix writing and reading via buffer[number]? I'm trying to use https://github.com/creationix/jsonparse with browserify and this is making it barf. If it can't be fixed here then I'll have to look at maybe detecting browserify and using something other than a Buffer in those cases.

  6. ysangkok commented on Oct 21, 2012

    @ysangkok
    Contributor
  7. GraemeF commented on Oct 21, 2012

    @GraemeF

    @ysangkok : Ah, just as I feared. Thanks!

  8. rdrey commented on Nov 15, 2012

    @rdrey
    Contributor

    Ah, I just got bitten by the buf[i] issue, too. Luckily the call is in my own code, so it's simple to replace it with buf.get(i) for now.

  9. toots commented on Mar 9, 2013

    @toots
    Owner

    I'm all about fixing the buf[i] issue. Typed array sounds promising. However, browser support for those seem pretty crappy so I don't think that this is actually a viable solution for now, unless there is some kind of browser detection+fallback which would definitely yield bad code I fear..

  10. alexstrat commented on Mar 17, 2013

    @alexstrat

    @toots I'm curious to know which technique you plan to use for fixing the buf[i] issue: __defineGetter__, defineProperty or others ? buf[i] = this.parent[i] does not do the hack, right ? Have you already started something ?

  11. GraemeF commented on Mar 18, 2013

    @GraemeF

    FYI @substack is working on a patch for the buf[i] issue (it was mentioned in dominictarr/JSONStream#23 (comment)).

  12. toots commented on Mar 18, 2013

    @toots
    Owner

    Hi all,

    @alexstrat I have no preference as to which technique to use, my only concerns are:

    • Compatibility with a reasonable set of browsers
    • Backward compatibility with node.js' original buffers (including potential boog/weird API specifics)

    I have not yet started working on it but, @GraemeF : any patch for this would be much welcome and I'd try to review and merge in a timely fashion, should that happen! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions