Permalink
Cannot retrieve contributors at this time
JMapMyLDAP/tests/3rdparty/CodeSniffer/Standards/MySource/Tests/Objects/CreateWidgetTypeCallbackUnitTest.js /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
186 lines (131 sloc)
2.96 KB
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
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| if (x === 1) { | |
| return; | |
| } | |
| if (y === 1) { | |
| callback.call(this); | |
| // A comment here to explain the return is okay. | |
| return; | |
| } | |
| if (a === 1) { | |
| // Cant return value even after calling callback. | |
| callback.call(this); | |
| return something; | |
| } | |
| if (a === 1) { | |
| // Need to pass self or this to callback function. | |
| callback.call(a); | |
| } | |
| callback.call(self); | |
| var self = this; | |
| this.createChildren(null, function() { | |
| callback.call(self, div); | |
| }); | |
| // Never good to return a vaue. | |
| return something; | |
| callback.call(self); | |
| } | |
| }; | |
| AnotherSampleWidgetType.prototype = { | |
| create: function(input) | |
| { | |
| return; | |
| } | |
| getSomething: function(input) | |
| { | |
| return 1; | |
| } | |
| }; | |
| NoCreateWidgetType.prototype = { | |
| getSomething: function(input) | |
| { | |
| return; | |
| } | |
| }; | |
| SomeRandom.prototype = { | |
| create: function(input) | |
| { | |
| return; | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| if (a === 1) { | |
| // This is ok because it is the last statement, | |
| // even though it is conditional. | |
| callback.call(self); | |
| } | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| var something = callback; | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| // Also valid because we are passing the callback to | |
| // someone else to call. | |
| if (y === 1) { | |
| this.something(callback); | |
| return; | |
| } | |
| this.init(callback); | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| // Also valid because we are passing the callback to | |
| // someone else to call. | |
| if (y === 1) { | |
| this.something(callback); | |
| } | |
| this.init(callback); | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| if (a === 1) { | |
| // This is ok because it is the last statement, | |
| // even though it is conditional. | |
| this.something(callback); | |
| } | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| if (dfx.isFn(callback) === true) { | |
| callback.call(this, cont); | |
| return; | |
| } | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| dfx.foreach(items, function(item) { | |
| return true; | |
| }); | |
| if (dfx.isFn(callback) === true) { | |
| callback.call(this); | |
| } | |
| } | |
| }; | |
| SampleWidgetType.prototype = { | |
| create: function(callback) | |
| { | |
| var self = this; | |
| this.createChildren(null, function() { | |
| callback.call(self, div); | |
| return; | |
| }); | |
| } | |
| }; |