Skip to content

Commit 68e4480

Browse files
committed
see diff
1 parent 0a7bbd1 commit 68e4480

File tree

4 files changed

+30
-42
lines changed

4 files changed

+30
-42
lines changed

src/parse.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ function parse(source, root, options) {
381381

382382
default:
383383
/* istanbul ignore if */
384-
if (!isProto3 || !edition || !typeRefRe.test(token))
384+
if ((!isProto3 && !edition) || !typeRefRe.test(token))
385385
throw illegal(token);
386386

387387
push(token);
@@ -476,8 +476,7 @@ function parse(source, root, options) {
476476
case "option":
477477
parseOption(type, token);
478478
skip(";");
479-
break;
480-
479+
break;
481480
case "required":
482481
case "repeated":
483482
parseField(type, token);

src/root.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ Root.prototype.load = function load(filename, options, callback) {
154154

155155
// Shortcut bundled definitions
156156
if (filename in common) {
157-
if (sync) {
157+
if (sync)
158158
process(filename, common[filename]);
159-
} else {
159+
else {
160160
++queued;
161161
setTimeout(function() {
162162
--queued;

tests/data/feature-resolution.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ enum SomeEnum {
5757
option features.amazing_feature = C;
5858
ONE = 1 [features.amazing_feature = K];
5959
TWO = 2;
60-
}
60+
}

tests/feature_resolution_editions.js

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,31 @@ message Message {
4343
4444
extensions 10 to 100;
4545
extend Message {
46-
int32 bar = 10 [features.amazing_feature = I];
46+
required int32 bar = 10 [features.amazing_feature = I];
4747
}
4848
4949
message Nested {
50-
option features.amazing_feature = H;
51-
optional int32 count = 1;
50+
option features.amazing_feature = H;
51+
optional int64 count = 9;
5252
}
5353
54-
enum SomeEnum {
54+
enum SomeEnumInMessage {
5555
option features.amazing_feature = G;
56-
ONE = 1;
57-
TWO = 2;
56+
ONE = 11;
57+
TWO = 12;
5858
}
5959
60-
oneof bar {
60+
oneof SomeOneOf {
6161
option features.amazing_feature = J;
62-
int32 a = 1;
63-
string b = 2;
62+
int32 a = 13;
63+
string b = 14;
6464
}
6565
66-
map<string,int64> int64_map = 9;
66+
map<string,int64> int64_map = 15;
6767
}
6868
6969
extend Message {
70-
int32 bar = 11 [features.amazing_feature = D];
70+
required int32 bar = 16 [features.amazing_feature = D];
7171
}
7272
7373
enum SomeEnum {
@@ -83,33 +83,22 @@ var tape = require("tape");
8383
var protobuf = require("..");
8484

8585

86-
tape.test.only("feature resolution editions", function(test) {
86+
tape.test("feature resolution editions", function(test) {
8787

8888
protobuf.load("tests/data/feature-resolution.proto", function(err, root) {
8989
if (err)
9090
return test.fail(err.message);
91-
92-
// test.same(root.fea, {
93-
// 1: "a",
94-
// 2: "b"
95-
// }, "should also expose their values by id");
96-
97-
// console.log(root.features.amazing_feature)
98-
99-
test.same(root.features.amazing_feature, 'A');
100-
test.same(root.lookup("Message").features.amazing_feature, 'B')
101-
test.same(root.lookupService("MyService").features.amazing_feature, 'E');
102-
test.same(root.lookupEnum("SomeEnum").features.amazing_feature, 'C')
103-
test.same(root.lookup("Message").lookupEnum("SomeEnumInMessage").features.amazing_feature, 'G')
104-
test.same(root.lookup("Message").lookup("Nested").features.amazing_feature, 'H')
105-
test.same(root.lookupService("MyService").lookup("MyMethod").features.amazing_feature, 'L')
106-
test.same(root.lookup("Message").fields.stringRepeated.features.amazing_feature, 'F')
107-
test.same(root.lookup("Message").lookup(".Message.bar").features.amazing_feature, 'I')
108-
test.same(root.lookupEnum("SomeEnum").valuesFeatures.ONE.amazing_feature, 'K')
109-
110-
test.end();
91+
test.same(root.features.amazing_feature, 'A');
92+
test.same(root.lookup("Message").features.amazing_feature, 'B')
93+
test.same(root.lookupService("MyService").features.amazing_feature, 'E');
94+
test.same(root.lookupEnum("SomeEnum").features.amazing_feature, 'C')
95+
test.same(root.lookup("Message").lookupEnum("SomeEnumInMessage").features.amazing_feature, 'G')
96+
test.same(root.lookup("Message").lookup("Nested").features.amazing_feature, 'H')
97+
test.same(root.lookupService("MyService").lookup("MyMethod").features.amazing_feature, 'L')
98+
test.same(root.lookup("Message").fields.stringRepeated.features.amazing_feature, 'F')
99+
test.same(root.lookup("Message").lookup(".Message.bar").features.amazing_feature, 'I')
100+
test.same(root.lookupEnum("SomeEnum").valuesFeatures.ONE.amazing_feature, 'K')
101+
102+
test.end();
103+
})
111104
})
112-
113-
114-
115-
})

0 commit comments

Comments
 (0)