wildfire chat server source initial submit

This commit is contained in:
heavyrain2012
2019-03-16 17:04:23 +08:00
parent e59217bd10
commit cab3ca0916
1466 changed files with 528862 additions and 15919 deletions
+36
View File
@@ -0,0 +1,36 @@
var tape = require("tape");
var protobuf = require("..");
tape.test("uncommon statements", function(test) {
test.plan(3);
protobuf.load("tests/data/uncommon.proto", function(err, root) {
if (err || !root)
test.fail(err && err.message || "should parse without errors");
new protobuf.Root().load("tests/data/uncommon.proto", { keepCase: true }, function(err, root) {
if (err || !root) {
test.fail(err && err.message || "should parse without errors");
return;
}
test.pass("should parse without errors");
test.doesNotThrow(function() {
root.resolveAll();
}, "should resolve without errors");
test.doesNotThrow(function() {
traverseTypes(root, function(type) {
type.setup();
});
}, "should setup all types without errors");
test.end();
});
});
});
function traverseTypes(current, fn) {
if (current instanceof protobuf.Type) // and/or protobuf.Enum, protobuf.Service etc.
fn(current);
if (current.nestedArray)
current.nestedArray.forEach(function(nested) {
traverseTypes(nested, fn);
});
}