Permalink
Browse files

Added a heap of coverage comments for usually unused code paths to op…

…en things up
  • Loading branch information...
dcodeIO committed Dec 18, 2016
1 parent 964f65a commit 1fcfdfe21c1b321d975a8a96d133a452c9a9c0d8

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -22 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -3 Bytes (100%) dist/runtime/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -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;
@@ -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
@@ -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);
};
@@ -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");
@@ -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);
}
@@ -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");
@@ -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");
@@ -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);
Oops, something went wrong.

0 comments on commit 1fcfdfe

Please sign in to comment.