summaryrefslogtreecommitdiff
path: root/frontend-old/node_modules/protobufjs/ext/descriptor/test.js
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
committeraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
commit8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch)
tree05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/protobufjs/ext/descriptor/test.js
pain
Diffstat (limited to 'frontend-old/node_modules/protobufjs/ext/descriptor/test.js')
-rw-r--r--frontend-old/node_modules/protobufjs/ext/descriptor/test.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/frontend-old/node_modules/protobufjs/ext/descriptor/test.js b/frontend-old/node_modules/protobufjs/ext/descriptor/test.js
new file mode 100644
index 0000000..ceb80f8
--- /dev/null
+++ b/frontend-old/node_modules/protobufjs/ext/descriptor/test.js
@@ -0,0 +1,54 @@
+/*eslint-disable no-console*/
+"use strict";
+var protobuf = require("../../"),
+ descriptor = require(".");
+
+/* var proto = {
+ nested: {
+ Message: {
+ fields: {
+ foo: {
+ type: "string",
+ id: 1
+ }
+ },
+ nested: {
+ SubMessage: {
+ fields: {}
+ }
+ }
+ },
+ Enum: {
+ values: {
+ ONE: 1,
+ TWO: 2
+ }
+ }
+ }
+}; */
+
+// var root = protobuf.Root.fromJSON(proto).resolveAll();
+var root = protobuf.loadSync("tests/data/google/protobuf/descriptor.proto").resolveAll();
+
+// console.log("Original proto", JSON.stringify(root, null, 2));
+
+var msg = root.toDescriptor();
+
+// console.log("\nDescriptor", JSON.stringify(msg.toObject(), null, 2));
+
+var buf = descriptor.FileDescriptorSet.encode(msg).finish();
+var root2 = protobuf.Root.fromDescriptor(buf, "proto2").resolveAll();
+
+// console.log("\nDecoded proto", JSON.stringify(root2, null, 2));
+
+var diff = require("deep-diff").diff(root.toJSON(), root2.toJSON());
+if (diff) {
+ diff.forEach(function(diff) {
+ console.log(diff.kind + " @ " + diff.path.join("."));
+ console.log("lhs:", typeof diff.lhs, diff.lhs);
+ console.log("rhs:", typeof diff.rhs, diff.rhs);
+ console.log();
+ });
+ process.exitCode = 1;
+} else
+ console.log("no differences");