Skip to content

Commit 15950c3

Browse files
test(grammar): pin C# 14 extension block members in the regression net
Carry the csharp_extension_declaration case from DeusData#2218 into the per-language grammar regression table: the DeusData#2071 snippet must yield NumberExtensions and SumPositive, so a future refresh of tree-sitter-c-sharp cannot silently drop extension block members again. The label golden table needs a row for every regression case, so the matching golden row from DeusData#2218 comes with it. The expression-bodied member is wrapped across two lines. Co-authored-by: lorenzozanee <wyz0707@proton.me> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 6d7cd64 commit 15950c3

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎tests/test_grammar_labels.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static const LabelGolden LABEL_GOLDENS[] = {
9393
{"ruby", "Class:1,Function:1,Module:1"},
9494
{"php", "Class:1,Function:1,Module:1"},
9595
{"c_sharp", "Class:1,Method:1,Module:1"},
96+
{"csharp_extension_declaration", "Class:1,Method:1,Module:1"},
9697
{"bash", "Function:2,Module:1"},
9798
{"zsh", "Function:2,Module:1"},
9899
{"lua", "Function:2,Module:1"},

‎tests/test_grammar_regression.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ const GrammarCase CBM_GRAMMAR_CASES[] = {
8181
"class A {\n void Foo() {}\n}\n",
8282
2,
8383
{"A", "Foo", NULL}},
84+
{"csharp_extension_declaration",
85+
CBM_LANG_CSHARP,
86+
"Extensions.cs",
87+
"using System.Collections.Generic;\n"
88+
"using System.Linq;\n"
89+
"public static class NumberExtensions\n"
90+
"{\n"
91+
" extension(IEnumerable<int> numbers)\n"
92+
" {\n"
93+
" public int SumPositive() =>\n"
94+
" numbers.Where(n => n > 0).Aggregate(0, static (total, n) => total + n);\n"
95+
" }\n"
96+
"}\n",
97+
2,
98+
{"NumberExtensions", "SumPositive", NULL}},
8499
{"bash",
85100
CBM_LANG_BASH,
86101
"a.sh",

0 commit comments

Comments
 (0)