Skip to content

Commit 1fcfdfe

Browse files
committed
Added a heap of coverage comments for usually unused code paths to open things up
1 parent 964f65a commit 1fcfdfe

27 files changed

+324
-51
lines changed

dist/protobuf.js

+140-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

-22 Bytes
Binary file not shown.

dist/protobuf.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/runtime/protobuf.js

+33-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/runtime/protobuf.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/runtime/protobuf.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/runtime/protobuf.min.js.gz

-3 Bytes
Binary file not shown.

dist/runtime/protobuf.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Can be used as a drop-in replacement for the full library as it has the same general structure.
33
var protobuf = exports;
44

5-
var Writer = protobuf.Writer = require("../src/writer");
6-
protobuf.BufferWriter = Writer.BufferWriter;
7-
var Reader = protobuf.Reader = require("../src/reader");
8-
protobuf.BufferReader = Reader.BufferReader;
5+
protobuf.Writer = require("../src/writer");
6+
protobuf.BufferWriter = require("../src/writer_buffer");
7+
protobuf.Reader = require("../src/reader");
8+
protobuf.BufferReader = require("../src/reader_buffer");
99
protobuf.util = require("../src/util/runtime");
1010
protobuf.roots = {};
1111
protobuf.configure = configure;

src/class.js

+4
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ function Class(type) {
2828
function create(type, ctor) {
2929
if (!Type)
3030
Type = require("./type");
31+
32+
/* istanbul ignore next */
3133
if (!(type instanceof Type))
3234
throw TypeError("type", "a Type");
35+
3336
if (ctor) {
37+
/* istanbul ignore next */
3438
if (typeof ctor !== "function")
3539
throw TypeError("ctor", "a function");
3640
} else

src/enum.js

+6
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,20 @@ EnumPrototype.toJSON = function toJSON() {
112112
* @throws {Error} If there is already a value with this name or id
113113
*/
114114
EnumPrototype.add = function(name, id) {
115+
116+
/* istanbul ignore next */
115117
if (!util.isString(name))
116118
throw TypeError("name");
119+
/* istanbul ignore next */
117120
if (!util.isInteger(id) || id < 0)
118121
throw TypeError("id", "a non-negative integer");
122+
/* istanbul ignore next */
119123
if (this.values[name] !== undefined)
120124
throw Error("duplicate name '" + name + "' in " + this);
125+
/* istanbul ignore next */
121126
if (this.getValuesById()[id] !== undefined)
122127
throw Error("duplicate id " + id + " in " + this);
128+
123129
this.values[name] = id;
124130
return clearCache(this);
125131
};

src/field.js

+6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ function Field(name, id, type, rule, extend, options) {
3838
extend = undefined;
3939
}
4040
ReflectionObject.call(this, name, options);
41+
42+
/* istanbul ignore next */
4143
if (!util.isInteger(id) || id < 0)
4244
throw TypeError("id", "a non-negative integer");
45+
/* istanbul ignore next */
4346
if (!util.isString(type))
4447
throw TypeError("type");
48+
/* istanbul ignore next */
4549
if (extend !== undefined && !util.isString(extend))
4650
throw TypeError("extend");
51+
/* istanbul ignore next */
4752
if (rule !== undefined && !/^required|optional|repeated$/.test(rule = rule.toString().toLowerCase()))
4853
throw TypeError("rule", "a valid rule string");
4954

@@ -241,6 +246,7 @@ FieldPrototype.resolve = function resolve() {
241246
typeDefault = null;
242247
else if (this.resolvedType = this.parent.lookup(this.type, Enum))
243248
typeDefault = 0;
249+
/* istanbul ignore next */
244250
else
245251
throw Error("unresolvable field type: " + this.type);
246252
}

src/mapfield.js

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var Enum = require("./enum"),
2626
*/
2727
function MapField(name, id, keyType, type, options) {
2828
Field.call(this, name, id, type, options);
29+
30+
/* istanbul ignore next */
2931
if (!util.isString(keyType))
3032
throw util._TypeError("keyType");
3133

src/method.js

+6
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
3333
options = responseStream;
3434
responseStream = undefined;
3535
}
36+
37+
/* istanbul ignore next */
3638
if (type && !util.isString(type))
3739
throw TypeError("type");
40+
/* istanbul ignore next */
3841
if (!util.isString(requestType))
3942
throw TypeError("requestType");
43+
/* istanbul ignore next */
4044
if (!util.isString(responseType))
4145
throw TypeError("responseType");
4246

@@ -126,8 +130,10 @@ MethodPrototype.resolve = function resolve() {
126130
if (this.resolved)
127131
return this;
128132

133+
/* istanbul ignore next */
129134
if (!(this.resolvedRequestType = this.parent.lookup(this.requestType, Type)))
130135
throw Error("unresolvable request type: " + this.requestType);
136+
/* istanbul ignore next */
131137
if (!(this.resolvedResponseType = this.parent.lookup(this.responseType, Type)))
132138
throw Error("unresolvable response type: " + this.requestType);
133139

0 commit comments

Comments
 (0)