Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add some basic specs for the grammar #40

Merged
merged 1 commit into from
Mar 30, 2016
Merged

Conversation

bytebutt
Copy link
Contributor

@bytebutt bytebutt commented Mar 6, 2016

I wrote some basic specs to serve as a sanity check for any grammar tweaks. All of these specs pass against the current version of the grammar. (Note that this pull request does not include specs for #39. My intention is to add specs for #39 on top of these baseline specs.)

I've actually never written CoffeeScript before and just relied on the example specs mentioned in #38 as reference. If anything looks wrong or improper let me know and I can make the necessary changes.

@winstliu
Copy link
Contributor

winstliu commented Mar 6, 2016

The value and scope checks can be combined into a single line like so:
expect(tokens[x]).toEqual value: "whatever", scopes: ["scopes"]

For tests that involve quotes, you can switch the containing quotes so that you don't need to escape anything. For example: grammar.tokenizeLine '"foo bar"'.

@bytebutt
Copy link
Contributor Author

bytebutt commented Mar 7, 2016

I've updated my branch to incorporate your suggestions. It's definitely more readable now. If there's any other adjustments you'd like I'd be happy to make them.

@bytebutt
Copy link
Contributor Author

I've rebased my branch onto the current master.

{tokens} = grammar.tokenizeLine " \n"
expect(tokens[0]).toEqual value: " \n", scopes: ["source.clojure", "invalid.trailing-whitespace"]

# TODO: Test 'after' tokens?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something you want to finish in this PR?

@bytebutt
Copy link
Contributor Author

Ah, yeah. I wasn't sure if it was worth testing the trailing whitespace tokens since they didn't necessarily have the same scopes across the different meta groups (and therefore didn't fit well into my generic function).

I'll leave it up to you whether I should (1) delete the todo and not worry about the after tokens, (2) add some testing of the tokens, or (3) do something else. Let me know and I can make the change.

@winstliu
Copy link
Contributor

Sorry for the delay in replying. Some specs are better than no specs, so let's remove the TODO for now and return to it later if necessary.

@bytebutt
Copy link
Contributor Author

No worries! I've removed the TODO and squashed my commits.

@winstliu winstliu merged commit bf4ad48 into atom:master Mar 30, 2016
@winstliu
Copy link
Contributor

Thanks for this!

Slowki pushed a commit to Slowki/hy.tmLanguage that referenced this pull request Sep 14, 2018
Add some basic specs for the grammar
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants