tj / should.js

BDD style assertions for node.js -- test framework agnostic
MIT License
2.75k stars 195 forks source link

Number assertions failing in Internet Explorer 9 #191

Closed christophercliff closed 9 years ago

christophercliff commented 10 years ago

Built with grunt-browserify, the following fails AssertionError: expected {} to be 2:

require('should')
it('should assert stuff', function(){
    (2).should.equal(2)
})

The following runs successfully:

var should = require('should')
it('should assert stuff', function(){
    should(2).equal(2)
})
btd commented 10 years ago

I does not reproduced this. I created simple html file with only should.js script included (from repo root) and in developer tools your examples working just fine. I need more details if you need help.

christophercliff commented 10 years ago

I put together a test case:

$ git clone git@github.com:christophercliff/should.js.git
$ cd ./should.js
$ git fetch
$ get checkout example-error
$ sudo npm install
$ grunt test

This will create a test runner at http://127.0.0.1:8000/. Just open it in Internet Explorer 9 (I'm using the IE9 - Win7 VM from modern.ie).

btd commented 10 years ago

Thanks, for detailed test case. I reproduced issue with win7 and ie9. There what i found: when ie9 should box number value and call getter it set wrong value.

//i added such getter
Object.defineProperty(Object.prototype, 'test', {
  get: function() { return this; }
});

//and when i tun
(100).test // return 0

Looks like it is ie bug, but I will look on this more.

btd commented 10 years ago

Hi again. I looked very attentively on this issue and tried several ways to find workaround for this issue, but i failed in this. I created wiki page with known bugs and add this page ref to readme. I will rest this issue opened, as it is bug and nobody recreate it (as by my observation nobody check closed bugs).

As a single workaround, as you mention - need to use not a getter but a function call.