jcoglan / jstest

The cross-platform JavaScript test framework
38 stars 3 forks source link

Enumerable.areEqual(expectedPromise, actualPromise) returns allways true #7

Open mgoerlich-dev opened 9 years ago

mgoerlich-dev commented 9 years ago
var JS = require('jstest');                                                                                                                                               

JS.Test.describe('Enumerable.areEqual comparing Promises', function () { with(this) {                                                                                     
    before(function() { with(this) {                                                                                                                                      
        this.promises = [                                                                                                                                                 
            new Promise(function (r) { r('a'); }),                                                                                                                        
            new Promise(function (_, r) { r('a'); })                                                                                                                      
        ];                                                                                                                                                                
    }});                                                                                                                                                                  

    it('should return true on the same promise', function () { with(this) {                                                                                               
        assert(JS.Enumerable.areEqual(promises[0], promises[0]));                                                                                                         
    }});                                                                                                                                                                  

    it('should return false on two different promises', function () { with(this) {                                                                                        
        assertNot(JS.Enumerable.areEqual(promises[0], promises[1]));                                                                                                      
    }});                                                                                                                                                                  
}});                                                                                                                                                                      

JS.Test.autorun();

The second one will fail, because Promises have no iterable keys on them.

So the loop at /build/jstest.js#L1483 won't run.

jcoglan commented 9 years ago

What were you actually trying to test when you discovered this? Can you show me a genuine test case?

mgoerlich-dev commented 9 years ago

I cant show you any code, that i would recommend anyone to actually use somewhere. Just discovered this on a "play-around" session in the debugger, how i'd call it.

Just wanted to let you know, in case you don't see any value in this change, just close it.

jcoglan commented 9 years ago

I guess I just wanted to know what you expected that call to do. It is possible to add support for this (in theory, I can't commit to doing it any time soon but I can imagine how it could work) so any info you have would be useful.