Skip to content

Instantly share code, notes, and snippets.

@peanutbother
Created October 21, 2016 13:52
Show Gist options
  • Save peanutbother/96738dd8a48ceb9f517e914b834cc1ee to your computer and use it in GitHub Desktop.
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
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