hashicorp / hcl2

Former temporary home for experimental new version of HCL
https://github.com/hashicorp/hcl
Mozilla Public License 2.0
373 stars 66 forks source link

hclsyntax: Add test for 'func()[idx]' syntax #49

Closed radeksimko closed 5 years ago

radeksimko commented 5 years ago

github.com/go-test/deep has pretty low default settings for how deeply it should inspect nested structures. As an effect we were silently ignoring some differences.

Also see https://github.com/go-test/deep/issues/17

I'm not sure if there's a better way/place where to set MaxDepth or whether this depth is appropriate, it's just an arbitrary number. I'm open to suggestions.

I'm also adding a test which I used to invalidate my assumption that we parse func()[idx] incorrectly - i.e. there is nothing to fix, but I just thought it would be useful to have such test in place for the future, just in case.

apparentlymart commented 5 years ago

Good catch, thanks! I'll take a closer look at it soon once we've completed some work over in Terraform itself.

Since writing this I've learned about go-cmp, which we've been using to good effect in Terraform tests recently. When looking at this I'll also see how much work it'd be to update the tests to use that instead of go-test/deep, since that seems to have some better defaults and nicer failure output.

apparentlymart commented 5 years ago

On second thought, let's just merge this now and I'll play with go-cmp separately at some later date, since that's not at all urgent with this fix in place.