Skip to content
This repository was archived by the owner on Mar 26, 2021. It is now read-only.

Commit ff89a86

Browse files
committed
add more examples
1 parent cda3863 commit ff89a86

File tree

4 files changed

+71
-9
lines changed

4 files changed

+71
-9
lines changed

gulpfile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,27 @@ function testchain () {
155155
.pipe(gulp.dest('./testoutput'));
156156
}
157157

158+
159+
function testc2 () {
160+
return gulp.src(['testsupport/c2_test.js'], { read: false })
161+
.pipe(cover.instrument({
162+
pattern: ['**/c2_cov.js'],
163+
debugDirectory: 'debug/info'
164+
}))
165+
.pipe(mochaTask({
166+
reporter: 'spec'
167+
}))
168+
.pipe(cover.gather())
169+
.pipe(cover.format({
170+
outFile: 'c2.html'
171+
}))
172+
.pipe(gulp.dest('./testoutput'))
173+
.pipe(cover.format({
174+
outFile: 'c2.json',
175+
reporter: 'json'
176+
}))
177+
.pipe(gulp.dest('./testoutput'));
178+
}
158179
/*
159180
* setup function
160181
*/
@@ -188,6 +209,8 @@ gulp.task('default', function() {
188209

189210
gulp.task('debug', debugDeps, debug);
190211

212+
gulp.task('c2', [], testc2);
213+
191214
setup();
192215

193216
gulp.task('watch', function () {

test/cover.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,20 @@ describe('cover.js', function () {
174174
stats = coverInst.allStats();
175175
// console.log(stats);
176176
it('will return the uncovered files', function () {
177+
//console.log(stats.uncovered);
177178
assert.deepEqual(stats.uncovered, [
179+
'testsupport/c2_cov.js',
180+
'testsupport/c2_test.js',
178181
'testsupport/chain.js',
179-
'testsupport/chainable.js',
180-
'testsupport/myModule.js',
181-
'testsupport/rewire.js',
182-
'testsupport/src.js',
183-
'testsupport/src2.js',
184-
'testsupport/src3.js',
185-
'testsupport/srcchain.js',
186-
'testsupport/srcjasmine.js',
187-
'testsupport/test.js' ]);
182+
'testsupport/chainable.js',
183+
'testsupport/myModule.js',
184+
'testsupport/rewire.js',
185+
'testsupport/src.js',
186+
'testsupport/src2.js',
187+
'testsupport/src3.js',
188+
'testsupport/srcchain.js',
189+
'testsupport/srcjasmine.js',
190+
'testsupport/test.js' ]);
188191
});
189192
it('will return the correct number of code lines', function () {
190193
assert.equal(stats.sloc, 9);

testsupport/c2_cov.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = function () {
2+
var a = false, b = false;
3+
4+
if (a && b) {
5+
console.log('a && b');
6+
}
7+
8+
a = true;
9+
10+
if (a && b) {
11+
console.log('a && b');
12+
}
13+
14+
b = true;
15+
a = false;
16+
17+
if (a && b) {
18+
console.log('a && b');
19+
}
20+
21+
a = true;
22+
b = true;
23+
24+
if (a && b) {
25+
console.log('a && b');
26+
}
27+
};

testsupport/c2_test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var assert = require('assert'),
2+
test = require('./c2_cov');
3+
4+
describe('Test C2', function () {
5+
it('SShould just run', function () {
6+
test();
7+
assert(true);
8+
});
9+
});

0 commit comments

Comments
 (0)