Permalink
Browse files

Properly parse text format options + simple test case, fixes #636

  • Loading branch information...
dcodeIO committed Jan 10, 2017
1 parent fe4d97b commit 7e57f4cdd284f886b936511b213a6468e4ddcdce

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

Oops, something went wrong.

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

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

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 +0 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.

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

Oops, something went wrong.
BIN +1 Byte (100%) dist/runtime/protobuf.min.js.gz
Binary file not shown.
@@ -468,11 +468,10 @@ function parse(source, root, options) {
if (!isName(token))
throw illegal(token, "name");
name = name + "." + token;
if (skip(":", true))
setOption(parent, name, readValue(true));
setOption(parent, name + "." + token, readValue(true));
else
parseOptionValue(parent, name);
parseOptionValue(parent, name + "." + token);
}
} else
setOption(parent, name, readValue(true));
@@ -0,0 +1,15 @@
syntax = "proto3";
import "google/protobuf/descriptor.proto";
message MyOptions {
string a = 1;
string b = 2;
}
extend google.protobuf.FieldOptions {
MyOptions my_options = 50000;
}
message Test {
string value = 1 [(my_options) = { a: "foo" b: "bar" }];
}
@@ -0,0 +1,15 @@
var tape = require("tape");
var protobuf = require("..");
tape.test("options in textformat", function(test) {
protobuf.load("tests/data/options-textformat.proto", function(err, root) {
if (err)
throw err;
var Test = root.lookup("Test");
test.same(Test.fields.value.options, { "(my_options).a": "foo", "(my_options).b": "bar" }, "should parse correctly");
test.end();
});
});

0 comments on commit 7e57f4c

Please sign in to comment.