Created
October 21, 2016 13:52
-
-
Save peanutbother/96738dd8a48ceb9f517e914b834cc1ee to your computer and use it in GitHub Desktop.
This mocha test checks usage of lambda in certain scenarios: type-equality, constructor, object-context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
describe('Lambda', function() { | |
describe('function(){}', function() { | |
it('should equal function´s type', function() { | |
var lambda = ()=>{}; | |
var funct = function(){}; | |
assert.equal(typeof(lambda), typeof(funct)); | |
}); | |
it('should have equal context as function', function() { | |
var T; | |
(T = function(){}).prototype = { | |
member: "MEMBER accessable!", | |
t: () => { | |
return this.member | |
}, | |
t2: function(){ | |
return this.member; | |
} | |
}; | |
var t = new T(); | |
var lambda = typeof(t.t()); | |
var funct = typeof(t.t2()); | |
assert.equal(lambda, funct, ""); | |
}); | |
it('should be able to be used as constructor', function() { | |
var construct_l = (()=>{}).prototype = {}; | |
var lambda = new construct_l(); | |
assert.equal(typeof(lambda), typeof(new construct_l())); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment