all files / workspace/ index-cov.js

61.48% Statements 75/122
89.55% Branches 60/67
47.37% Functions 9/19
60% Lines 69/115
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163                              267× 267×       36×       78× 78× 78×   188× 188× 188×               21× 13× 13×                   11× 11×                           13× 13× 13× 13× 11×     13× 13×                                                                                  
 
// instrument by jscoverage, do not modifly this file
(function (file, lines, conds, source) {
  var BASE;
  Eif (typeof global === 'object') {
    BASE = global;
  } else if (typeof window === 'object') {
    BASE = window;
  } else {
    throw new Error('[jscoverage] unknow ENV!');
  }
  Iif (BASE._$jscoverage) {
    BASE._$jscmd(file, 'init', lines, conds, source);
    return;
  }
  var cov = {};
  /**
   * jsc(file, 'init', lines, condtions)
   * jsc(file, 'line', lineNum)
   * jsc(file, 'cond', lineNum, expr, start, offset)
   */
  function jscmd(file, type, line, express, start, offset) {
    var storage;
    switch (type) {
      case 'init':
        Iif(cov[file]){
          storage = cov[file];
        } else {
          storage = [];
          for (var i = 0; i < line.length; i ++) {
            storage[line[i]] = 0;
          }
          var condition = express;
          var source = start;
          storage.condition = condition;
          storage.source = source;
        }
        cov[file] = storage;
        break;
      case 'line':
        storage = cov[file];
        storage[line] ++;
        break;
      case 'cond':
        storage = cov[file];
        storage.condition[line] ++;
        return express;
    }
  }
 
  BASE._$jscoverage = cov;
  BASE._$jscmd = jscmd;
  jscmd(file, 'init', lines, conds, source);
})('index.js', [1,3,5,72,103,66,9,32,41,13,14,17,21,22,27,23,24,25,34,47,48,54,55,60,61,62,67,68,100,81,82,88,89,94,95,96], {"7_12_63":0,"7_12_28":0,"7_45_30":0,"21_24_7":0,"21_35_19":0,"36_28_29":0,"44_12_58":0,"44_12_26":0,"44_42_28":0,"49_15_7":0,"49_26_20":0,"49_48_4":0,"49_56_8":0,"51_12_26":0,"56_15_7":0,"56_26_19":0,"56_47_4":0,"56_55_8":0,"58_12_58":0,"58_12_26":0,"58_42_28":0,"63_15_7":0,"63_26_24":0,"63_52_4":0,"63_60_8":0,"74_12_63":0,"74_12_28":0,"74_45_30":0,"78_12_58":0,"78_12_26":0,"78_42_28":0,"83_15_7":0,"83_26_24":0,"83_52_4":0,"83_60_8":0,"85_12_26":0,"90_15_7":0,"90_26_28":0,"90_56_4":0,"90_64_8":0,"92_12_58":0,"92_12_26":0,"92_42_28":0,"97_15_7":0,"97_26_33":0,"97_61_4":0,"97_69_8":0}, ["var stream = require('stream');","","module.exports = function (exports) {","    ","    var unit = function (expected, message, data) {","        ","        if (expected instanceof Function ||  typeof expected === 'function') {","            ","            var duplex =  new stream.Duplex({","                objectMode: true,","                highWaterMark: 1,","                read: function() {","                    this.push(data);","                    this.pause();","                },","                write: function(data, encoding, callback) {","                    callback();","                }","            }).on('pipe', function (source) {","                ","                exports[message || expected.toString()] = function (test) {","                    this._write = function(data, encoding, callback) {","                        expected.call(test, data);","                        source.unpipe(this);","                        callback();","                    };","                    this.emit('drain');","                }.bind(this);","                ","            });","            ","            duplex.pipe = (function (pipe) {","                ","                return function() {","                    for (var key in arguments)","                        if (arguments.hasOwnProperty(key))","                            pipe.call(this, arguments[key]);","                };","            })(duplex.pipe);","            ","            return duplex;","        }","        ","        if (expected instanceof String || typeof expected === 'string')","            ","            return unit(function (data) {","                this.strictEqual(data, expected);","                this.done();","            }, message || '\"' + expected + '\"', data || expected);","        ","        if (expected instanceof RegExp)","            ","            return unit(function (data) {","                this.ok(expected.test(data));","                this.done();","            }, message || expected.toString(), data || expected);","        ","        if (expected instanceof Object || typeof callback === 'object') {","            ","            return unit(function (data) {","                this.deepEqual(data, expected);","                this.done();","            }, message || JSON.stringify(expected), data || expected);","        }","        ","        return unit(function () {","            this.ok(process.env.UNIT_TEST);","            this.done();","        }, 'not expected');","    };","    ","    unit.not = function (expected, message, data) {","        ","        if (expected instanceof Function ||  typeof expected === 'function')","            ","            return unit(expected, message);","        ","        if (expected instanceof String || typeof expected === 'string')","            ","            return unit(function (data) {","                this.notStrictEqual(data, expected);","                this.done();","            }, message || 'not \"' + expected + '\"', data || expected);","        ","        if (expected instanceof RegExp)","            ","            return unit(function (data) {","                this.ok(!expected.test(data));","                this.done();","            }, message || 'not ' + expected.toString(), data || expected);","        ","        if (expected instanceof Object || typeof callback === 'object') {","            ","            return unit(function (data) {","                this.notDeepEqual(data, expected);","                this.done();","            }, message || 'not ' + JSON.stringify(expected), data || expected);","        }","            ","        return unit(expected);","    };","    ","    return unit;","};"]);
_$jscmd("index.js", "line", 1);
 
var stream = require("stream");
 
_$jscmd("index.js", "line", 3);
 
module.exports = function(exports) {
    _$jscmd("index.js", "line", 5);
    var unit = function(expected, message, data) {
        if (_$jscmd("index.js", "cond", "7_12_63", _$jscmd("index.js", "cond", "7_12_28", expected instanceof Function) || _$jscmd("index.js", "cond", "7_45_30", typeof expected === "function"))) {
            _$jscmd("index.js", "line", 9);
            var duplex = new stream.Duplex({
                objectMode: true,
                highWaterMark: 1,
                read: function() {
                    _$jscmd("index.js", "line", 13);
                    this.push(data);
                    _$jscmd("index.js", "line", 14);
                    this.pause();
                },
                write: function(data, encoding, callback) {
                    _$jscmd("index.js", "line", 17);
                    callback();
                }
            }).on("pipe", function(source) {
                _$jscmd("index.js", "line", 21);
                exports[_$jscmd("index.js", "cond", "21_24_7", message) || _$jscmd("index.js", "cond", "21_35_19", expected.toString())] = function(test) {
                    _$jscmd("index.js", "line", 22);
                    this._write = function(data, encoding, callback) {
                        _$jscmd("index.js", "line", 23);
                        expected.call(test, data);
                        _$jscmd("index.js", "line", 24);
                        source.unpipe(this);
                        _$jscmd("index.js", "line", 25);
                        callback();
                    };
                    _$jscmd("index.js", "line", 27);
                    this.emit("drain");
                }.bind(this);
            });
            _$jscmd("index.js", "line", 32);
            duplex.pipe = function(pipe) {
                _$jscmd("index.js", "line", 34);
                return function() {
                    for (var key in arguments) Eif (_$jscmd("index.js", "cond", "36_28_29", arguments.hasOwnProperty(key))) pipe.call(this, arguments[key]);
                };
            }(duplex.pipe);
            _$jscmd("index.js", "line", 41);
            return duplex;
        }
        if (_$jscmd("index.js", "cond", "44_12_58", _$jscmd("index.js", "cond", "44_12_26", expected instanceof String) || _$jscmd("index.js", "cond", "44_42_28", typeof expected === "string"))) return unit(function(data) {
            _$jscmd("index.js", "line", 47);
            this.strictEqual(data, expected);
            _$jscmd("index.js", "line", 48);
            this.done();
        }, _$jscmd("index.js", "cond", "49_15_7", message) || _$jscmd("index.js", "cond", "49_26_20", '"' + expected + '"'), _$jscmd("index.js", "cond", "49_48_4", data) || _$jscmd("index.js", "cond", "49_56_8", expected));
        if (_$jscmd("index.js", "cond", "51_12_26", expected instanceof RegExp)) return unit(function(data) {
            _$jscmd("index.js", "line", 54);
            this.ok(expected.test(data));
            _$jscmd("index.js", "line", 55);
            this.done();
        }, _$jscmd("index.js", "cond", "56_15_7", message) || _$jscmd("index.js", "cond", "56_26_19", expected.toString()), _$jscmd("index.js", "cond", "56_47_4", data) || _$jscmd("index.js", "cond", "56_55_8", expected));
        if (_$jscmd("index.js", "cond", "58_12_58", _$jscmd("index.js", "cond", "58_12_26", expected instanceof Object) || _$jscmd("index.js", "cond", "58_42_28", typeof callback === "object"))) {
            _$jscmd("index.js", "line", 60);
            return unit(function(data) {
                _$jscmd("index.js", "line", 61);
                this.deepEqual(data, expected);
                _$jscmd("index.js", "line", 62);
                this.done();
            }, _$jscmd("index.js", "cond", "63_15_7", message) || _$jscmd("index.js", "cond", "63_26_24", JSON.stringify(expected)), _$jscmd("index.js", "cond", "63_52_4", data) || _$jscmd("index.js", "cond", "63_60_8", expected));
        }
        _$jscmd("index.js", "line", 66);
        return unit(function() {
            _$jscmd("index.js", "line", 67);
            this.ok(process.env.UNIT_TEST);
            _$jscmd("index.js", "line", 68);
            this.done();
        }, "not expected");
    };
    _$jscmd("index.js", "line", 72);
    unit.not = function(expected, message, data) {
        Iif (_$jscmd("index.js", "cond", "74_12_63", _$jscmd("index.js", "cond", "74_12_28", expected instanceof Function) || _$jscmd("index.js", "cond", "74_45_30", typeof expected === "function"))) return unit(expected, message);
        if (_$jscmd("index.js", "cond", "78_12_58", _$jscmd("index.js", "cond", "78_12_26", expected instanceof String) || _$jscmd("index.js", "cond", "78_42_28", typeof expected === "string"))) return unit(function(data) {
            _$jscmd("index.js", "line", 81);
            this.notStrictEqual(data, expected);
            _$jscmd("index.js", "line", 82);
            this.done();
        }, _$jscmd("index.js", "cond", "83_15_7", message) || _$jscmd("index.js", "cond", "83_26_24", 'not "' + expected + '"'), _$jscmd("index.js", "cond", "83_52_4", data) || _$jscmd("index.js", "cond", "83_60_8", expected));
        if (_$jscmd("index.js", "cond", "85_12_26", expected instanceof RegExp)) return unit(function(data) {
            _$jscmd("index.js", "line", 88);
            this.ok(!expected.test(data));
            _$jscmd("index.js", "line", 89);
            this.done();
        }, _$jscmd("index.js", "cond", "90_15_7", message) || _$jscmd("index.js", "cond", "90_26_28", "not " + expected.toString()), _$jscmd("index.js", "cond", "90_56_4", data) || _$jscmd("index.js", "cond", "90_64_8", expected));
        if (_$jscmd("index.js", "cond", "92_12_58", _$jscmd("index.js", "cond", "92_12_26", expected instanceof Object) || _$jscmd("index.js", "cond", "92_42_28", typeof callback === "object"))) {
            _$jscmd("index.js", "line", 94);
            return unit(function(data) {
                _$jscmd("index.js", "line", 95);
                this.notDeepEqual(data, expected);
                _$jscmd("index.js", "line", 96);
                this.done();
            }, _$jscmd("index.js", "cond", "97_15_7", message) || _$jscmd("index.js", "cond", "97_26_33", "not " + JSON.stringify(expected)), _$jscmd("index.js", "cond", "97_61_4", data) || _$jscmd("index.js", "cond", "97_69_8", expected));
        }
        _$jscmd("index.js", "line", 100);
        return unit(expected);
    };
    _$jscmd("index.js", "line", 103);
    return unit;
};