Skip to content

Commit

Permalink
chore: rearrange testcases + mark real-world scripts as new testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-semenov committed May 8, 2024
1 parent 13bc339 commit 336ee8c
Show file tree
Hide file tree
Showing 10 changed files with 558 additions and 359 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ $(BUILD_DIR)parigp.tmLanguage: $(BUILD_DIR)parigp.JSON-tmLanguage
$(J2_RENDERS): $(BUILD_DIR)gp_builtins.json
@cat $< | jinja2 --format=yaml $@.j2 > $@

TEST_CASES := $(shell find $(ROOT_DIR)tests/ -name '*.test.gp*')

.PHONY: test
test: ## Test the Textmate grammar for PARI/GP.
test: $(BUILD_DIR)parigp.tmLanguage.json
@vscode-tmgrammar-test \
--grammar $(BUILD_DIR)parigp.tmLanguage.json \
$(ROOT_DIR)tests/*.gp
$(TEST_CASES)

$(BUILD_DIR)gp_commands.tsv:
$(eval FUNCS := $(shell echo '\c' | gp -fq | grep -v 'RETURN'))
Expand Down Expand Up @@ -116,7 +118,7 @@ $(ROOT_DIR)images/coverage-badge.svg:
'[.. | select(has("name") and .name != "PARI/GP") | .name] | @tsv' \
$(ROOT_DIR)src/*.YAML-tmLanguage* |\
xargs -n1 | sort | uniq))
$(eval SCOPES_UNDER_TEST := $(shell tail -n+2 $(ROOT_DIR)tests/*.test.gp |\
$(eval SCOPES_UNDER_TEST := $(shell tail -n+2 $(TEST_CASES) |\
grep -o 'source.parigp.*$$' |\
xargs -n1 | sort | uniq | grep -v source.parigp))
$(eval DIFF := $(shell echo $(REFS) $(SCOPES_UNDER_TEST) | tr ' ' '\n' | sort | uniq -u | xargs -n1))
Expand Down
10 changes: 7 additions & 3 deletions src/functions.YAML-tmLanguage.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ repository:
builtins:
patterns:
-
match: '\b({{ scopes["entity.name.function"] | join("|") }})\b\s*(?={|\()'
match: '\b({{ scopes["entity.name.function"] | join("|") }})\b(\s*)(?={|\()'
captures:
1:
name: entity.name.function.builtins.parigp
2:
name: constant.character.whitespace.parigp
-
match: '\b({{ scopes["constant.language"] | join("|") }})'
captures:
Expand Down Expand Up @@ -66,12 +68,14 @@ repository:
- include: '#general'
- include: '#operators'
-
begin: '\.([[:alpha:]][[:alnum:]_]*)\b(?=[^=]*=)'
begin: '(\.)([[:alpha:]][[:alnum:]_]*)\b(?=[^=]*=)'
end: '(?<=\s*\=)'
beginCaptures:
1:
name: markup.punctuation.member.parigp
2:
name: entity.name.function.user.member.parigp
name: meta.function.user.member.parigp
name: meta.function.member.parigp
patterns:
- include: '#general'
- include: '#operators'
Expand Down
2 changes: 1 addition & 1 deletion src/operators.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repository:
match: '(<<|>>)'
name: keyword.operator.shift.parigp
-
match: '(<=|>=|<|(?<!\-)>|!=)'
match: '(<=|>=|<|(?<!\-)>|!=|==)'
name: keyword.operator.comparison.parigp
-
match: '(\->)'
Expand Down
337 changes: 133 additions & 204 deletions tests/functions.test.gp

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions tests/operators.test.gp
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,19 @@
## ^^ source.parigp meta.brackets.parigp variable.name.parigp
## ^ source.parigp meta.brackets.parigp punctuation.section.brackets.end.parigp
## ^ source.parigp keyword.operator.derivative.parigp

x = 1; x *= 10;
##^ ^ source.parigp variable.name.parigp
## ^ ^ ^ ^ ^ source.parigp constant.character.whitespace.parigp
## ^ source.parigp keyword.operator.assignment.parigp
## ^^ source.parigp keyword.operator.arithmetic.assignment.parigp
## ^ ^^ source.parigp constant.numeric.int.parigp
## ^ ^ source.parigp markup.punctuation.statement-terminator.parigp

y = x >> 2;
##^ ^ source.parigp variable.name.parigp
## ^ ^ ^ ^ source.parigp constant.character.whitespace.parigp
## ^ source.parigp keyword.operator.assignment.parigp
## ^^ source.parigp keyword.operator.shift.parigp
## ^ source.parigp constant.numeric.int.parigp
## ^ source.parigp markup.punctuation.statement-terminator.parigp
149 changes: 0 additions & 149 deletions tests/other.test.gp

This file was deleted.

Loading

0 comments on commit 336ee8c

Please sign in to comment.