Skip to content

Commit

Permalink
Added a heap of coverage comments for usually unused code paths to op…
Browse files Browse the repository at this point in the history
…en things up
  • Loading branch information
dcodeIO committed Dec 18, 2016
1 parent 964f65a commit 1fcfdfe
Show file tree
Hide file tree
Showing 27 changed files with 324 additions and 51 deletions.
153 changes: 140 additions & 13 deletions dist/protobuf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

47 changes: 33 additions & 14 deletions dist/runtime/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/runtime/protobuf.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/runtime/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/runtime/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/runtime/protobuf.min.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Can be used as a drop-in replacement for the full library as it has the same general structure.
var protobuf = exports;

var Writer = protobuf.Writer = require("../src/writer");
protobuf.BufferWriter = Writer.BufferWriter;
var Reader = protobuf.Reader = require("../src/reader");
protobuf.BufferReader = Reader.BufferReader;
protobuf.Writer = require("../src/writer");
protobuf.BufferWriter = require("../src/writer_buffer");
protobuf.Reader = require("../src/reader");
protobuf.BufferReader = require("../src/reader_buffer");
protobuf.util = require("../src/util/runtime");
protobuf.roots = {};
protobuf.configure = configure;
Expand Down
4 changes: 4 additions & 0 deletions src/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ function Class(type) {
function create(type, ctor) {
if (!Type)
Type = require("./type");

/* istanbul ignore next */
if (!(type instanceof Type))
throw TypeError("type", "a Type");

if (ctor) {
/* istanbul ignore next */
if (typeof ctor !== "function")
throw TypeError("ctor", "a function");
} else
Expand Down
6 changes: 6 additions & 0 deletions src/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,20 @@ EnumPrototype.toJSON = function toJSON() {
* @throws {Error} If there is already a value with this name or id
*/
EnumPrototype.add = function(name, id) {

/* istanbul ignore next */
if (!util.isString(name))
throw TypeError("name");
/* istanbul ignore next */
if (!util.isInteger(id) || id < 0)
throw TypeError("id", "a non-negative integer");
/* istanbul ignore next */
if (this.values[name] !== undefined)
throw Error("duplicate name '" + name + "' in " + this);
/* istanbul ignore next */
if (this.getValuesById()[id] !== undefined)
throw Error("duplicate id " + id + " in " + this);

this.values[name] = id;
return clearCache(this);
};
Expand Down
6 changes: 6 additions & 0 deletions src/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ function Field(name, id, type, rule, extend, options) {
extend = undefined;
}
ReflectionObject.call(this, name, options);

/* istanbul ignore next */
if (!util.isInteger(id) || id < 0)
throw TypeError("id", "a non-negative integer");
/* istanbul ignore next */
if (!util.isString(type))
throw TypeError("type");
/* istanbul ignore next */
if (extend !== undefined && !util.isString(extend))
throw TypeError("extend");
/* istanbul ignore next */
if (rule !== undefined && !/^required|optional|repeated$/.test(rule = rule.toString().toLowerCase()))
throw TypeError("rule", "a valid rule string");

Expand Down Expand Up @@ -241,6 +246,7 @@ FieldPrototype.resolve = function resolve() {
typeDefault = null;
else if (this.resolvedType = this.parent.lookup(this.type, Enum))
typeDefault = 0;
/* istanbul ignore next */
else
throw Error("unresolvable field type: " + this.type);
}
Expand Down
2 changes: 2 additions & 0 deletions src/mapfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var Enum = require("./enum"),
*/
function MapField(name, id, keyType, type, options) {
Field.call(this, name, id, type, options);

/* istanbul ignore next */
if (!util.isString(keyType))
throw util._TypeError("keyType");

Expand Down
6 changes: 6 additions & 0 deletions src/method.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ function Method(name, type, requestType, responseType, requestStream, responseSt
options = responseStream;
responseStream = undefined;
}

/* istanbul ignore next */
if (type && !util.isString(type))
throw TypeError("type");
/* istanbul ignore next */
if (!util.isString(requestType))
throw TypeError("requestType");
/* istanbul ignore next */
if (!util.isString(responseType))
throw TypeError("responseType");

Expand Down Expand Up @@ -126,8 +130,10 @@ MethodPrototype.resolve = function resolve() {
if (this.resolved)
return this;

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

Expand Down
Loading

0 comments on commit 1fcfdfe

Please sign in to comment.