Skip to content

Syntactic tests #19

Open
Open
@justinmchase

Description

@justinmchase

The language should support a syntactic method for writing tests in the same file as the patterns. I'm not totally sure how this should be, will require some research.

Initial thoughts:

  • use --- to separate code from tests, multiple --- indicates multiple tests
  • test blocks are just object property declarations, where the properties are the shape of a test object
  • or maybe its just yaml?
  • The test just runs the pattern with the given input, deep equals it to the expected output
  • The test object may have some other fields to describe expectations like:
    • throws?: boolean | Pattern
    • matched?: boolean
    • done?: boolean
    • errors?: MachError[]
Letter = "a"-"z"
Main = Letter+
---
input: abc
expected: abc
---
input: abc1
expected: abc
matched: true
done: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions