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

Use toml for test cases #5

Open
dvc94ch opened this issue Jan 23, 2018 · 5 comments
Open

Use toml for test cases #5

dvc94ch opened this issue Jan 23, 2018 · 5 comments
Labels
antlr-port Issues only applicable to our attempt to port to antlr

Comments

@dvc94ch
Copy link
Collaborator

dvc94ch commented Jan 23, 2018

If our grammar is language agnostic so should the test cases.

[test-suite]
parser = 'strict'
rule = 'all_packages'
describe = 'chip packages'

[[test]]
it = 'parses 0805'

[test.cases]
metric = '0805'
imperial = '2012'

[test.result]
package = '0805'

[test.ignored]
0 = ''

[test.warnings]
ambiguous_size = true
@dvc94ch
Copy link
Collaborator Author

dvc94ch commented Jan 23, 2018

lit is written in python and available on pip. To reproduce the llvm testing experience we also need filecheck [2] which is written in C++. I'm not sure if it is worth the effort or if it is used outside of llvm.
Other solutions to the problem I found are [0] (written in Haskell) [1]. Any thoughts on the issue? I'll port the tests to js for now, otherwise I won't get anything done today =P

@kasbah
Copy link
Member

kasbah commented Jan 23, 2018

We should definitely find a way to avoid repeating the test cases everywhere.

On the replicad Babeljs transform I started using testing tool that let me just write input and expected output examples as files. The runner is specific to Babeljs but we could follow this pattern and start making a fixtures directory with input.txt and expected.json files. The actual test runner in each language could then be quite simple, so maybe we wouldn't need an extra test framework.

Otherwise I am always partial to Haskell solutions but a bit wary of managing a Haskell dependency. I'd want to be sure it's worth it. LLVM-lit looks good too but if we need to pull in an extra CPP file and compile it it might not be the right solution (but maybe it compiles easily and it's worth it, not sure yet).

@dvc94ch dvc94ch changed the title Use llvm-lit for test cases Use toml for test cases Jan 24, 2018
@kasbah
Copy link
Member

kasbah commented Jan 24, 2018

package = '0805'
'package.width' = 10

Isn't there a better way to do nesting in TOML? https://github.com/toml-lang/toml#array-of-tables

@dvc94ch
Copy link
Collaborator Author

dvc94ch commented Jan 24, 2018

this wouldn't be nice:

[10k +-10%]
['10k +-10%'.result]
type = 'resistor'
tolerance = 10

we can go with

[[test]]
input = '10k +-10%'
[test.result]
type = 'resistor'
tolerance = 10

@kasbah
Copy link
Member

kasbah commented Jan 24, 2018

I would suggest aligning with #9

[test-suite]
parser = 'strict'
rule = 'all_packages'
describe = 'chip packages'

[[test]]
it = 'parses 0805'

[test.cases]
metric = '0805'
imperial = '2012'

[test.output]
warnings = ["ambigous_size"]
ignored = ''

[test.output.result]
package = '0805'

This repl type thing is handy for sketching btw.

@kasbah kasbah added the antlr-port Issues only applicable to our attempt to port to antlr label Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
antlr-port Issues only applicable to our attempt to port to antlr
Projects
None yet
Development

No branches or pull requests

2 participants