Skip to content

Commit

Permalink
Fix erroneous list "fix"
Browse files Browse the repository at this point in the history
The c. was never required. That resulted from an
incorrectly written unit test.
  • Loading branch information
sblom committed Dec 15, 2023
1 parent 8253829 commit ab98627
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions RegExtract.Test/Usage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,21 @@ public void a005()
[Fact]
public void a006()
{
var str = ExtractionPlan<List<int>>.CreatePlan(new Regex(@"((\d+) ?)+")).ToString("x");
var plan = ExtractionPlan<List<int>>.CreatePlan(new Regex(@"((\d+) ?)+"));
var str = plan.ToString("x");
output.WriteLine(str);

var result = plan.Extract("123 456 789");
}

[Fact]
public void a007()
{
var str = ExtractionPlan<List<int>>.CreatePlan(new Regex(@"(?:(\d+) ?)+")).ToString("x");
var plan = ExtractionPlan<List<int>>.CreatePlan(new Regex(@"(?:(\d+) ?)+"));
var str = plan.ToString("x");
output.WriteLine(str);

var result = plan.Extract("123 456 789");
}

[Fact]
Expand Down Expand Up @@ -345,13 +351,25 @@ public void nested_extraction()
[Fact]
public void nested_extraction_of_list()
{
var plan = ExtractionPlan<List<List<char>>>.CreatePlan(new Regex(@"(((\w)+) ?)+"));
// TODO: Why does this need the outer parens here: "((\w)+)"?
var plan = ExtractionPlan<List<List<char>>>.CreatePlan(new Regex(@"((\w)+ ?)+"));
var str = plan.ToString("x");
output.WriteLine(str);

var result = plan.Extract("The quick brown fox jumps over the lazy dog.");
}

[Fact]
public void harder_nested_extraction_of_list()
{
// TODO: This currently doesn't quite work without extra parens outsize the top level.
var plan = ExtractionPlan<List<List<List<char>>>>.CreatePlan(new Regex(@"(((\w)+ ?)+,? ?)+"));
var str = plan.ToString("x");
output.WriteLine(str);

var result = plan.Extract("asdf lkj, wero oiu");
}

[Fact]
public void nested_extraction_of_bags()
{
Expand Down
2 changes: 1 addition & 1 deletion RegExtract/ExtractionPlanNodeTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal record CollectionInitializerNode(string groupName, Type type, Extractio

object?[] itemVals = new object[genericArgs.Length];

var rangeArray = constructorParams.Select(c => Ranges(match, c.groupName, captureStart, captureLength).GetEnumerator()).ToArray();
var rangeArray = constructorParams.Select(c => Ranges(match, groupName, captureStart, captureLength).GetEnumerator()).ToArray();

do
{
Expand Down

0 comments on commit ab98627

Please sign in to comment.