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

Test on toml-v0.4.0 example #206

Closed
leptonyu opened this issue Jul 10, 2019 · 8 comments
Closed

Test on toml-v0.4.0 example #206

leptonyu opened this issue Jul 10, 2019 · 8 comments
Labels
bug Something isn't working parser Everything related to `Text -> Toml` test Testing (unit, properties)

Comments

@leptonyu
Copy link

################################################################################
## Inline Table

# Inline tables provide a more compact syntax for expressing tables. They are
# especially useful for grouped data that can otherwise quickly become verbose.
# Inline tables are enclosed in curly braces `{` and `}`. No newlines are
# allowed between the curly braces unless they are valid within a value.

[table.inline]

name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }

My tests has the above inline block, it fails by using tomland-1.1.0.0

uncaught exception: IOException of type UserError
user error (ParseException "61:8:\n   |\n61 | name = { first = \"Tom\", last = \"Preston-Werner\" }\n   |        ^\n\"name\" :| [] is not a child key of \"table\" :| [\"inline\"]\n")
@chshersh chshersh added bug Something isn't working parser Everything related to `Text -> Toml` labels Jul 10, 2019
@chshersh
Copy link
Contributor

@leptonyu Thanks for reporting the issue! That was unexpected 😕 We will improve our test-suite and fix the bug. Could you also provide the link to your tests, so we can test before releasing a new version to Hackage?

/cc @jiegillet

@leptonyu
Copy link
Author

My tests file was copied from the offical toml-lang repo. example-v0.4.0.toml

Here are the link.
salak.toml

@leptonyu
Copy link
Author

Official toml file link

@chshersh chshersh changed the title tomland-1.1.0.0 break down tests Test on toml-v0.4.0 example Jul 10, 2019
@chshersh chshersh added the test Testing (unit, properties) label Jul 10, 2019
@chshersh
Copy link
Contributor

@leptonyu Nice to have an example! I've changed the title of this issue to implement more robust testing.

@jiegillet
Copy link
Collaborator

Sorry about that. For this specific issue, adding a try at the right place fixes it. I'll do a PR, I should also probably add all official examples and make sure they are fine.

I have one uncertainty about this situation though. Should

[table.inline]
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }

be interpreted as one table table.inline containing two sub tables name and point, or should it be considered as three separate tables on the same level? The official documentation says:

name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
animal = { type.name = "pug" }

The inline tables above are identical to the following standard table definitions:

[name]
first = "Tom"
last = "Preston-Werner"

[point]
x = 1
y = 2

[animal]
type.name = "pug"

Following this definition, the table should be three different tables right? That's what my parser does (and will do correctly as soon as I fix the current issue).

I think this is correct but I never found a satisfying explicit answer or counter-example. What do you think?

@leptonyu
Copy link
Author

Reviewing the following issue, I think you are right. The motivation of inline tables is not to supporting sub tables, but to simplify tables.
Tuples and Inline Tables: A Motivation

@jiegillet
Copy link
Collaborator

Thanks for looking into it!

jiegillet added a commit that referenced this issue Jul 10, 2019
chshersh pushed a commit that referenced this issue Jul 10, 2019
* [#206] Test on toml-v0.4.0 example

* Added offical TOML examples as tests

* Added unit tests for specific issue

* CHANGELOG

* Update CHANGELOG.md

Co-Authored-By: Dmitrii Kovanikov <[email protected]>

* listDirectory instead of hardcoded paths
@chshersh
Copy link
Contributor

@leptonyu This was fixed by @jiegillet. I've uploaded tomland-1.1.0.1 to Hackage:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Everything related to `Text -> Toml` test Testing (unit, properties)
Projects
None yet
Development

No branches or pull requests

3 participants