Skip to content

Commit

Permalink
fix: improve coverage + resolve bad rules ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-semenov committed May 3, 2024
1 parent 05696de commit a881344
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ $(ROOT_DIR)images/coverage-badge.svg:
xargs -n1 | sort | uniq))
$(eval SCOPES_UNDER_TEST := $(shell tail -n+2 $(ROOT_DIR)tests/*.test.gp |\
grep -o 'source.parigp.*$$' |\
xargs -n1 | sort | uniq))
xargs -n1 | sort | uniq | grep -v source.parigp))
$(eval DIFF := $(shell echo $(REFS) $(SCOPES_UNDER_TEST) | tr ' ' '\n' | sort | uniq -u | xargs -n1))
@$(info $(DIFF))
$(eval COVERAGE := $(shell echo "scale=4 ; 100.0 * (1.0 - $(shell echo $(DIFF) | wc -w) / $(shell echo $(REFS) | wc -w))" | bc))
@xsltproc --param coverage $(COVERAGE) \
--output $@ \
Expand Down
5 changes: 4 additions & 1 deletion src/functions.YAML-tmLanguage.j2
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ repository:
beginCaptures:
1:
name: entity.name.function.user.member.parigp
name: meta.function.member.parigp
name: meta.function.user.member.parigp
patterns:
- include: '#general'
- include: '#operators'
repository:
function-vars:
patterns:
Expand Down
12 changes: 6 additions & 6 deletions src/operators.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ repository:
-
match: '(?<!&)(&)'
name: keyword.operator.pointer.parigp
-
match: '(<<|>>)'
name: keyword.operator.shift.parigp
-
match: '(<=|>=|<|(?<!\-)>|!=)'
name: keyword.operator.comparison.parigp
Expand All @@ -22,18 +25,15 @@ repository:
-
match: '(=)'
name: keyword.operator.assignment.parigp
-
match: '(<<|>>)'
name: keyword.operator.shift.parigp
-
match: '(\-\-|\+\+)'
name: keyword.operator.increment-decrement.parigp
-
match: '(\-|\+|\*|\/|\\|\\/|%)'
name: keyword.operator.arithmetic.parigp
-
match: '(\+=|\-=|\*=|\/=|\\=|<<=|>>=)'
name: keyword.operator.arithmetic.assign.parigp
-
match: '(\-|\+|\*|\/|\\|\\/|%)'
name: keyword.operator.arithmetic.parigp
-
match: '(\.\.)'
name: keyword.operator.range.parigp
Expand Down
21 changes: 17 additions & 4 deletions tests/functions.test.gp
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
## SYNTAX TEST "source.parigp" "Functions"

-oo
##^ source.parigp keyword.operator.arithmetic.parigp
## ^^ source.parigp constant.language.parigp

x = Euler() * I
##^ source.parigp variable.name.parigp
## ^ ^ source.parigp constant.character.whitespace.parigp
## ^ source.parigp keyword.operator.assignment.parigp
## ^^^^^ ^ source.parigp constant.language.parigp
## ^ ^ source.parigp constant.character.whitespace.parigp
## ^ source.parigp keyword.operator.arithmetic.parigp

Col([])
##^^^ source.parigp entity.name.function.builtins.parigp
## ^ source.parigp meta.parens.parigp punctuation.section.parens.begin.parigp
Expand Down Expand Up @@ -315,11 +327,12 @@

\\ Code from pages 39-40 of "User's Guide to PARI/GP"
##^^ source.parigp punctuation.definition.comment.parigp comment.line.double-slash.parigp
x.j = {
x.r = {
##^ source.parigp variable.name.parigp
## ^ source.parigp entity.name.function.member.builtins.parigp
## ^ ^ source.parigp constant.character.whitespace.parigp
## ^ source.parigp keyword.operator.assignment.parigp
## ^ source.parigp entity.name.function.user.member.parigp
## ^ source.parigp meta.function.user.member.parigp constant.character.whitespace.parigp
## ^ source.parigp meta.function.user.member.parigp keyword.operator.assignment.parigp
## ^ source.parigp constant.character.whitespace.parigp
## ^ source.parigp meta.block.parigp punctuation.section.group.begin.parigp
if (type(x) != "t_VEC" || length(x) < 14,
## ^^ source.parigp meta.block.parigp entity.name.function.builtins.parigp
Expand Down
16 changes: 16 additions & 0 deletions tests/other.test.gp
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,19 @@
##^^ source.parigp support.function.parigp
## ^ source.parigp constant.character.whitespace.parigp
## ^^^^^^^^^^^^ source.parigp constant.character.escape.parigp

x = 1;
x *= 10;
##^ source.parigp variable.name.parigp
## ^ ^ source.parigp constant.character.whitespace.parigp
## ^^ source.parigp keyword.operator.arithmetic.assign.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

0 comments on commit a881344

Please sign in to comment.