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

Create test framework for grammar rules #2249

Closed
vinistock opened this issue Jul 3, 2024 · 3 comments
Closed

Create test framework for grammar rules #2249

vinistock opened this issue Jul 3, 2024 · 3 comments
Labels
chore Chore task pinned This issue or pull request is pinned and won't be marked as stale vscode This pull request should be included in the VS Code extension's release notes

Comments

@vinistock
Copy link
Member

Currently, there are no tests for our grammar files. Not having tests is always bad, but it's especially worse for this case since the Ruby grammar file is immense and filled with complex regexes that try to understand Ruby's ambiguous syntax.

Let's try to design a little test framework that allows us to assert the token types for a string of Ruby code. The framework should apply the grammar rules on the given source string and then somehow allow us to assert the tokens based on positions.

Something like this:

test("Class declaration tokens", () => {
  const tokenTypes = applyGrammar("class Foo < Bar; end");
  assert.strictEqual(tokenTypes[0].type, "keyword");
  assert.strictEqual(tokenTypes[1].type, "class.declaration");
});
@vinistock vinistock added chore Chore task pinned This issue or pull request is pinned and won't be marked as stale vscode This pull request should be included in the VS Code extension's release notes labels Jul 3, 2024
@borama
Copy link

borama commented Jul 13, 2024

FWIW, I like the https://github.com/PanAeon/vscode-tmgrammar-test approach and I've had great success with building a test suite for my VS Code Slim extension using it. I may even try to start building some tests if there is interest.

@andyw8
Copy link
Contributor

andyw8 commented Aug 27, 2024

I hadn't realised the extension already has something for testing grammar rules:

#2493

@vinistock
Copy link
Member Author

Indeed, I forgot we already have a setup for testing grammar rules. I'll close this issue then.

@vinistock vinistock closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Chore task pinned This issue or pull request is pinned and won't be marked as stale vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

No branches or pull requests

3 participants