datalust / superpower

A C# parser construction toolkit with high-quality error reporting
Apache License 2.0
1.07k stars 99 forks source link

TextSpan.Until Behaviour #65

Closed AndrewSav closed 5 years ago

AndrewSav commented 5 years ago

TextSpan.Until is documented as

Return a new span from the start of this span to the beginning of another.

So I expect this to work:

string source = "123";
Position one = Position.Zero.Advance(source[0]);
TextSpan t1 = new TextSpan(source);
TextSpan t2 = new TextSpan(source, one, 1);        
Assert.AreEqual("1",t1.Until(t2).ToStringValue());

But it does not because the code assume that both text spans should end in the same position. This is fine, but this not documented and it is not checked in the code. Am I'm missing something?

nblumhardt commented 5 years ago

I believe #66 will fix this. I'll add a test case there. Thanks!

nblumhardt commented 5 years ago

Slightly different problem; rolled it into the same PR :-)