puffnfresh / bilby.js

Serious functional programming library for JavaScript.
http://bilby.brianmckenna.org/
MIT License
592 stars 24 forks source link

Functor test failing #2

Closed antris closed 12 years ago

antris commented 12 years ago

As mentioned in the pull request for adding tests (#1), the functor test is failing:

bilby.js(tests): grunt test
Running "test:src" (test) task
Testing features.js....F..
>> 1
>> TypeError Object function () {
>>             var g = f.bind.apply(f, [this].concat([].slice.call(arguments))),
>>                 // Special hack for polyfilled Function.prototype.bind
>>                 length = g._length || g.length;
>>     
>>             if(length === 0)
>>                 return g();
>>     
>>             return curry(g);
>>         } has no method '>'
>>   at /Users/antris/src/bilby.js/bilby.js:65:25
>>   at Object.<anonymous> (/Users/antris/src/bilby.js/test/features.js:49:20)
>>   at Object.<anonymous> (/Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>>   at /Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16
>>   at Object.runTest (/Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/lib/core.js:69:9)
>>   at /Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/lib/core.js:117:25
>>   at /Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/deps/async.js:508:13
>>   at /Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/deps/async.js:118:13
>>   at /Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/deps/async.js:129:25
>>   at /Users/antris/src/bilby.js/node_modules/grunt/node_modules/nodeunit/deps/async.js:510:17

<WARN> 1/9 assertions failed (10ms) Use --force to continue. </WARN>

Aborted due to warnings.
puffnfresh commented 12 years ago

That's really interesting, mine is passing fine:

$ npm test

> bilby@0.0.0 test bilby.js
> ./node_modules/grunt/bin/grunt test

Running "test:src" (test) task
Testing features.js.......OK
>> 9 assertions passed (4ms)

Done, without errors.

What version of node.js/grunt are you using?

antris commented 12 years ago
bilby.js(tests): node --version
v0.6.19
bilby.js(tests): grunt --version
grunt v0.3.15
puffnfresh commented 12 years ago

I've had a look at this and have no idea. Passes just fine locally with node v0.6.12 and grunt 0.3.15. Not sure why only the functor test would fail - works exactly the same way as the other tests.

puffnfresh commented 12 years ago

Getting the same thing on Travis:

http://travis-ci.org/#!/pufuwozu/bilby.js/jobs/2384699

Crazy.

puffnfresh commented 12 years ago

Ah, so in node.js 0.6.19 I get this behaviour:

> {valueOf: function() { console.log('a'); }} > {valueOf: function() { console.log('b'); }}
b
a
false

Notice the order? Interesting that it's only a problem with >. Ordering might be an implementation detail - but maybe I should just change symbol :bulb:

puffnfresh commented 12 years ago

Specification says it should go left to right. Was a bug in V8. Guess I'll change the symbol to something that hasn't had a bug.

puffnfresh commented 12 years ago

Changed functor syntax from > to <.

antris commented 12 years ago

Haha, wow. #wtfjs

michaelficarra commented 12 years ago

@pufuwozu: I'd be very interested to see that bug report. Can we get a link?

puffnfresh commented 12 years ago

@michaelficarra found it:

http://code.google.com/p/v8/issues/detail?id=1752

http://code.google.com/p/v8/source/detail?r=9641

puffnfresh commented 12 years ago

From the V8 issue, there might be an issue with Safari's >=. Need to check.

puffnfresh commented 12 years ago

Safari 6:

({valueOf: function() { console.log('a'); }}) >= ({valueOf: function() { console.log('b'); }})
a
b
false