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

feat(ast-spec): add fixture test framework and some initial fixtures #3258

Merged
merged 1 commit into from Apr 25, 2022

Commits on Apr 25, 2022

  1. feat(ast-spec): add fixtures

    Add fixture tests for each and every AST node.
    To make things more readable I:
    - separated the AST from the tokens
      - this stops the individual snapshot from being so long it's impossible to understand
      - if there are changes to tokens - then they should be more obvious now. Before you had to expand the snapshot in github to understand that the token was part of the tokens array.
    - always write error snapshot, and always write AST/token snapshots
      - This is just for consistency and to make it easier whilst you're developing.
      - It will prevent us from accidentally leaving behind error snapshots if they weren't supposed to be there.
    - added a custom snapshot serializer
      - Having learned how useful they are with scope manager - I created a new one to improve the look of the snapshots.
      - Instead of sorting alphabetically, I place `type` at the top, and `range`/`loc` at the end.
      - Instead of outputting `Object` ahead of every node, instead it outputs the node `type`.
      - I adjusted the output `range`/`loc` so they take up fewer lines and are more compact.
    
    I prefixed the snapshot names with numbers just so we can control the sorting of them. No other reason.
    bradzacher committed Apr 25, 2022
    Copy the full SHA
    fb13fb5 View commit details
    Browse the repository at this point in the history