-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tmain: add cases for testing parser specific fields with data types d…
…efined in optlib Signed-off-by: Masatake YAMATO <[email protected]>
- Loading branch information
Showing
13 changed files
with
228 additions
and
6 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
Tmain/parser-own-fields-for-foreign-lang-in-json.d/stdout-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# output: json | ||
{"_type": "tag", "name": "foo", "path": "input.unknownx", "pattern": "/^public func foo(n, m);$/", "language": "unknownx", "kind": "func", "protection": "public ", "signature": "(n, m)"} | ||
{"_type": "tag", "name": "bar", "path": "input.unknownx", "pattern": "/^protected func bar(n);$/", "language": "unknownx", "kind": "func", "protection": "protected ", "signature": "(n)"} | ||
{"_type": "tag", "name": "baz", "path": "input.unknownx", "pattern": "/^private func baz(n,...);$/", "language": "unknownx", "kind": "func", "protection": "private ", "signature": "(n,...)"} | ||
{"_type": "tag", "name": "strset", "path": "input.unknownx", "pattern": "/^STR:strset@iamowner$/", "language": "knownz", "kind": "mark", "owner": "iamowner"} | ||
{"_type": "tag", "name": "setsetempty", "path": "input.unknownx", "pattern": "/^STR:setsetempty@$/", "language": "knownz", "kind": "mark", "owner": ""} | ||
{"_type": "tag", "name": "notset", "path": "input.unknownx", "pattern": "/^STR:notset$/", "language": "knownz", "kind": "mark"} | ||
{"_type": "tag", "name": "tagme2", "path": "input.unknownx", "pattern": "/^Y:iamowner2=tagme2$/", "language": "knownz", "kind": "mark", "owner": "iamowner2"} | ||
{"_type": "tag", "name": "tagme-z", "path": "input.unknownx", "pattern": "/^Z:tagme-z@iamowner-z$/", "language": "knownz", "kind": "mark", "owner": "iamowner-z", "len": 10, "lenplus": 11} | ||
{"_type": "tag", "name": "a", "path": "input.unknownx", "pattern": "/^eset:a$/", "language": "knownz", "kind": "mark", "exported": true} | ||
{"_type": "tag", "name": "b", "path": "input.unknownx", "pattern": "/^enoset:b$/", "language": "knownz", "kind": "mark"} | ||
{"_type": "tag", "name": "9_exported", "path": "input.unknownx", "pattern": "/^enoset:b$/", "language": "knownz", "kind": "mark"} |
10 changes: 10 additions & 0 deletions
10
Tmain/parser-specific-fields-for-foreign-lang-in-json.d/input.unknownx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
public func foo(n, m); | ||
protected func bar(n); | ||
private func baz(n,...); | ||
STR:strset@iamowner | ||
STR:setsetempty@ | ||
STR:notset | ||
Y:iamowner2=tagme2 | ||
Z:tagme-z@iamowner-z | ||
eset:a | ||
enoset:b |
12 changes: 12 additions & 0 deletions
12
Tmain/parser-specific-fields-for-foreign-lang-in-json.d/knownz.ctags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--langdef=knownz | ||
--kinddef-knownz=m,mark,makers | ||
|
||
--_fielddef-knownz=owner,the owner of the markers{datatype=str} | ||
|
||
--_fielddef-knownz=len,the length of owner string{datatype=int} | ||
--fields-knownz=+{len} | ||
--_fielddef-knownz=lenplus,the length of owner string + 1{datatype=int} | ||
--fields-knownz=+{lenplus} | ||
|
||
--_fielddef-knownz=exported,whether the marker is exported or not{datatype=bool} | ||
--fields-knownz=+{exported} |
19 changes: 19 additions & 0 deletions
19
Tmain/parser-specific-fields-for-foreign-lang-in-json.d/run.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright: 2025 Masatake YAMATO | ||
# License: GPL-2 | ||
|
||
. ../utils.sh | ||
|
||
CTAGS=$1 | ||
|
||
V= | ||
# V=valgrind | ||
|
||
is_feature_available "${CTAGS}" json | ||
|
||
echo "# output: json" | ||
${V} ${CTAGS} --options=NONE --options=./knownz.ctags --sort=no --options=./unknownx.ctags \ | ||
--fields=+l \ | ||
--fields-unknownx=+'{protection}{signature}' \ | ||
--fields-knownz=+'{owner}' \ | ||
--output-format=json \ | ||
-o - input.unknownx |
1 change: 1 addition & 0 deletions
1
Tmain/parser-specific-fields-for-foreign-lang-in-json.d/stderr-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ctags: Notice: No options will be read from files or environment |
12 changes: 12 additions & 0 deletions
12
Tmain/parser-specific-fields-for-foreign-lang-in-json.d/stdout-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# output: json | ||
{"_type": "tag", "name": "foo", "path": "input.unknownx", "pattern": "/^public func foo(n, m);$/", "language": "unknownx", "kind": "func", "protection": "public ", "signature": "(n, m)"} | ||
{"_type": "tag", "name": "bar", "path": "input.unknownx", "pattern": "/^protected func bar(n);$/", "language": "unknownx", "kind": "func", "protection": "protected ", "signature": "(n)"} | ||
{"_type": "tag", "name": "baz", "path": "input.unknownx", "pattern": "/^private func baz(n,...);$/", "language": "unknownx", "kind": "func", "protection": "private ", "signature": "(n,...)"} | ||
{"_type": "tag", "name": "strset", "path": "input.unknownx", "pattern": "/^STR:strset@iamowner$/", "language": "knownz", "kind": "mark", "owner": "iamowner"} | ||
{"_type": "tag", "name": "setsetempty", "path": "input.unknownx", "pattern": "/^STR:setsetempty@$/", "language": "knownz", "kind": "mark", "owner": ""} | ||
{"_type": "tag", "name": "notset", "path": "input.unknownx", "pattern": "/^STR:notset$/", "language": "knownz", "kind": "mark"} | ||
{"_type": "tag", "name": "tagme2", "path": "input.unknownx", "pattern": "/^Y:iamowner2=tagme2$/", "language": "knownz", "kind": "mark", "owner": "iamowner2"} | ||
{"_type": "tag", "name": "tagme-z", "path": "input.unknownx", "pattern": "/^Z:tagme-z@iamowner-z$/", "language": "knownz", "kind": "mark", "owner": "iamowner-z", "len": 10, "lenplus": 11} | ||
{"_type": "tag", "name": "a", "path": "input.unknownx", "pattern": "/^eset:a$/", "language": "knownz", "kind": "mark", "exported": true} | ||
{"_type": "tag", "name": "b", "path": "input.unknownx", "pattern": "/^enoset:b$/", "language": "knownz", "kind": "mark"} | ||
{"_type": "tag", "name": "9_exported", "path": "input.unknownx", "pattern": "/^enoset:b$/", "language": "knownz", "kind": "mark"} |
41 changes: 41 additions & 0 deletions
41
Tmain/parser-specific-fields-for-foreign-lang-in-json.d/unknownx.ctags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--langdef=unknownx{_foreignLanguage=knownz} | ||
--kinddef-unknownx=f,func,functions | ||
--map-unknownx=+.unknownx | ||
|
||
--_fielddef-unknownx=protection,protections | ||
--_fielddef-unknownx=signature,signatures | ||
|
||
--_prelude-unknownx={{ | ||
/exported false def | ||
}} | ||
|
||
--regex-unknownx=/^((public|protected|private) +)?func ([^\(]+)\((.*)\)/\3/f/{_field=protection:\1}{_field=signature:(\4)} | ||
--regex-unknownx=/^STR:([a-z]+)@([a-z]+)/\1/m/{_language=knownz}{_field=owner:\2} | ||
--regex-unknownx=/^STR:([a-z]+)@$/\1/m/{_language=knownz}{_field=owner:} | ||
--regex-unknownx=/^STR:([a-z]+)$/\1/m/{_language=knownz} | ||
--regex-unknownx=/^Y:([a-z0-9]+)=([a-z0-9]+)/\2/m/{_field=owner:\1}{_language=knownz} | ||
--regex-unknownx=/^Z:([-a-z]+)@([-a-z]+)/\1/m/{_language=knownz}{{ | ||
. \2 knownz.owner: | ||
. :knownz.owner { | ||
. exch length knownz.len: | ||
} if | ||
. :knownz.len { | ||
1 add | ||
. exch knownz.lenplus: | ||
} if | ||
}} | ||
|
||
--regex-unknownx=/^eset:([-a-z]+)/\1/m/{_language=knownz}{{ | ||
/exported . def | ||
. true knownz.exported: | ||
}} | ||
|
||
--regex-unknownx=/^enoset:([-a-z]+)/\1/m/{_language=knownz}{{ | ||
. false knownz.exported: | ||
exported :knownz.exported and { | ||
mark exported 0 string cvs (_exported) _buildstring | ||
/knownz | ||
/mark | ||
1@ _foreigntag _commit pop | ||
} if | ||
}} |
13 changes: 12 additions & 1 deletion
13
Tmain/parser-specific-fields-for-foreign-lang.d/input.unknownx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
public func foo(n, m); | ||
protected func bar(n); | ||
private func baz(n,...); | ||
X:tagme@iamowner | ||
STR:strset@iamowner | ||
STR:setsetempty@ | ||
STR:notset | ||
Y:iamowner2=tagme2 | ||
Z:tagme-z@iamowner-z | ||
eset:a | ||
enoset:b | ||
|
||
stb:o | ||
stb:p- | ||
stb:q.something string | ||
x0:O | ||
x1:P |
13 changes: 12 additions & 1 deletion
13
Tmain/parser-specific-fields-for-foreign-lang.d/knownz.ctags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
--langdef=knownz | ||
--kinddef-knownz=m,mark,makers | ||
|
||
--_fielddef-knownz=owner,the owner of the markers | ||
--_fielddef-knownz=owner,the owner of the markers{datatype=str} | ||
|
||
--_fielddef-knownz=len,the length of owner string{datatype=int} | ||
--fields-knownz=+{len} | ||
--_fielddef-knownz=lenplus,the length of owner string + 1{datatype=int} | ||
--fields-knownz=+{lenplus} | ||
|
||
--_fielddef-knownz=exported,whether the marker is exported or not{datatype=bool} | ||
--fields-knownz=+{exported} | ||
|
||
--_fielddef-knownz=stb,string or false{datatype=str+bool} | ||
--fields-knownz=+{stb} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Tmain/parser-specific-fields-for-foreign-lang.d/stderr-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ctags: Notice: No options will be read from files or environment | ||
ctags: Notice: No options will be read from files or environment |
23 changes: 21 additions & 2 deletions
23
Tmain/parser-specific-fields-for-foreign-lang.d/stdout-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
# output: tags | ||
foo input.unknownx /^public func foo(n, m);$/;" f language:unknownx protection:public signature:(n, m) | ||
bar input.unknownx /^protected func bar(n);$/;" f language:unknownx protection:protected signature:(n) | ||
baz input.unknownx /^private func baz(n,...);$/;" f language:unknownx protection:private signature:(n,...) | ||
foo input.unknownx /^public func foo(n, m);$/;" f language:unknownx protection:public signature:(n, m) | ||
tagme input.unknownx /^X:tagme@iamowner$/;" m language:knownz owner:iamowner | ||
strset input.unknownx /^STR:strset@iamowner$/;" m language:knownz owner:iamowner | ||
setsetempty input.unknownx /^STR:setsetempty@$/;" m language:knownz owner: | ||
notset input.unknownx /^STR:notset$/;" m language:knownz | ||
tagme2 input.unknownx /^Y:iamowner2=tagme2$/;" m language:knownz owner:iamowner2 | ||
tagme-z input.unknownx /^Z:tagme-z@iamowner-z$/;" m language:knownz owner:iamowner-z len:10 lenplus:11 | ||
a input.unknownx /^eset:a$/;" m language:knownz exported: | ||
b input.unknownx /^enoset:b$/;" m language:knownz | ||
9_exported input.unknownx /^enoset:b$/;" m language:knownz | ||
# output: xref | ||
foo unknownx / owner:,len:,lenplus:,exported:- / public (n, m) | ||
bar unknownx / owner:,len:,lenplus:,exported:- / protected (n) | ||
baz unknownx / owner:,len:,lenplus:,exported:- / private (n,...) | ||
strset knownz / owner:iamowner,len:,lenplus:,exported:- / | ||
setsetempty knownz / owner:,len:,lenplus:,exported:- / | ||
notset knownz / owner:,len:,lenplus:,exported:- / | ||
tagme2 knownz / owner:iamowner2,len:,lenplus:,exported:- / | ||
tagme-z knownz / owner:iamowner-z,len:10,lenplus:11,exported:- / | ||
a knownz / owner:,len:,lenplus:,exported:exported / | ||
b knownz / owner:,len:,lenplus:,exported:- / | ||
9_exported knownz / owner:,len:,lenplus:,exported:- / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters