Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #50 #60

Merged
merged 4 commits into from
Feb 28, 2018
Merged

Issue #50 #60

merged 4 commits into from
Feb 28, 2018

Conversation

emicklei
Copy link
Owner

No description provided.

@bufdev
Copy link
Contributor

bufdev commented Feb 27, 2018

Can you add a test for:

  • two-deep nested ie foo { bar { baz: "bat" } }
  • two elements in a nested ie foo { bar: "baz bat:"ban" }

@bufdev
Copy link
Contributor

bufdev commented Feb 27, 2018

Here's the updated test for those two:

func TestNestedAggregateConstants(t *testing.T) {
	src := `syntax = "proto3";

	package baz;

	option (foo.bar) = {
	  woot: 100
	  foo {
		hello: 200
		hello2: 300
		bar {
			hello3: 400
		}
	  }
	};`
	p := newParserOn(src)
	proto, err := p.Parse()
	if err != nil {
		t.Error(err)
	}
	option := proto.Elements[2].(*Option)
	if got, want := option.Name, "(foo.bar)"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := len(option.AggregatedConstants), 4; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := option.AggregatedConstants[0].Name, "woot"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := option.AggregatedConstants[1].Name, "foo.hello"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := option.AggregatedConstants[2].Name, "foo.hello2"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := option.AggregatedConstants[3].Name, "foo.bar.hello3"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := option.AggregatedConstants[1].Literal.SourceRepresentation(), "200"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := option.AggregatedConstants[2].Literal.SourceRepresentation(), "300"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := option.AggregatedConstants[3].Literal.SourceRepresentation(), "400"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
}

@bufdev
Copy link
Contributor

bufdev commented Feb 28, 2018

Can we merge? :-)

@emicklei emicklei merged commit 04b3b05 into master Feb 28, 2018
@emicklei emicklei deleted the issue50 branch February 28, 2018 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants