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

add support of mixed-type array #376

Merged
merged 2 commits into from
May 7, 2020

Conversation

AllenX2018
Copy link
Contributor

Issue: #357

This pr adds support of mixed-type array as the spec(v1.0.0) describes:

Values of different types may be mixed.

# Mixed-type arrays are allowed
numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]
contributors = [
 "Foo Bar <foo@example.com>",
  { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
]

@codecov
Copy link

codecov bot commented Apr 26, 2020

Codecov Report

Merging #376 into master will decrease coverage by 0.29%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #376      +/-   ##
==========================================
- Coverage   95.54%   95.24%   -0.30%     
==========================================
  Files          10       10              
  Lines        2288     2313      +25     
==========================================
+ Hits         2186     2203      +17     
- Misses         65       70       +5     
- Partials       37       40       +3     
Impacted Files Coverage Δ
tomltree_write.go 94.69% <87.09%> (-0.83%) ⬇️
marshal.go 96.18% <100.00%> (-0.60%) ⬇️
parser.go 90.76% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ccd9bb...984af92. Read the comment docs.

@pelletier
Copy link
Owner

Thank you for taking care of this, I apologize for the delay in review. I think the PR could use a test for the new check in valueToOtherSlice as it's part of the new behavior.

@AllenX2018
Copy link
Contributor Author

I think valueToOtherSlice's changes has been covered by TestMarshalMixedTypeArray().

if mtype.Elem().Kind() == reflect.Interface {
	return nil, fmt.Errorf("marshal can't handle []interface{}")
}

I delete these lines to support []interface type when marshaling and TestMarshalMixedTypeArray() has add a test for this type. Is there any other lines/paths/changes that need to be checked?

@pelletier
Copy link
Owner

Ha my bad, looks like I misread the diff. All good, thank you for calling this out!

@pelletier pelletier merged commit c5fbd3e into pelletier:master May 7, 2020
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