jstest icon indicating copy to clipboard operation
jstest copied to clipboard

Enumerable.areEqual(expectedPromise, actualPromise) returns allways true

Open mgoerlich-dev opened this issue 9 years ago • 3 comments

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.

mgoerlich-dev avatar Apr 14 '15 19:04 mgoerlich-dev

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

jcoglan avatar Apr 14 '15 20:04 jcoglan

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.

mgoerlich-dev avatar Apr 16 '15 17:04 mgoerlich-dev

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.

jcoglan avatar Apr 28 '15 23:04 jcoglan