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

Reflect actual slice type in TreeFromMap #145

Merged
merged 5 commits into from
Mar 23, 2017

Conversation

pelletier
Copy link
Owner

Retrieve the actual type of a slice's elements when possible.

Fixes #143

@carolynvs
Copy link
Contributor

carolynvs commented Mar 21, 2017

I just tested this with my dep tests and now I am getting a new error. Here's an updated test to reproduce:

func TestRoundTripArrayOfTables(t *testing.T) {
	orig := "\n[[stuff]]\n  name = \"foo\"\n  things = [\"a\",\"b\"]"
	tree, err := Load(orig)
	if err != nil {
		t.Fatalf("unexpected error: %s", err)
	}

	m := tree.ToMap()

	tree, err = TreeFromMap(m)
	if err != nil {
		t.Fatalf("unexpected error: %s", err)
	}

	want := orig
	got, err := tree.ToTomlString()
	if err != nil {
		t.Fatalf("unexpected error: %s", err)
	}

	if got != want {
		t.Errorf("want:\n%q\ngot:\n%q", want, got)
	}
}

Output

unexpected error: unsupported value type []string: [a b]

@pelletier
Copy link
Owner Author

@carolynvs Good catch! Added a fix for that bug as well.

@carolynvs
Copy link
Contributor

Thank you! All fixed. 💖

@pelletier pelletier merged commit f6e7596 into master Mar 23, 2017
@pelletier pelletier deleted the pelletier/reflect-actual-slice-type branch March 23, 2017 10:20
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