Skip to content

Commit

Permalink
use arrow function syntax in test lambda function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiryukhin, Vadim committed Jul 26, 2016
1 parent 1df96e7 commit 73446e9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -7,7 +7,7 @@ Javascript (both node.js and browser) plugin to stringify / parse / clone jsvasc
- **Date**


**Version** - 1.1.00
**Version** - 1.1.0

**Copyright** (c) Vadim Kiryukhin ( vkiryukhin @ gmail.com )

Expand Down
2 changes: 1 addition & 1 deletion jsonfn.js
Expand Up @@ -2,7 +2,7 @@
* JSONfn - javascript (both node.js and browser) plugin to stringify,
* parse and clone objects with Functions, Regexp and Date.
*
* Version - 1.1.00
* Version - 1.1.0
* Copyright (c) Vadim Kiryukhin
* vkiryukhin @ gmail.com
* http://www.eslinstructor.net/jsonfn/
Expand Down
2 changes: 1 addition & 1 deletion jsonfn.min.js
Expand Up @@ -2,7 +2,7 @@
* JSONfn - javascript (both node.js and browser) plugin to stringify,
* parse and clone objects with Functions, Regexp and Date.
*
* Version - 1.1.00
* Version - 1.1.0
* Copyright (c) Vadim Kiryukhin
* vkiryukhin @ gmail.com
* http://www.eslinstructor.net/jsonfn/
Expand Down
39 changes: 8 additions & 31 deletions test/jsonfn_test.js
Expand Up @@ -8,16 +8,12 @@ var obj = {
getFullName: function () {
return this.firstName + " " + this.lastName;
},
getFullNameArrow: () => {
return this.firstName + " " + this.lastName;
},
arrowFnSimple: a => a > 10 ? 10 : a,
arrowFn: (a, b) => a > b ? a : b,
getFullNameArrow: () => this.firstName + " " + this.lastName,
//arrowFnSimple: a => a > 10 ? 10 : a,
//arrowFn: (a, b) => a > b ? a : b,
greetLambda: function (param) {
var displayMessage = (function (msg1) {
return function (msg2) {
return msg1 + msg2;
};
return msg2 => msg1 + msg2;
}(param));
return displayMessage("Lambda World!");
}
Expand Down Expand Up @@ -67,27 +63,12 @@ function testDate(objfn) {
}
}

function testArrowFn(objfn) {
if (objfn.arrowFn(11,22) === 22) {
console.log(' arrowFunction......... OK\n');
} else {
console.log(' arrowFunction......... failure\n');
}
}

function testArrowFnSimple(objfn) {
if (objfn.arrowFnSimple(123) === 10) {
console.log(' arrowFunctionSimple... OK\n');
} else {
console.log(' arrowFunctionSimple... failure\n');
}
}

function testArrowFnRegular(objfn) {
if (objfn.getFullNameArrow() === "John Dow") {
console.log(' arrowFunctionRegular.. OK\n');
console.log(' arrowFunction......... OK\n');
} else {
console.log(' arrowFunctionRegular.. failure\n');
console.log(' arrowFunction......... failure\n');
}
}

Expand All @@ -107,13 +88,11 @@ testFunction(objfn);
testLambda(objfn);
testRegexp(objfn);
testDate(objfn);
testArrowFn(objfn);
testArrowFnSimple(objfn);
testArrowFnRegular(objfn);

console.log(' Cloning original object.......\n');
console.log('\n Cloning original object *******\n');

console.log(' Run test on clonned object:\n');
console.log('\n Running test on clonned object:\n');

objfn = JSONfn.clone(obj, true);

Expand All @@ -122,8 +101,6 @@ testFunction(objfn);
testLambda(objfn);
testRegexp(objfn);
testDate(objfn);
testArrowFn(objfn);
testArrowFnSimple(objfn);
testArrowFnRegular(objfn);

console.log('\n\n======= Test finished =======\n\n');
Expand Down

0 comments on commit 73446e9

Please sign in to comment.