-
Notifications
You must be signed in to change notification settings - Fork 2
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
Language-agnostic tests #10
Comments
For JS we can use |
I shall have a tinker over the weekend. |
Dynamic invocation can be performed in c#- here's the proof-of-concept. It's only proof-of-concept because DynamicInvocationTestCases() features a hard-coded version of the getRegex.json example- I had tinkered with adding a nuget package, but couldn't figure out the syntax to get the files to be copied to the build directory so one can parse them with something like Newtonsoft's JSON parser, hence skipping to the proof-of-concept. |
Dynamic invocation isn't possible in Elm, and I'm sure this is true of some of the other strongly-typed languages as well. I'm wondering, would a standard JSON format for verbal expressions operations be a good step forward in creating a cross-language test suite? This could be used in conjunction with additional JSON data for expected results to create a repeatable test suite that each language can deal with just in the way it deals with parsing JSON in general. |
Re: elm, we could perhaps compile JSON definitions to elm tests ? |
This is definitely also possible, I know some others in the community have experimented with building tools for bridging JSON and Elm type definitions and decoders. I'll reach out to some folks and report back with what I find out! |
Also having a browse through the docs, could the test suite be run with qunit & Elm worker ? |
Have just implemented a proof-of-concept for JSVerbalExpressions that parses the tests JSON & generates an abstract syntax tree to run the tests; I'm wondering how many of the other implementation languages have libraries that support creating scripts from ASTs ? |
I've just implemented a working AST-based test generator for PHPVerbalExpressions- see output in files suffixed with "DynamicallyGeneratedTest.php" |
Further experiments in the matter of generating tests; swap out a use statement in PHP to get a json-serializable representation of the call stack on an instance of VerbalExpressions: TraceverbalExpressions |
Would I be alone in thinking that having a unified, language-agnostic test suite would be beneficial?
I've recently been thinking over the issue of unit tests for the different implementations (mostly just the PHP & JS ones as you might guess). A quick google suggested that language-agnostic test suites are few & far between. So I rolled my own :P
It struck me that one would need to define a series of tests for VerbalExpressions that can be read in as many languages as possible. Parsing XML isn't exactly straight-forward in PHP or JS, so I went with JSON.
So with the test suites being defined in JSON, it would seem like a good idea to ensure that the test suites were well-defined (so each implementation would know what to expect of the structure of the files). For this we have JSON Schema and a grunt task I cooked up last night (this issue would've been posted last night, but unicorns got in the way). This allows test definers to be confident that when a new version goes out there should only be issues with implementations when the test schema changes (i.e. if
grunt jsonschema
fails, don't push it).The basic schema I've implemented in the proof-of-concept examples allows for:
Thoughts/comments/suggestions?
The text was updated successfully, but these errors were encountered: