Skip to content

Language-agnostic tests #10

@SignpostMarv

Description

@SignpostMarv

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:

  • multiple tests per file (no restrictions on file names beyond any silliness that would prevent an implementation from parsing it)
  • abstract call stacks & arguments (only a single call stack for all languages)
  • default expected output + language-specific outputs (if for whatever reason an implementation needs to generate different regex strings to be most performant whilst doing the same job)

Thoughts/comments/suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions