Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed document
- Loading branch information
Showing
4 changed files
with
197 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
|
||
var testMetrics = require('./lib/test-metrics'); | ||
var assert = require('assert'); | ||
|
||
assert.ok(!testMetrics.hasComplexCode('./test/test_sample1.js',10)); | ||
assert.ok(testMetrics.hasComplexCode('./test/test_sample1.js',1)); | ||
//Complexity | ||
assert.ok(!testMetrics.hasComplexCode('./test/test_sample1.js', 10), 'complexity of test_sample1.js does not exceed threshold value'); | ||
assert.ok(testMetrics.hasComplexCode('./test/test_sample1.js', 1), 'complexity of test_sample1.js exceeds threshold value'); | ||
assert.ok(testMetrics.hasComplexCode('./test/test_sample2.js', 5), 'complexity of test_sample2.js exceeds threshold value'); | ||
|
||
//Lines | ||
assert.ok(!testMetrics.hasTooLargeFunction('./test/test_sample1.js', 100), 'lines of test_sample1.js does not exceed threshold value'); | ||
assert.ok(testMetrics.hasTooLargeFunction('./test/test_sample2.js', 100), 'lines of test_sample2.js exceeds threshold value'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
var nop = function() { | ||
}; | ||
function foo(x) { | ||
var func = (function(x) { | ||
if(!x) | ||
return nop; | ||
if(x == 0) { | ||
return function(y) { | ||
nop(); | ||
}; | ||
} else if(x > 0) { | ||
return function() {(function(y) { | ||
nop(); | ||
})(); | ||
}; | ||
} else { | ||
return function() {(function() { | ||
nop(); | ||
})(); | ||
}; | ||
} | ||
})(x); | ||
return func; | ||
} | ||
|
||
function bar() { | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
nop(); | ||
} |