Skip to content

Commit c0e3f28

Browse files
antonsyndclaude
andcommitted
fix(core): fix test compilation and enable disabled test suites
- Fix StringExtensionsAdditionalTests: call StringExtensions.Split/Replace explicitly to avoid C# built-in method resolution priority - Enable ItertoolsAdditionalTests (remove #if guard) - Enable OsModuleTests (remove #if guard) - Add InternalsVisibleTo for Sharpy.Core.Tests in Sharpy.Core.csproj - Fix OsModuleTests Walk test tuple element names - Fix OverloadIndexBuilderTypeTests to allow ValueError as exception base type - Apply dotnet format whitespace Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c73e145 commit c0e3f28

8 files changed

Lines changed: 77 additions & 52 deletions

File tree

src/Sharpy.Compiler.Tests/Discovery/Caching/OverloadIndexBuilderTypeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void DiscoverPublicTypes_ExceptionTypes_HaveCorrectBaseTypeName()
133133
// extend intermediate .NET exception types (IOException, FileNotFoundException)
134134
var allowedBaseTypes = new HashSet<string?>
135135
{
136-
"Exception", "IOException", "FileNotFoundException", "UnauthorizedAccessException"
136+
"Exception", "IOException", "FileNotFoundException", "UnauthorizedAccessException", "ValueError"
137137
};
138138
foreach (var exType in exceptionTypes)
139139
{

src/Sharpy.Core.Tests/ItertoolsAdditionalTests.cs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// TODO: Temporarily disabled due to API mismatch with itertools implementation
2-
#if ITERTOOLS_ADDITIONAL_TESTS_ENABLED
31
using Xunit;
42
using FluentAssertions;
53
using System.Linq;
@@ -38,7 +36,8 @@ public void Accumulate_DefaultSum()
3836
var acc = new Sharpy.AccumulateIterator<int>(
3937
new[] { 1, 2, 3, 4, 5 }, null, default, false);
4038
var results = new System.Collections.Generic.List<int>();
41-
while (acc.MoveNext()) results.Add(acc.Current);
39+
while (acc.MoveNext())
40+
results.Add(acc.Current);
4241
results.Should().Equal(1, 3, 6, 10, 15);
4342
}
4443

@@ -48,7 +47,8 @@ public void Accumulate_WithFunc()
4847
var acc = new Sharpy.AccumulateIterator<int>(
4948
new[] { 1, 2, 3, 4, 5 }, (a, b) => a * b, default, false);
5049
var results = new System.Collections.Generic.List<int>();
51-
while (acc.MoveNext()) results.Add(acc.Current);
50+
while (acc.MoveNext())
51+
results.Add(acc.Current);
5252
results.Should().Equal(1, 2, 6, 24, 120);
5353
}
5454

@@ -58,7 +58,8 @@ public void Accumulate_WithInitial()
5858
var acc = new Sharpy.AccumulateIterator<int>(
5959
new[] { 1, 2, 3 }, null, 100, true);
6060
var results = new System.Collections.Generic.List<int>();
61-
while (acc.MoveNext()) results.Add(acc.Current);
61+
while (acc.MoveNext())
62+
results.Add(acc.Current);
6263
results.Should().Equal(100, 101, 103, 106);
6364
}
6465

@@ -77,7 +78,8 @@ public void Dropwhile_DropsWhileTrue()
7778
{
7879
var dw = new Sharpy.DropwhileIterator<int>(x => x < 5, new[] { 1, 4, 6, 4, 1 });
7980
var results = new System.Collections.Generic.List<int>();
80-
while (dw.MoveNext()) results.Add(dw.Current);
81+
while (dw.MoveNext())
82+
results.Add(dw.Current);
8183
results.Should().Equal(6, 4, 1);
8284
}
8385

@@ -86,7 +88,8 @@ public void Dropwhile_NeverTrue_YieldsAll()
8688
{
8789
var dw = new Sharpy.DropwhileIterator<int>(x => x > 100, new[] { 1, 2, 3 });
8890
var results = new System.Collections.Generic.List<int>();
89-
while (dw.MoveNext()) results.Add(dw.Current);
91+
while (dw.MoveNext())
92+
results.Add(dw.Current);
9093
results.Should().Equal(1, 2, 3);
9194
}
9295

@@ -95,7 +98,8 @@ public void Dropwhile_AlwaysTrue_YieldsNothing()
9598
{
9699
var dw = new Sharpy.DropwhileIterator<int>(x => x < 100, new[] { 1, 2, 3 });
97100
var results = new System.Collections.Generic.List<int>();
98-
while (dw.MoveNext()) results.Add(dw.Current);
101+
while (dw.MoveNext())
102+
results.Add(dw.Current);
99103
results.Should().BeEmpty();
100104
}
101105

@@ -106,7 +110,8 @@ public void Takewhile_TakesWhileTrue()
106110
{
107111
var tw = new Sharpy.TakewhileIterator<int>(x => x < 5, new[] { 1, 4, 6, 4, 1 });
108112
var results = new System.Collections.Generic.List<int>();
109-
while (tw.MoveNext()) results.Add(tw.Current);
113+
while (tw.MoveNext())
114+
results.Add(tw.Current);
110115
results.Should().Equal(1, 4);
111116
}
112117

@@ -115,7 +120,8 @@ public void Takewhile_AlwaysTrue_YieldsAll()
115120
{
116121
var tw = new Sharpy.TakewhileIterator<int>(x => x < 100, new[] { 1, 2, 3 });
117122
var results = new System.Collections.Generic.List<int>();
118-
while (tw.MoveNext()) results.Add(tw.Current);
123+
while (tw.MoveNext())
124+
results.Add(tw.Current);
119125
results.Should().Equal(1, 2, 3);
120126
}
121127

@@ -128,7 +134,8 @@ public void Compress_SelectsMatchingElements()
128134
new[] { "A", "B", "C", "D", "E", "F" },
129135
new[] { true, false, true, false, true, true });
130136
var results = new System.Collections.Generic.List<string>();
131-
while (c.MoveNext()) results.Add(c.Current);
137+
while (c.MoveNext())
138+
results.Add(c.Current);
132139
results.Should().Equal("A", "C", "E", "F");
133140
}
134141

@@ -139,7 +146,8 @@ public void Compress_UnevenLengths_StopsAtShorter()
139146
new[] { 1, 2, 3, 4, 5 },
140147
new[] { true, true });
141148
var results = new System.Collections.Generic.List<int>();
142-
while (c.MoveNext()) results.Add(c.Current);
149+
while (c.MoveNext())
150+
results.Add(c.Current);
143151
results.Should().Equal(1, 2);
144152
}
145153

@@ -150,7 +158,8 @@ public void Filterfalse_FiltersWherePredicateFalse()
150158
{
151159
var ff = new Sharpy.FilterfalseIterator<int>(x => x % 2 != 0, new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
152160
var results = new System.Collections.Generic.List<int>();
153-
while (ff.MoveNext()) results.Add(ff.Current);
161+
while (ff.MoveNext())
162+
results.Add(ff.Current);
154163
results.Should().Equal(0, 2, 4, 6, 8);
155164
}
156165

@@ -163,7 +172,8 @@ public void ZipLongest_FillsShorterIterables()
163172
new IEnumerable<string>[] { new[] { "A", "B" }, new[] { "x", "y", "z" } },
164173
"-");
165174
var results = new System.Collections.Generic.List<string[]>();
166-
while (zl.MoveNext()) results.Add(zl.Current);
175+
while (zl.MoveNext())
176+
results.Add(zl.Current);
167177
results.Should().HaveCount(3);
168178
results[0].Should().Equal("A", "x");
169179
results[1].Should().Equal("B", "y");
@@ -177,7 +187,8 @@ public void Pairwise_ReturnsSlidingPairs()
177187
{
178188
var pw = new Sharpy.PairwiseIterator<int>(new[] { 1, 2, 3, 4, 5 });
179189
var results = new System.Collections.Generic.List<(int, int)>();
180-
while (pw.MoveNext()) results.Add(pw.Current);
190+
while (pw.MoveNext())
191+
results.Add(pw.Current);
181192
results.Should().Equal((1, 2), (2, 3), (3, 4), (4, 5));
182193
}
183194

@@ -203,7 +214,8 @@ public void Product_TwoIterables_ReturnsCartesianProduct()
203214
var p = new Sharpy.ProductIterator<string>(
204215
new IEnumerable<string>[] { new[] { "A", "B" }, new[] { "1", "2" } });
205216
var results = new System.Collections.Generic.List<string[]>();
206-
while (p.MoveNext()) results.Add(p.Current);
217+
while (p.MoveNext())
218+
results.Add(p.Current);
207219
results.Should().HaveCount(4);
208220
results[0].Should().Equal("A", "1");
209221
results[1].Should().Equal("A", "2");
@@ -241,7 +253,8 @@ public void CombinationsWithReplacement_ReturnsCorrect()
241253
{
242254
var cwr = new Sharpy.CombinationsWithReplacementIterator<char>(new[] { 'A', 'B' }, 2);
243255
var results = new System.Collections.Generic.List<char[]>();
244-
while (cwr.MoveNext()) results.Add(cwr.Current);
256+
while (cwr.MoveNext())
257+
results.Add(cwr.Current);
245258
results.Should().HaveCount(3);
246259
results[0].Should().Equal('A', 'A');
247260
results[1].Should().Equal('A', 'B');
@@ -264,4 +277,3 @@ public void CombinationsWithReplacement_NegativeR_ThrowsValueError()
264277
.Should().Throw<Sharpy.ValueError>();
265278
}
266279
}
267-
#endif

src/Sharpy.Core.Tests/MathAdditionalTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public void Perm_KZero_ReturnsOne()
116116
public void Fsum_AccurateSummation()
117117
{
118118
var values = new double[10];
119-
for (int i = 0; i < 10; i++) values[i] = 0.1;
119+
for (int i = 0; i < 10; i++)
120+
values[i] = 0.1;
120121
Sharpy.Math.Fsum(values).Should().Be(1.0);
121122
}
122123

src/Sharpy.Core.Tests/OsModuleTests.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// TODO: Temporarily disabled due to API mismatch with os implementation
2-
#if OS_MODULE_TESTS_ENABLED
31
using System;
42
using System.IO;
53
using FluentAssertions;
@@ -33,11 +31,15 @@ public void Dispose()
3331
{
3432
foreach (var f in _tempFiles)
3533
{
36-
try { File.Delete(f); } catch { }
34+
try
35+
{ File.Delete(f); }
36+
catch { }
3737
}
3838
foreach (var d in _tempDirs)
3939
{
40-
try { Directory.Delete(d, true); } catch { }
40+
try
41+
{ Directory.Delete(d, true); }
42+
catch { }
4143
}
4244
}
4345

@@ -249,13 +251,13 @@ public void Walk_Traverses_Directory_Tree()
249251
File.WriteAllText(System.IO.Path.Combine(root, "root.txt"), "");
250252
File.WriteAllText(System.IO.Path.Combine(root, "sub1", "a.txt"), "");
251253

252-
var entries = new System.Collections.Generic.List<(string, Sharpy.List<string>, Sharpy.List<string>)>();
254+
var entries = new System.Collections.Generic.List<(string dirpath, Sharpy.List<string> dirnames, Sharpy.List<string> filenames)>();
253255
foreach (var entry in Os.Walk(root))
254256
{
255257
entries.Add(entry);
256258
}
257259

258-
entries.Should().HaveCountGreaterOrEqualTo(3);
260+
entries.Should().HaveCountGreaterThanOrEqualTo(3);
259261
entries[0].dirpath.Should().Be(root);
260262
entries[0].dirnames.Should().Contain("sub1");
261263
entries[0].filenames.Should().Contain("root.txt");
@@ -264,7 +266,7 @@ public void Walk_Traverses_Directory_Tree()
264266
[Fact]
265267
public void Walk_Nonexistent_Yields_Nothing()
266268
{
267-
var entries = new System.Collections.Generic.List<(string, Sharpy.List<string>, Sharpy.List<string>)>();
269+
var entries = new System.Collections.Generic.List<(string dirpath, Sharpy.List<string> dirnames, Sharpy.List<string> filenames)>();
268270
foreach (var entry in Os.Walk("/tmp/nonexistent_" + Guid.NewGuid()))
269271
{
270272
entries.Add(entry);
@@ -298,4 +300,3 @@ public void Stat_Nonexistent_Throws()
298300
act.Should().Throw<FileNotFoundError>();
299301
}
300302
}
301-
#endif

src/Sharpy.Core.Tests/OsPathTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public void Dispose()
2222
{
2323
foreach (var f in _tempFiles)
2424
{
25-
try { File.Delete(f); } catch { }
25+
try
26+
{ File.Delete(f); }
27+
catch { }
2628
}
2729
}
2830

src/Sharpy.Core.Tests/PathlibTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ public void Dispose()
3232
{
3333
foreach (var f in _tempFiles)
3434
{
35-
try { File.Delete(f); } catch { }
35+
try
36+
{ File.Delete(f); }
37+
catch { }
3638
}
3739
foreach (var d in _tempDirs)
3840
{
39-
try { Directory.Delete(d, true); } catch { }
41+
try
42+
{ Directory.Delete(d, true); }
43+
catch { }
4044
}
4145
}
4246

0 commit comments

Comments
 (0)