PanAeon / vscode-tmgrammar-test

Test helpers for VSCode textmate grammars

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow multiple negations in a test case

radeksimko opened this issue · comments

Version: 0.0.10

{
	"scopeName": "source.terraform",
	"name": "Terraform",
	"patterns": [
		{
			"include": "#comments"
		}
	],
	"repository": {
		"comments": {
			"begin": "#|//",
			"comment": "Inline Comments",
			"name": "comment.line.terraform",
			"captures": {
				"0": {
					"name": "punctuation.definition.comment.terraform"
				}
			},
			"end": "$\\n?"
		}
	}
}

1 negation per line

# SYNTAX TEST "source.terraform"

   # foo
# ^ -comment
# ^ -punctuation
#  ^ punctuation.definition.comment.terraform
#  ^^^^^ comment.line.terraform
> vscode-tmgrammar-test -s source.terraform -g ./terraform.tmLanguage.json -t "**/*.tf"

✓ test_terraform.tf run successfuly.

2 negations per line

# SYNTAX TEST "source.terraform"

   # foo
# ^ -comment -punctuation
#  ^ punctuation.definition.comment.terraform
#  ^^^^^ comment.line.terraform
> vscode-tmgrammar-test -s source.terraform -g ./terraform.tmLanguage.json -t "**/*.tf"

ERROR can't parse testcase: test_terraform.tf
Error: Inalid assertion at line 3:
# ^ -comment -punctuation

    at parseScopeAssertion (.../node_modules/vscode-tmgrammar-test/dist/src/unit/parsing.js:43:19)
    at .../node_modules/vscode-tmgrammar-test/dist/src/unit/parsing.js:119:22
    at Array.forEach (<anonymous>)
    at Object.parseGrammarTestCase (.../node_modules/vscode-tmgrammar-test/dist/src/unit/parsing.js:107:10)
    at .../node_modules/vscode-tmgrammar-test/dist/src/unit.js:142:26
    at Array.map (<anonymous>)
    at .../node_modules/vscode-tmgrammar-test/dist/src/unit.js:139:41
    at f (.../node_modules/once/once.js:25:25)
    at Glob.<anonymous> (.../node_modules/glob/glob.js:151:7)
    at Glob.emit (events.js:315:20)
npm ERR! Test failed.  See above for more details.

Sorry for not responding for so long, must have completely misunderstand this ticket.
Multiple negations are supported on a single line:

# SYNTAX TEST "source.terraform"

  # foo
# ^ source.terraform - comment.line.terraform punctuation.definition.comment.terraform
# ^^^ source.terraform comment.line.terraform

Result:

> vscode-tmgrammar-test -g terraform.tmLanguage.json test.tf
✖ test.tf failed
  at [test.tf:3:3:4]:
  3:   # foo
       ^
  prohibited scopes: comment.line.terraform punctuation.definition.comment.terraform
  actual: source.terraform comment.line.terraform punctuation.definition.comment.terraform

I think there was a mistake in the README.md which lead to confusion

Yep - that worked, and shorter scopes also work as I just verified.

# SYNTAX TEST "source.terraform"

   # foo
# ^ - comment punctuation
#  ^ punctuation.definition.comment.terraform
#  ^^^^^ comment.line.terraform

Thank you!